1 # Copyright 2018 ZTE Corporation.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from rest_framework import serializers
18 class ResourceHandleSerializer(serializers.Serializer):
19 vimConnectionId = serializers.CharField(
20 help_text="Identifier of the VIM connection to manage the resource.",
25 resourceProviderId = serializers.CharField(
26 help_text="Identifier of the entity responsible for the management of the resource.",
31 resourceId = serializers.CharField(
32 help_text="Identifier of the resource in the scope of the VIM or the resource provider.",
35 vimLevelResourceType = serializers.CharField(
36 help_text="Type of the resource in the scope of the VIM or the resource provider.",
43 class ResourceDefinitionSerializer(serializers.Serializer):
44 id = serializers.CharField(
45 help_text="Identifier of this ResourceDefinition, unique at least within the scope of the GrantRequest.",
48 type = serializers.ChoiceField(
49 help_text="Type of the resource definition referenced.",
50 choices=["COMPUTE", "VL", "STORAGE", "LINKPORT"],
53 vduId = serializers.CharField(
54 help_text="Reference to the related VDU in the VNFD applicable to this resource.",
59 resourceTemplateId = serializers.CharField(
60 help_text="Reference to a resource template(such as VnfVirtualLinkDesc) in the VNFD.",
65 resource = ResourceHandleSerializer(
66 help_text="Resource information for an existing resource.",
72 class ConstraintResourceRefSerializer(serializers.Serializer):
73 idType = serializers.ChoiceField(
74 help_text="The type of the identifier.",
75 choices=["RES_MGMT", "GRANT"],
78 resourceId = serializers.CharField(
79 help_text="An actual resource-management-level identifier(idType=RES_MGMT), or an identifier that references a ResourceDefinition(idType=GRANT).",
82 vimConnectionId = serializers.CharField(
88 resourceProviderId = serializers.CharField(
89 help_text="Identifier of the resource provider. It shall only be present when idType = RES_MGMT.",
96 class PlacementConstraintSerializer(serializers.Serializer):
97 affinityOrAntiAffinity = serializers.ChoiceField(
98 help_text="The type of the constraint.",
99 choices=["AFFINITY", "ANTI_AFFINITY"],
102 scope = serializers.ChoiceField(
103 help_text="The scope of the placement constraint indicating the category of the place where the constraint applies.",
104 choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"],
107 resource = ConstraintResourceRefSerializer(
108 help_text="References to resources in the constraint rule.",
114 class VimConstraintSerializer(serializers.Serializer):
115 sameResourceGroup = serializers.BooleanField(
116 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 resource = ConstraintResourceRefSerializer(
120 help_text="References to resources in the constraint rule.",
126 class LinkSerializer(serializers.Serializer):
127 href = serializers.CharField(
128 help_text="URI of the referenced resource.",
133 class GrantRequestLinksSerializer(serializers.Serializer):
134 vnfLcmOpOcc = LinkSerializer(
135 help_text="Related VNF lifecycle management operation occurrence.",
138 vnfInstance = LinkSerializer(
139 help_text="Related VNF instance.",
144 class GrantRequestSerializer(serializers.Serializer):
145 vnfInstanceId = serializers.CharField(
146 help_text="Identifier of the VNF instance which this grant request is related to.",
149 vnfLcmOpOccId = serializers.CharField(
150 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
155 vnfdId = serializers.CharField(
156 help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
161 flavourId = serializers.CharField(
162 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 operation = serializers.ChoiceField(
168 help_text="The lifecycle management operation for which granting is requested.",
169 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
172 isAutomaticInvocation = serializers.BooleanField(
173 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 instantiationLevelId = serializers.CharField(
177 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 addResources = ResourceDefinitionSerializer(
183 help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
187 tempResources = ResourceDefinitionSerializer(
188 help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
192 removeResources = ResourceDefinitionSerializer(
193 help_text="Provides the definitions of resources to be removed by the LCM operation.",
197 updateResources = ResourceDefinitionSerializer(
198 help_text="Provides the definitions of resources to be modified by the LCM operation.",
202 placementConstraints = PlacementConstraintSerializer(
203 help_text="Placement constraints that the VNFM may send to the NFVO in order to influence the resource placement decision.",
207 vimConstraints = VimConstraintSerializer(
208 help_text="Used by the VNFM to require that multiple resources are managed through the same VIM connection.",
212 additionalParams = serializers.DictField(
213 help_text="Additional parameters passed by the VNFM.",
214 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
218 _links = GrantRequestLinksSerializer(
219 help_text="Links to resources related to this request.",
224 class VimConnectionInfoSerializer(serializers.Serializer):
225 id = serializers.CharField(
226 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
229 vimId = serializers.CharField(
230 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
235 vimType = serializers.CharField(
236 help_text="Discriminator for the different types of the VIM information.",
241 interfaceInfo = serializers.DictField(
242 help_text="Information about the interface or interfaces to the VIM.",
243 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
247 accessInfo = serializers.DictField(
248 help_text="Authentication credentials for accessing the VIM.",
249 child=serializers.CharField(help_text="Access Info", allow_blank=True),
253 extra = serializers.DictField(
254 help_text="VIM type specific additional information.",
255 child=serializers.CharField(help_text="Extra", allow_blank=True),
261 class ZoneInfoSerializer(serializers.Serializer):
262 id = serializers.CharField(
263 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
266 zoneId = serializers.CharField(
267 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
272 vimConnectionId = serializers.CharField(
273 help_text="Identifier of the connection to the VIM that manages the resource zone.",
278 resourceProviderId = serializers.CharField(
279 help_text="Identifies the entity responsible for the management the resource zone.",
286 class ZoneGroupInfoSerializer(serializers.Serializer):
287 zoneId = serializers.ListSerializer(
288 help_text="References of identifiers of ZoneInfo structures.",
289 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
295 class GrantInfoSerializer(serializers.Serializer):
296 resourceDefinitionId = serializers.CharField(
297 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
300 reservationId = serializers.CharField(
301 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
306 vimConnectionId = serializers.CharField(
307 help_text="Identifier of the VIM connection to be used to manage this resource.",
312 resourceProviderId = serializers.CharField(
313 help_text="Identifies the entity responsible for the management of the virtualised resource.",
318 zoneId = serializers.CharField(
319 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
324 resourceGroupId = serializers.CharField(
325 help_text="Identifier of the infrastructure resource group.",
332 class VimComputeResourceFlavourSerializer(serializers.Serializer):
333 vimConnectionId = serializers.CharField(
334 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
339 resourceProviderId = serializers.CharField(
340 help_text="Identifies the entity responsible for the management of the virtualised resource.",
345 vnfdVirtualComputeDescId = serializers.CharField(
346 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
351 vimFlavourId = serializers.CharField(
352 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
359 class VimSoftwareImageSerializer(serializers.Serializer):
360 vimConnectionId = serializers.CharField(
361 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
366 resourceProviderId = serializers.CharField(
367 help_text="Identifies the entity responsible for the management of the virtualised resource.",
372 vnfdSoftwareImageId = serializers.CharField(
373 help_text="Identifier which references the software image descriptor in the VNFD.",
378 vimSoftwareImageId = serializers.CharField(
379 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
386 class VimAssetsSerializer(serializers.Serializer):
387 computeResourceFlavours = VimComputeResourceFlavourSerializer(
388 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
392 softwareImages = VimSoftwareImageSerializer(
393 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
399 class AddressRangeSerializer(serializers.Serializer):
400 minAddress = serializers.CharField(
401 help_text="Lowest IP address belonging to the range.",
404 maxAddress = serializers.CharField(
405 help_text="Highest IP address belonging to the range.",
410 class IpAddresseSerializer(serializers.Serializer):
411 type = serializers.ChoiceField(
412 help_text="The type of the IP addresses.",
413 choices=["IPV4", "IPV6"],
416 fixedAddresses = serializers.ListSerializer(
417 help_text="Fixed addresses to assign.",
418 child=serializers.CharField(help_text="IpAddress"),
422 numDynamicAddresses = serializers.IntegerField(
423 help_text="Number of dynamic addresses to assign.",
426 addressRange = AddressRangeSerializer(
427 help_text="An IP address range to be used, e.g. in case of egress connections.",
431 subnetId = serializers.CharField(
432 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
439 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
440 macAddress = serializers.CharField(
441 help_text="MAC address.",
446 ipAddresses = IpAddresseSerializer(
447 help_text="List of IP addresses to assign to the CP instance.",
453 class CpProtocolDataSerializer(serializers.Serializer):
454 layerProtocol = serializers.ChoiceField(
455 help_text="Identifier of layer(s) and protocol(s).",
456 choices=["IP_OVER_ETHERNET"],
459 ipOverEthernet = IpOverEthernetAddressDataSerializer(
460 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
466 class VnfExtCpConfigSerializer(serializers.Serializer):
467 cpInstanceId = serializers.CharField(
468 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
473 linkPortId = serializers.CharField(
474 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
479 cpProtocolData = CpProtocolDataSerializer(
480 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
486 class VnfExtCpDataSerializer(serializers.Serializer):
487 cpdId = serializers.CharField(
488 help_text="The identifier of the CPD in the VNFD.",
491 cpConfig = VnfExtCpConfigSerializer(
492 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
498 class ExtLinkPortDataSerializer(serializers.Serializer):
499 id = serializers.CharField(
500 help_text="Identifier of this link port as provided by the entity that has created the link port.",
503 resourceHandle = serializers.CharField(
504 help_text="Reference to the virtualised resource realizing this link port.",
509 class ExtVirtualLinkDataSerializer(serializers.Serializer):
510 id = serializers.CharField(
511 help_text="The identifier of the external VL instance.",
514 vimConnectionId = serializers.CharField(
515 help_text="Identifier of the VIM connection to manage this resource.",
520 resourceProviderId = serializers.CharField(
521 help_text="Identifies the entity responsible for the management of this resource.",
526 resourceId = serializers.CharField(
527 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
530 extCps = VnfExtCpDataSerializer(
531 help_text="External CPs of the VNF to be connected to this external VL.",
535 extLinkPorts = ExtLinkPortDataSerializer(
536 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
542 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
543 id = serializers.CharField(
544 help_text="The identifier of the externally-managed internal VL instance.",
547 virtualLinkDescId = serializers.CharField(
548 help_text="The identifier of the VLD in the VNFD for this VL.",
551 vimConnectionId = serializers.CharField(
552 help_text="Identifier of the VIM connection to manage this resource.",
557 resourceProviderId = serializers.CharField(
558 help_text="Identifies the entity responsible for the management of this resource.",
563 resourceId = serializers.CharField(
564 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
569 class GrantLinksSerializer(serializers.Serializer):
570 self = LinkSerializer(
571 help_text="URI of this resource.",
574 vnfLcmOpOcc = LinkSerializer(
575 help_text="Related VNF lifecycle management operation occurrence.",
578 vnfInstance = LinkSerializer(
579 help_text="Related VNF instance.",
584 class GrantSerializer(serializers.Serializer):
585 id = serializers.CharField(
586 help_text="Identifier of the grant.",
589 vnfInstanceId = serializers.CharField(
590 help_text="Identifier of the related VNF instance.",
593 vnfLcmOpOccId = serializers.CharField(
594 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
599 vimConnections = VimConnectionInfoSerializer(
600 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
604 zones = ZoneInfoSerializer(
605 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
609 zoneGroups = ZoneGroupInfoSerializer(
610 help_text="Information about groups of resource zones.",
614 computeReservationId = serializers.CharField(
615 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
620 networkReservationId = serializers.CharField(
621 help_text="Information that identifies a reservation applicable to the network resource requirements.",
626 storageReservationId = serializers.CharField(
627 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
632 addResources = GrantInfoSerializer(
633 help_text="List of resources that are approved to be added.",
637 tempResources = GrantInfoSerializer(
638 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
642 removeResources = GrantInfoSerializer(
643 help_text="List of resources that are approved to be removed.",
647 updateResources = GrantInfoSerializer(
648 help_text="List of resources that are approved to be modified.",
652 vimAssets = VimAssetsSerializer(
653 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
657 extVirtualLinks = ExtVirtualLinkDataSerializer(
658 help_text="Information about external VLs to connect the VNF to.",
662 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
663 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
667 _links = GrantLinksSerializer(
668 help_text="Links to resources related to this resource.",
673 class AffectedVnfcSerializer(serializers.Serializer):
674 id = serializers.CharField(
675 help_text="Identifier of the Vnfc instance.",
678 vduId = serializers.CharField(
679 help_text="Identifier of the related VDU in the VNFD.",
682 changeType = serializers.ChoiceField(
683 help_text="Signals the type of change.",
684 choices=["ADDED", "REMOVED", "MODIFIED", "TEMPORARY"],
687 computeResource = ResourceHandleSerializer(
688 help_text="Reference to the VirtualCompute resource.",
691 metadata = serializers.DictField(
692 help_text="Metadata about this resource.",
693 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
697 affectedVnfcCpIds = serializers.ListSerializer(
698 help_text="Identifiers of CP(s) of the VNFC instance that were affected by the change.",
699 child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
703 addedStorageResourceIds = serializers.ListSerializer(
704 help_text="References to VirtualStorage resources that have been added.",
705 child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
709 removedStorageResourceIds = serializers.ListSerializer(
710 help_text="References to VirtualStorage resources that have been removed.",
711 child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
717 class VnfLcmOperationOccurrenceNotificationSerializer(serializers.Serializer):
718 id = serializers.CharField(
719 help_text="Identifier of this notification.",
722 notificationType = serializers.CharField(
723 help_text="Discriminator for the different notification types.",
726 subscriptionId = serializers.CharField(
727 help_text="Identifier of the subscription that this notification relates to.",
730 timeStamp = serializers.CharField(
731 help_text="Date-time of the generation of the notification.",
734 notificationStatus = serializers.ChoiceField(
735 help_text="Indicates whether this notification reports about the start of a lifecycle operation or the result of a lifecycle operation.",
736 choices=["START", "RESULT"],
739 operationState = serializers.ChoiceField(
740 help_text="The state of the VNF LCM operation occurrence.",
741 choices=["STARTING", "PROCESSING", "COMPLETED", "FAILED_TEMP", "FAILED", "ROLLING_BACK", "ROLLED_BACK"],
744 vnfInstanceId = serializers.CharField(
745 help_text="The identifier of the VNF instance affected.",
748 operation = serializers.ChoiceField(
749 help_text="The lifecycle management operation.",
750 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
753 isAutomaticInvocation = serializers.BooleanField(
754 help_text="Set to true if this VNF LCM operation occurrence has been triggered by an automated procedure inside the VNFM.",
757 vnfLcmOpOccId = serializers.CharField(
758 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the notification.",