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