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