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