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