fb81609fc220031f3eeb818bdb453d88d083ee7c
[vfc/nfvo/lcm.git] / lcm / ns_vnfs / serializers / grant_vnf_serializer.py
1 # Copyright 2018 ZTE Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from rest_framework import serializers
16
17 from lcm.ns.serializers.sol.ext_virtual_link_info import ExtVirtualLinkInfoSerializer
18 from lcm.ns.serializers.sol.cp_serializers import AddressRangeSerializer
19 from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
20 from lcm.ns.serializers.sol.pub_serializers import ProblemDetailsSerializer, LinkSerializer
21 from lcm.ns.enum import LAYER_PROTOCOL, IPADDRESSES_TYPE, AFFINITY_OR_ANTIAFFIINTY_SCOPE, AFFINITY_OR_ANTIAFFIINTY, LCM_NOTIFICATION_STATUS, OPERATION_STATE_TYPE
22 from lcm.ns_vnfs.enum import STORAGE_CHANGE_TYPE, VNFC_CHANGE_TYPE, VL_CHANGE_TYPE, RESOURE_TYPE, RESOURCE_ID_TYPE, GRANT_OPERATION, VNF_NOTIFICATION_TYPE
23 from lcm.pub.utils.enumutil import enum_to_list
24
25
26 class ResourceDefinitionSerializer(serializers.Serializer):
27     id = serializers.CharField(
28         help_text="Identifier of this ResourceDefinition, unique at least within the scope of the GrantRequest.",
29         required=True
30     )
31     type = serializers.ChoiceField(
32         help_text="Type of the resource definition referenced.",
33         choices=enum_to_list(RESOURE_TYPE),
34         required=True
35     )
36     vduId = serializers.CharField(
37         help_text="Reference to the related VDU in the VNFD applicable to this resource.",
38         required=False,
39         allow_null=True,
40         allow_blank=True
41     )
42     resourceTemplateId = serializers.CharField(
43         help_text="Reference to a resource template(such as VnfVirtualLinkDesc) in the VNFD.",
44         required=False,
45         allow_null=True,
46         allow_blank=True
47     )
48     resource = ResourceHandleSerializer(
49         help_text="Resource information for an existing resource.",
50         required=False,
51         allow_null=True
52     )
53
54
55 class ConstraintResourceRefSerializer(serializers.Serializer):
56     idType = serializers.ChoiceField(
57         help_text="The type of the identifier.",
58         choices=enum_to_list(RESOURCE_ID_TYPE),
59         required=True
60     )
61     resourceId = serializers.CharField(
62         help_text="An actual resource-management-level identifier(idType=RES_MGMT), or an identifier that references a ResourceDefinition(idType=GRANT).",
63         required=True
64     )
65     vimConnectionId = serializers.CharField(
66         help_text="",
67         required=False,
68         allow_null=True,
69         allow_blank=True
70     )
71     resourceProviderId = serializers.CharField(
72         help_text="Identifier of the resource provider. It shall only be present when idType = RES_MGMT.",
73         required=False,
74         allow_null=True,
75         allow_blank=True
76     )
77
78
79 class PlacementConstraintSerializer(serializers.Serializer):
80     affinityOrAntiAffinity = serializers.ChoiceField(
81         help_text="The type of the constraint.",
82         choices=enum_to_list(AFFINITY_OR_ANTIAFFIINTY),
83         required=True
84     )
85     scope = serializers.ChoiceField(
86         help_text="The scope of the placement constraint indicating the category of the place where the constraint applies.",
87         choices=enum_to_list(AFFINITY_OR_ANTIAFFIINTY_SCOPE),
88         required=True
89     )
90     resource = ConstraintResourceRefSerializer(
91         help_text="References to resources in the constraint rule.",
92         many=True,
93         required=False
94     )
95
96
97 class VimConstraintSerializer(serializers.Serializer):
98     sameResourceGroup = serializers.BooleanField(
99         help_text="Set to true when the constraint applies not only to the same VIM connection, but also to the same infrastructure resource group.",
100         required=False
101     )
102     resource = ConstraintResourceRefSerializer(
103         help_text="References to resources in the constraint rule.",
104         many=True,
105         required=False
106     )
107
108
109 # class LinkSerializer(serializers.Serializer):
110 #     href = serializers.CharField(
111 #         help_text="URI of the referenced resource.",
112 #         required=True
113 #     )
114
115
116 class GrantRequestLinksSerializer(serializers.Serializer):
117     vnfLcmOpOcc = LinkSerializer(
118         help_text="Related VNF lifecycle management operation occurrence.",
119         required=True
120     )
121     vnfInstance = LinkSerializer(
122         help_text="Related VNF instance.",
123         required=True
124     )
125
126
127 class GrantRequestSerializer(serializers.Serializer):
128     vnfInstanceId = serializers.CharField(
129         help_text="Identifier of the VNF instance which this grant request is related to.",
130         required=True
131     )
132     vnfLcmOpOccId = serializers.CharField(
133         help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
134         required=False,  # TODO required
135         allow_null=True,
136         allow_blank=True
137     )
138     vnfdId = serializers.CharField(
139         help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
140         required=False,  # TODO required
141         allow_null=True,
142         allow_blank=True
143     )
144     flavourId = serializers.CharField(
145         help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
146         required=False,
147         allow_null=True,
148         allow_blank=True
149     )
150     operation = serializers.ChoiceField(
151         help_text="The lifecycle management operation for which granting is requested.",
152         choices=enum_to_list(GRANT_OPERATION),
153         required=True
154     )
155     isAutomaticInvocation = serializers.BooleanField(
156         help_text="Set to true if this VNF LCM operation occurrence has been triggered by an automated procedure inside the VNFM, set to false otherwise.",
157         required=True
158     )
159     instantiationLevelId = serializers.CharField(
160         help_text="If operation=INSTANTIATE, the identifier of the instantiation level may be provided as an alternative way to define the resources to be added.",
161         required=False,
162         allow_null=True,
163         allow_blank=True
164     )
165     addResources = ResourceDefinitionSerializer(
166         help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
167         many=True,
168         required=False
169     )
170     tempResources = ResourceDefinitionSerializer(
171         help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
172         many=True,
173         required=False
174     )
175     removeResources = ResourceDefinitionSerializer(
176         help_text="Provides the definitions of resources to be removed by the LCM operation.",
177         many=True,
178         required=False
179     )
180     updateResources = ResourceDefinitionSerializer(
181         help_text="Provides the definitions of resources to be modified by the LCM operation.",
182         many=True,
183         required=False
184     )
185     placementConstraints = PlacementConstraintSerializer(
186         help_text="Placement constraints that the VNFM may send to the NFVO in order to influence the resource placement decision.",
187         many=True,
188         required=False
189     )
190     vimConstraints = VimConstraintSerializer(
191         help_text="Used by the VNFM to require that multiple resources are managed through the same VIM connection.",
192         many=True,
193         required=False
194     )
195     additionalParams = serializers.DictField(
196         help_text="Additional parameters passed by the VNFM.",
197         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
198         required=False,
199         allow_null=True
200     )
201     _links = GrantRequestLinksSerializer(
202         help_text="Links to resources related to this request.",
203         required=False  # TODO required
204     )
205
206
207 class VimConnectionInfoSerializer(serializers.Serializer):
208     id = serializers.CharField(
209         help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
210         required=True
211     )
212     vimId = serializers.CharField(
213         help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
214         required=False,
215         allow_null=True,
216         allow_blank=True
217     )
218     vimType = serializers.CharField(
219         help_text="Discriminator for the different types of the VIM information.",
220         required=False,
221         allow_null=True,
222         allow_blank=True
223     )
224     interfaceInfo = serializers.DictField(
225         help_text="Information about the interface or interfaces to the VIM.",
226         child=serializers.CharField(help_text="Interface Info", allow_blank=True),
227         required=False,
228         allow_null=True
229     )
230     accessInfo = serializers.DictField(
231         help_text="Authentication credentials for accessing the VIM.",
232         child=serializers.CharField(help_text="Access Info", allow_blank=True),
233         required=False,
234         allow_null=True
235     )
236     extra = serializers.DictField(
237         help_text="VIM type specific additional information.",
238         child=serializers.CharField(help_text="Extra", allow_blank=True),
239         required=False,
240         allow_null=True
241     )
242
243
244 class ZoneInfoSerializer(serializers.Serializer):
245     id = serializers.CharField(
246         help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
247         required=True
248     )
249     zoneId = serializers.CharField(
250         help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
251         required=False,
252         allow_null=True,
253         allow_blank=True
254     )
255     vimConnectionId = serializers.CharField(
256         help_text="Identifier of the connection to the VIM that manages the resource zone.",
257         required=False,
258         allow_null=True,
259         allow_blank=True
260     )
261     resourceProviderId = serializers.CharField(
262         help_text="Identifies the entity responsible for the management the resource zone.",
263         required=False,
264         allow_null=True,
265         allow_blank=True
266     )
267
268
269 class ZoneGroupInfoSerializer(serializers.Serializer):
270     zoneId = serializers.ListSerializer(
271         help_text="References of identifiers of ZoneInfo structures.",
272         child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
273         required=False,
274         allow_null=True
275     )
276
277
278 class GrantInfoSerializer(serializers.Serializer):
279     resourceDefinitionId = serializers.CharField(
280         help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
281         required=True
282     )
283     reservationId = serializers.CharField(
284         help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
285         required=False,
286         allow_null=True,
287         allow_blank=True
288     )
289     vimConnectionId = serializers.CharField(
290         help_text="Identifier of the VIM connection to be used to manage this resource.",
291         required=False,
292         allow_null=True,
293         allow_blank=True
294     )
295     resourceProviderId = serializers.CharField(
296         help_text="Identifies the entity responsible for the management of the virtualised resource.",
297         required=False,
298         allow_null=True,
299         allow_blank=True
300     )
301     zoneId = serializers.CharField(
302         help_text="Reference to the identifier of the ZoneInfo in the Grant.",
303         required=False,
304         allow_null=True,
305         allow_blank=True
306     )
307     resourceGroupId = serializers.CharField(
308         help_text="Identifier of the infrastructure resource group.",
309         required=False,
310         allow_null=True,
311         allow_blank=True
312     )
313
314
315 class VimComputeResourceFlavourSerializer(serializers.Serializer):
316     vimConnectionId = serializers.CharField(
317         help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
318         required=False,
319         allow_null=True,
320         allow_blank=True
321     )
322     resourceProviderId = serializers.CharField(
323         help_text="Identifies the entity responsible for the management of the virtualised resource.",
324         required=False,
325         allow_null=True,
326         allow_blank=True
327     )
328     vnfdVirtualComputeDescId = serializers.CharField(
329         help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
330         required=False,
331         allow_null=True,
332         allow_blank=True
333     )
334     vimFlavourId = serializers.CharField(
335         help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
336         required=False,
337         allow_null=True,
338         allow_blank=True
339     )
340
341
342 class VimSoftwareImageSerializer(serializers.Serializer):
343     vimConnectionId = serializers.CharField(
344         help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
345         required=False,
346         allow_null=True,
347         allow_blank=True
348     )
349     resourceProviderId = serializers.CharField(
350         help_text="Identifies the entity responsible for the management of the virtualised resource.",
351         required=False,
352         allow_null=True,
353         allow_blank=True
354     )
355     vnfdSoftwareImageId = serializers.CharField(
356         help_text="Identifier which references the software image descriptor in the VNFD.",
357         required=False,
358         allow_null=True,
359         allow_blank=True
360     )
361     vimSoftwareImageId = serializers.CharField(
362         help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
363         required=False,
364         allow_null=True,
365         allow_blank=True
366     )
367
368
369 class VimAssetsSerializer(serializers.Serializer):
370     computeResourceFlavours = VimComputeResourceFlavourSerializer(
371         help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
372         many=True,
373         required=False
374     )
375     softwareImages = VimSoftwareImageSerializer(
376         help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
377         many=True,
378         required=False
379     )
380
381
382 # class AddressRangeSerializer(serializers.Serializer):
383 #     minAddress = serializers.CharField(
384 #         help_text="Lowest IP address belonging to the range.",
385 #         required=True
386 #     )
387 #     maxAddress = serializers.CharField(
388 #         help_text="Highest IP address belonging to the range.",
389 #         required=True
390 #     )
391
392
393 class IpAddresseSerializer(serializers.Serializer):
394     type = serializers.ChoiceField(
395         help_text="The type of the IP addresses.",
396         choices=enum_to_list(IPADDRESSES_TYPE),
397         required=True
398     )
399     fixedAddresses = serializers.ListSerializer(
400         help_text="Fixed addresses to assign.",
401         child=serializers.CharField(help_text="IpAddress"),
402         required=False,
403         allow_null=True
404     )
405     numDynamicAddresses = serializers.IntegerField(
406         help_text="Number of dynamic addresses to assign.",
407         required=True
408     )
409     addressRange = AddressRangeSerializer(
410         help_text="An IP address range to be used, e.g. in case of egress connections.",
411         required=False,
412         allow_null=True
413     )
414     subnetId = serializers.CharField(
415         help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
416         required=False,
417         allow_null=True,
418         allow_blank=True
419     )
420
421
422 class IpOverEthernetAddressSerializer(serializers.Serializer):
423     macAddress = serializers.CharField(
424         help_text="MAC address.",
425         required=False,
426         allow_null=True,
427         allow_blank=True
428     )
429     ipAddresses = IpAddresseSerializer(
430         help_text="List of IP addresses to assign to the CP instance.",
431         many=True,
432         required=False
433     )
434
435
436 class CpProtocolDataConfigSerializer(serializers.Serializer):
437     layerProtocol = serializers.ChoiceField(
438         help_text="Identifier of layer(s) and protocol(s).",
439         choices=enum_to_list(LAYER_PROTOCOL),
440         required=True
441     )
442     ipOverEthernet = IpOverEthernetAddressSerializer(
443         help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
444         required=False,
445         allow_null=True,
446     )
447
448
449 class VnfExtCpConfigDataSerializer(serializers.Serializer):
450     cpInstanceId = serializers.CharField(
451         help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
452         required=False,
453         allow_null=True,
454         allow_blank=True
455     )
456     linkPortId = serializers.CharField(
457         help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
458         required=False,
459         allow_null=True,
460         allow_blank=True
461     )
462     cpProtocolData = CpProtocolDataConfigSerializer(
463         help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
464         many=True,
465         required=False
466     )
467
468
469 class VnfExtCpSerializer(serializers.Serializer):
470     cpdId = serializers.CharField(
471         help_text="The identifier of the CPD in the VNFD.",
472         required=True
473     )
474     cpConfig = VnfExtCpConfigDataSerializer(
475         help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
476         many=True,
477         required=False
478     )
479
480
481 class ExtLinkPortSerializer(serializers.Serializer):
482     id = serializers.CharField(
483         help_text="Identifier of this link port as provided by the entity that has created the link port.",
484         required=True
485     )
486     resourceHandle = serializers.CharField(
487         help_text="Reference to the virtualised resource realizing this link port.",
488         required=True
489     )
490
491
492 class ExtVirtualLinkSerializer(serializers.Serializer):
493     id = serializers.CharField(
494         help_text="The identifier of the external VL instance.",
495         required=True
496     )
497     vimConnectionId = serializers.CharField(
498         help_text="Identifier of the VIM connection to manage this resource.",
499         required=False,
500         allow_null=True,
501         allow_blank=True
502     )
503     resourceProviderId = serializers.CharField(
504         help_text="Identifies the entity responsible for the management of this resource.",
505         required=False,
506         allow_null=True,
507         allow_blank=True
508     )
509     resourceId = serializers.CharField(
510         help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
511         required=True
512     )
513     extCps = VnfExtCpSerializer(
514         help_text="External CPs of the VNF to be connected to this external VL.",
515         many=True,
516         required=False
517     )
518     extLinkPorts = ExtLinkPortSerializer(
519         help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
520         many=True,
521         required=False
522     )
523
524
525 class ExtManagedVirtualLinkSerializer(serializers.Serializer):
526     id = serializers.CharField(
527         help_text="The identifier of the externally-managed internal VL instance.",
528         required=True
529     )
530     virtualLinkDescId = serializers.CharField(
531         help_text="The identifier of the VLD in the VNFD for this VL.",
532         required=True
533     )
534     vimConnectionId = serializers.CharField(
535         help_text="Identifier of the VIM connection to manage this resource.",
536         required=False,
537         allow_null=True,
538         allow_blank=True
539     )
540     resourceProviderId = serializers.CharField(
541         help_text="Identifies the entity responsible for the management of this resource.",
542         required=False,
543         allow_null=True,
544         allow_blank=True
545     )
546     resourceId = serializers.CharField(
547         help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
548         required=True
549     )
550
551
552 class GrantLinksSerializer(serializers.Serializer):
553     self = LinkSerializer(
554         help_text="URI of this resource.",
555         required=True
556     )
557     vnfLcmOpOcc = LinkSerializer(
558         help_text="Related VNF lifecycle management operation occurrence.",
559         required=True
560     )
561     vnfInstance = LinkSerializer(
562         help_text="Related VNF instance.",
563         required=True
564     )
565
566
567 class GrantSerializer(serializers.Serializer):
568     id = serializers.CharField(
569         help_text="Identifier of the grant.",
570         required=True
571     )
572     vnfInstanceId = serializers.CharField(
573         help_text="Identifier of the related VNF instance.",
574         required=True
575     )
576     vnfLcmOpOccId = serializers.CharField(
577         help_text="Identifier of the related VNF lifecycle management operation occurrence.",
578         required=False,  # TODO required
579         allow_null=True,
580         allow_blank=True
581     )
582     vimConnections = VimConnectionInfoSerializer(
583         help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
584         many=True,
585         required=False
586     )
587     zones = ZoneInfoSerializer(
588         help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
589         many=True,
590         required=False
591     )
592     zoneGroups = ZoneGroupInfoSerializer(
593         help_text="Information about groups of resource zones.",
594         many=True,
595         required=False
596     )
597     computeReservationId = serializers.CharField(
598         help_text="Information that identifies a reservation applicable to the compute resource requirements.",
599         required=False,
600         allow_null=True,
601         allow_blank=True
602     )
603     networkReservationId = serializers.CharField(
604         help_text="Information that identifies a reservation applicable to the network resource requirements.",
605         required=False,
606         allow_null=True,
607         allow_blank=True
608     )
609     storageReservationId = serializers.CharField(
610         help_text="Information that identifies a reservation applicable to the storage resource requirements.",
611         required=False,
612         allow_null=True,
613         allow_blank=True
614     )
615     addResources = GrantInfoSerializer(
616         help_text="List of resources that are approved to be added.",
617         many=True,
618         required=False
619     )
620     tempResources = GrantInfoSerializer(
621         help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
622         many=True,
623         required=False
624     )
625     removeResources = GrantInfoSerializer(
626         help_text="List of resources that are approved to be removed.",
627         many=True,
628         required=False
629     )
630     updateResources = GrantInfoSerializer(
631         help_text="List of resources that are approved to be modified.",
632         many=True,
633         required=False
634     )
635     vimAssets = VimAssetsSerializer(
636         help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
637         required=False,
638         allow_null=True
639     )
640     extVirtualLinks = ExtVirtualLinkSerializer(
641         help_text="Information about external VLs to connect the VNF to.",
642         many=True,
643         required=False
644     )
645     extManagedVirtualLinks = ExtManagedVirtualLinkSerializer(
646         help_text="Information about internal VLs that are managed by other entities than the VNFM.",
647         many=True,
648         required=False
649     )
650     additionalParams = serializers.DictField(
651         help_text="Additional parameters passed by the NFVO, \
652         specific to the VNF and the LCM operation.",
653         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
654         required=False,
655         allow_null=True
656     )
657     _links = GrantLinksSerializer(
658         help_text="Links to resources related to this resource.",
659         required=False
660     )
661
662
663 class AffectedVnfcSerializer(serializers.Serializer):
664     id = serializers.CharField(
665         help_text="Identifier of the Vnfc instance.",
666         required=True
667     )
668     vduId = serializers.CharField(
669         help_text="Identifier of the related VDU in the VNFD.",
670         required=True
671     )
672     changeType = serializers.ChoiceField(
673         help_text="Signals the type of change.",
674         choices=enum_to_list(VNFC_CHANGE_TYPE),
675         required=True
676     )
677     computeResource = ResourceHandleSerializer(
678         help_text="Reference to the VirtualCompute resource.",
679         required=True
680     )
681     metadata = serializers.DictField(
682         help_text="Metadata about this resource.",
683         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
684         required=False,
685         allow_null=True
686     )
687     affectedVnfcCpIds = serializers.ListSerializer(
688         help_text="Identifiers of CP(s) of the VNFC instance that were affected by the change.",
689         child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
690         required=False,
691         allow_null=True
692     )
693     addedStorageResourceIds = serializers.ListSerializer(
694         help_text="References to VirtualStorage resources that have been added.",
695         child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
696         required=False,
697         allow_null=True
698     )
699     removedStorageResourceIds = serializers.ListSerializer(
700         help_text="References to VirtualStorage resources that have been removed.",
701         child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
702         required=False,
703         allow_null=True
704     )
705
706
707 class AffectedVirtualLinkSerializer(serializers.Serializer):
708     id = serializers.CharField(
709         help_text="Identifier of the virtual link instance.",
710         required=True
711     )
712     virtualLinkDescId = serializers.CharField(
713         help_text="Identifier of the related VLD in the VNFD.",
714         required=True
715     )
716     changeType = serializers.ChoiceField(
717         help_text="Signals the type of change.",
718         choices=enum_to_list(VL_CHANGE_TYPE),
719         required=True
720     )
721     networkResource = ResourceHandleSerializer(
722         help_text="Reference to the VirtualNetwork resource.",
723         required=False,
724         allow_null=True
725     )
726     metadata = serializers.DictField(
727         help_text="Metadata about this resource.",
728         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
729         required=False,
730         allow_null=True
731     )
732
733
734 class AffectedVirtualStorageSerializer(serializers.Serializer):
735     id = serializers.CharField(
736         help_text="Identifier of the storage instance.",
737         required=True
738     )
739     virtualStorageDescId = serializers.CharField(
740         help_text="Identifier of the related VirtualStorage descriptor in the VNFD.",
741         required=True
742     )
743     changeType = serializers.ChoiceField(
744         help_text="Signals the type of change.",
745         choices=enum_to_list(STORAGE_CHANGE_TYPE),
746         required=True
747     )
748     storageResource = ResourceHandleSerializer(
749         help_text="Reference to the VirtualStorage resource.",
750         required=False,
751         allow_null=True
752     )
753     metadata = serializers.DictField(
754         help_text="Metadata about this resource.",
755         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
756         required=False,
757         allow_null=True
758     )
759
760
761 class VnfInfoModificationsSerializer(serializers.Serializer):
762     vnfInstanceName = serializers.CharField(
763         help_text="If present, this attribute signals modifications of the vnfInstanceName attribute in VnfInstance.",
764         required=False,
765         allow_null=True,
766         allow_blank=True
767     )
768     vnfInstanceDescription = serializers.CharField(
769         help_text="If present, this attribute signals modifications of the vnfInstanceDescription attribute in VnfInstance.",
770         required=False,
771         allow_null=True,
772         allow_blank=True
773     )
774     vnfConfigurableProperties = serializers.DictField(
775         help_text="If present, this attribute signals modifications of the vnfConfigurableProperties attribute in VnfInstance.",
776         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
777         required=False,
778         allow_null=True
779     )
780     metadata = serializers.DictField(
781         help_text="If present, this attribute signals modifications of the metadata attribute in VnfInstance.",
782         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
783         required=False,
784         allow_null=True
785     )
786     extensions = serializers.DictField(
787         help_text="If present, this attribute signals modifications of the extensions attribute in VnfInstance.",
788         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
789         required=False,
790         allow_null=True
791     )
792     vimConnectionInfo = VimConnectionInfoSerializer(
793         help_text="If present, this attribute signals modifications of the vimConnectionInfo attribute in VnfInstance.",
794         many=True,
795         required=False
796     )
797     vnfPkgId = serializers.CharField(
798         help_text="If present, this attribute signals modifications of the vnfPkgId attribute in VnfInstance.",
799         required=False,
800         allow_null=True,
801         allow_blank=True
802     )
803     vnfdId = serializers.CharField(
804         help_text="If present, this attribute signals modifications of the vnfdId attribute in VnfInstance.",
805         required=False,
806         allow_null=True,
807         allow_blank=True
808     )
809     vnfProvider = serializers.CharField(
810         help_text="If present, this attribute signals modifications of the vnfProvider attribute in VnfInstance.",
811         required=False,
812         allow_null=True,
813         allow_blank=True
814     )
815     vnfProductName = serializers.CharField(
816         help_text="If present, this attribute signals modifications of the vnfProductName attribute in VnfInstance.",
817         required=False,
818         allow_null=True,
819         allow_blank=True
820     )
821     vnfSoftwareVersion = serializers.CharField(
822         help_text="If present, this attribute signals modifications of the vnfSoftwareVersion attribute in VnfInstance.",
823         required=False,
824         allow_null=True,
825         allow_blank=True
826     )
827     vnfdVersion = serializers.CharField(
828         help_text="If present, this attribute signals modifications of the vnfdVersion attribute in VnfInstance.",
829         required=False,
830         allow_null=True,
831         allow_blank=True
832     )
833
834
835 class ExtLinkPortInfoSerializer(serializers.Serializer):
836     id = serializers.CharField(
837         help_text="Identifier of this link port as provided by the entity that has created the link port.",
838         required=True
839     )
840     resourceHandle = ResourceHandleSerializer(
841         help_text="Reference to the virtualised resource realizing this link port.",
842         required=True
843     )
844     cpInstanceId = serializers.CharField(
845         help_text="Identifier of the external CP of the VNF connected to this link port.",
846         required=False,
847         allow_null=True,
848         allow_blank=True
849     )
850
851
852 # class ExtVirtualLinkInfoSerializer(serializers.Serializer):
853 #     id = serializers.CharField(
854 #         help_text="Identifier of the external VL and the related external VL information instance.",
855 #         required=True
856 #     )
857 #     resourceHandle = ResourceHandleSerializer(
858 #         help_text="Reference to the resource realizing this VL.",
859 #         required=True
860 #     )
861 #     extLinkPorts = ExtLinkPortInfoSerializer(
862 #         help_text="Link ports of this VL.",
863 #         many=True,
864 #         required=False
865 #     )
866
867
868 # class ProblemDetailsSerializer(serializers.Serializer):
869 #     type = serializers.CharField(
870 #         help_text="A URI reference according to IETF RFC 3986 [5] that identifies the problem type.",
871 #         required=False,
872 #         allow_null=True,
873 #         allow_blank=True
874 #     )
875 #     title = serializers.CharField(
876 #         help_text="A short, human-readable summary of the problem type.",
877 #         required=False,
878 #         allow_null=True,
879 #         allow_blank=True
880 #     )
881 #     status = serializers.IntegerField(
882 #         help_text="The HTTP status code for this occurrence of the problem.",
883 #         required=True
884 #     )
885 #     detail = serializers.CharField(
886 #         help_text="A human-readable explanation specific to this occurrence of the problem.",
887 #         required=True
888 #     )
889 #     instance = serializers.CharField(
890 #         help_text="A URI reference that identifies the specific occurrence of the problem.",
891 #         required=False,
892 #         allow_null=True,
893 #         allow_blank=True
894 #     )
895
896
897 class LccnLinksSerializer(serializers.Serializer):
898     vnfInstance = LinkSerializer(
899         help_text="Link to the resource representing the VNF instance to which the notified change applies.",
900         required=True
901     )
902     subscription = LinkSerializer(
903         help_text="Link to the related subscription.",
904         required=True
905     )
906     vnfLcmOpOcc = LinkSerializer(
907         help_text="Link to the VNF lifecycle management operation occurrence that this notification is related to.",
908         required=False,
909         allow_null=True
910     )
911
912
913 class VnfLcmOperationOccurrenceNotificationSerializer(serializers.Serializer):
914     id = serializers.CharField(
915         help_text="Identifier of this notification.",
916         required=True
917     )
918     notificationType = serializers.ChoiceField(
919         help_text="Discriminator for the different notification types.",
920         choices=enum_to_list(VNF_NOTIFICATION_TYPE),
921         required=True
922     )
923     subscriptionId = serializers.CharField(
924         help_text="Identifier of the subscription that this notification relates to.",
925         required=True
926     )
927     timeStamp = serializers.CharField(
928         help_text="Date-time of the generation of the notification.",
929         required=True
930     )
931     notificationStatus = serializers.ChoiceField(
932         help_text="Indicates whether this notification reports about the start of a lifecycle operation or the result of a lifecycle operation.",
933         choices=enum_to_list(LCM_NOTIFICATION_STATUS),
934         required=True
935     )
936     operationState = serializers.ChoiceField(
937         help_text="The state of the VNF LCM operation occurrence.",
938         choices=enum_to_list(OPERATION_STATE_TYPE),
939         required=True
940     )
941     vnfInstanceId = serializers.CharField(
942         help_text="The identifier of the VNF instance affected.",
943         required=True
944     )
945     operation = serializers.ChoiceField(
946         help_text="The lifecycle management operation.",
947         choices=enum_to_list(GRANT_OPERATION),
948         required=True
949     )
950     isAutomaticInvocation = serializers.BooleanField(
951         help_text="Set to true if this VNF LCM operation occurrence has been triggered by an automated procedure inside the VNFM.",
952         required=True
953     )
954     vnfLcmOpOccId = serializers.CharField(
955         help_text="The identifier of the VNF lifecycle management operation occurrence associated to the notification.",
956         required=True
957     )
958     affectedVnfcs = AffectedVnfcSerializer(
959         help_text="Information about VNFC instances that were affected during the lifecycle operation.",
960         many=True,
961         required=False
962     )
963     affectedVirtualLinks = AffectedVirtualLinkSerializer(
964         help_text="Information about VL instances that were affected during the lifecycle operation.",
965         many=True,
966         required=False
967     )
968     affectedVirtualStorages = AffectedVirtualStorageSerializer(
969         help_text="Information about virtualised storage instances that were affected during the lifecycle operation.",
970         many=True,
971         required=False
972     )
973     changedInfo = VnfInfoModificationsSerializer(
974         help_text="Information about the changed VNF instance information, including changed VNF configurable properties.",
975         required=False,
976         allow_null=True
977     )
978     changedExtConnectivity = ExtVirtualLinkInfoSerializer(
979         help_text="Information about changed external connectivity.",
980         many=True,
981         required=False
982     )
983     error = ProblemDetailsSerializer(
984         help_text="Details of the latest error, if one has occurred during executing the LCM operation",
985         required=False,
986         allow_null=True
987     )
988     _links = LccnLinksSerializer(
989         help_text="Links to resources related to this notification.",
990         required=False,
991         allow_null=True
992     )
993
994
995 class VnfIdentifierCreationNotificationSerializer(serializers.Serializer):
996     id = serializers.CharField(
997         help_text="Identifier of this notification. \
998         If a notification is sent multiple times due to multiple subscriptions, \
999         the id attribute of all these notifications shall have the same value.",
1000         required=True,
1001         allow_null=False,
1002         allow_blank=False
1003     )
1004     notificationType = serializers.ChoiceField(
1005         help_text="Discriminator for the different notification types.",
1006         choices=enum_to_list(VNF_NOTIFICATION_TYPE),
1007         required=True
1008     )
1009     subscriptionId = serializers.CharField(
1010         help_text="Identifier of the subscription that this notification relates to.",
1011         required=False,
1012         allow_null=True,
1013         allow_blank=True
1014     )
1015     timeStamp = serializers.DateTimeField(
1016         help_text="Date-time of the generation of the notification.",
1017         required=True,
1018         allow_null=False,
1019     )
1020     vnfInstanceId = serializers.CharField(
1021         help_text="The created VNF instance identifier.",
1022         required=True,
1023         allow_null=False,
1024         allow_blank=False
1025     )
1026     _links = LccnLinksSerializer(
1027         help_text="Links to resources related to this notification.",
1028         required=True,
1029         allow_null=False
1030     )
1031
1032
1033 class VnfIdentifierDeletionNotificationSerializer(serializers.Serializer):
1034     id = serializers.CharField(
1035         help_text="Identifier of this notification. \
1036         If a notification is sent multiple times due to multiple subscriptions, \
1037         the id attribute of all these notifications shall have the same value.",
1038         required=True,
1039         allow_null=False,
1040         allow_blank=False
1041     )
1042     notificationType = serializers.ChoiceField(
1043         help_text="Discriminator for the different notification types.",
1044         choices=enum_to_list(VNF_NOTIFICATION_TYPE),
1045         required=True
1046     )
1047     subscriptionId = serializers.CharField(
1048         help_text="Identifier of the subscription that this notification relates to.",
1049         required=False,
1050         allow_null=True,
1051         allow_blank=True
1052     )
1053     timeStamp = serializers.DateTimeField(
1054         help_text="Date-time of the generation of the notification.",
1055         required=True,
1056         allow_null=False,
1057     )
1058     vnfInstanceId = serializers.CharField(
1059         help_text="The deleted VNF instance identifier.",
1060         required=True,
1061         allow_null=False,
1062         allow_blank=False
1063     )
1064     _links = LccnLinksSerializer(
1065         help_text="Links to resources related to this notification.",
1066         required=True,
1067         allow_null=False
1068     )