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.",
113 class VimConstraintSerializer(serializers.Serializer):
114 sameResourceGroup = serializers.BooleanField(
115 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.",
125 class LinkSerializer(serializers.Serializer):
126 href = serializers.CharField(
127 help_text="URI of the referenced resource.",
132 class GrantRequestLinksSerializer(serializers.Serializer):
133 vnfLcmOpOcc = LinkSerializer(
134 help_text="Related VNF lifecycle management operation occurrence.",
137 vnfInstance = LinkSerializer(
138 help_text="Related VNF instance.",
143 class GrantRequestSerializer(serializers.Serializer):
144 vnfInstanceId = serializers.CharField(
145 help_text="Identifier of the VNF instance which this grant request is related to.",
148 vnfLcmOpOccId = serializers.CharField(
149 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
154 vnfdId = serializers.CharField(
155 help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
160 flavourId = serializers.CharField(
161 help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
166 operation = serializers.ChoiceField(
167 help_text="The lifecycle management operation for which granting is requested.",
168 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
171 isAutomaticInvocation = serializers.BooleanField(
172 help_text="Set to true if this VNF LCM operation occurrence has been triggered by an automated procedure inside the VNFM, set to false otherwise.",
175 instantiationLevelId = serializers.CharField(
176 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.",
181 addResources = ResourceDefinitionSerializer(
182 help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
185 tempResources = ResourceDefinitionSerializer(
186 help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
189 removeResources = ResourceDefinitionSerializer(
190 help_text="Provides the definitions of resources to be removed by the LCM operation.",
193 updateResources = ResourceDefinitionSerializer(
194 help_text="Provides the definitions of resources to be modified by the LCM operation.",
197 placementConstraints = PlacementConstraintSerializer(
198 help_text="Placement constraints that the VNFM may send to the NFVO in order to influence the resource placement decision.",
201 vimConstraints = VimConstraintSerializer(
202 help_text="Used by the VNFM to require that multiple resources are managed through the same VIM connection.",
205 additionalParams = serializers.DictField(
206 help_text="Additional parameters passed by the VNFM.",
207 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
211 _links = GrantRequestLinksSerializer(
212 help_text="Links to resources related to this request.",
217 class VimConnectionInfoSerializer(serializers.Serializer):
218 id = serializers.CharField(
219 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
222 vimId = serializers.CharField(
223 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
228 vimType = serializers.CharField(
229 help_text="Discriminator for the different types of the VIM information.",
234 interfaceInfo = serializers.DictField(
235 help_text="Information about the interface or interfaces to the VIM.",
236 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
240 accessInfo = serializers.DictField(
241 help_text="Authentication credentials for accessing the VIM.",
242 child=serializers.CharField(help_text="Access Info", allow_blank=True),
246 extra = serializers.DictField(
247 help_text="VIM type specific additional information.",
248 child=serializers.CharField(help_text="Extra", allow_blank=True),
254 class ZoneInfoSerializer(serializers.Serializer):
255 id = serializers.CharField(
256 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
259 zoneId = serializers.CharField(
260 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
265 vimConnectionId = serializers.CharField(
266 help_text="Identifier of the connection to the VIM that manages the resource zone.",
271 resourceProviderId = serializers.CharField(
272 help_text="Identifies the entity responsible for the management the resource zone.",
279 class ZoneGroupInfoSerializer(serializers.Serializer):
280 zoneId = serializers.ListSerializer(
281 help_text="References of identifiers of ZoneInfo structures.",
282 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
288 class GrantInfoSerializer(serializers.Serializer):
289 resourceDefinitionId = serializers.CharField(
290 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
293 reservationId = serializers.CharField(
294 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
299 vimConnectionId = serializers.CharField(
300 help_text="Identifier of the VIM connection to be used to manage this resource.",
305 resourceProviderId = serializers.CharField(
306 help_text="Identifies the entity responsible for the management of the virtualised resource.",
311 zoneId = serializers.CharField(
312 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
317 resourceGroupId = serializers.CharField(
318 help_text="Identifier of the infrastructure resource group.",
325 class VimComputeResourceFlavourSerializer(serializers.Serializer):
326 vimConnectionId = serializers.CharField(
327 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
332 resourceProviderId = serializers.CharField(
333 help_text="Identifies the entity responsible for the management of the virtualised resource.",
338 vnfdVirtualComputeDescId = serializers.CharField(
339 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
344 vimFlavourId = serializers.CharField(
345 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
352 class VimSoftwareImageSerializer(serializers.Serializer):
353 vimConnectionId = serializers.CharField(
354 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
359 resourceProviderId = serializers.CharField(
360 help_text="Identifies the entity responsible for the management of the virtualised resource.",
365 vnfdSoftwareImageId = serializers.CharField(
366 help_text="Identifier which references the software image descriptor in the VNFD.",
371 vimSoftwareImageId = serializers.CharField(
372 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
379 class VimAssetsSerializer(serializers.Serializer):
380 computeResourceFlavours = VimComputeResourceFlavourSerializer(
381 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
384 softwareImages = VimSoftwareImageSerializer(
385 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
390 class AddressRangeSerializer(serializers.Serializer):
391 minAddress = serializers.CharField(
392 help_text="Lowest IP address belonging to the range.",
395 maxAddress = serializers.CharField(
396 help_text="Highest IP address belonging to the range.",
401 class IpAddresseSerializer(serializers.Serializer):
402 type = serializers.ChoiceField(
403 help_text="The type of the IP addresses.",
404 choices=["IPV4", "IPV6"],
407 fixedAddresses = serializers.ListSerializer(
408 help_text="Fixed addresses to assign.",
409 child=serializers.CharField(help_text="IpAddress"),
413 numDynamicAddresses = serializers.IntegerField(
414 help_text="Number of dynamic addresses to assign.",
417 addressRange = AddressRangeSerializer(
418 help_text="An IP address range to be used, e.g. in case of egress connections.",
422 subnetId = serializers.CharField(
423 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
430 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
431 macAddress = serializers.CharField(
432 help_text="MAC address.",
437 ipAddresses = IpAddresseSerializer(
438 help_text="List of IP addresses to assign to the CP instance.",
443 class CpProtocolDataSerializer(serializers.Serializer):
444 layerProtocol = serializers.ChoiceField(
445 help_text="Identifier of layer(s) and protocol(s).",
446 choices=["IP_OVER_ETHERNET"],
449 ipOverEthernet = IpOverEthernetAddressDataSerializer(
450 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
456 class VnfExtCpConfigSerializer(serializers.Serializer):
457 cpInstanceId = serializers.CharField(
458 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
463 linkPortId = serializers.CharField(
464 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
469 cpProtocolData = CpProtocolDataSerializer(
470 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
475 class VnfExtCpDataSerializer(serializers.Serializer):
476 cpdId = serializers.CharField(
477 help_text="The identifier of the CPD in the VNFD.",
480 cpConfig = VnfExtCpConfigSerializer(
481 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
486 class ExtLinkPortDataSerializer(serializers.Serializer):
487 id = serializers.CharField(
488 help_text="Identifier of this link port as provided by the entity that has created the link port.",
491 resourceHandle = serializers.CharField(
492 help_text="Reference to the virtualised resource realizing this link port.",
497 class ExtVirtualLinkDataSerializer(serializers.Serializer):
498 id = serializers.CharField(
499 help_text="The identifier of the external VL instance.",
502 vimConnectionId = serializers.CharField(
503 help_text="Identifier of the VIM connection to manage this resource.",
508 resourceProviderId = serializers.CharField(
509 help_text="Identifies the entity responsible for the management of this resource.",
514 resourceId = serializers.CharField(
515 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
518 extCps = VnfExtCpDataSerializer(
519 help_text="External CPs of the VNF to be connected to this external VL.",
522 extLinkPorts = ExtLinkPortDataSerializer(
523 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
528 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
529 id = serializers.CharField(
530 help_text="The identifier of the externally-managed internal VL instance.",
533 virtualLinkDescId = serializers.CharField(
534 help_text="The identifier of the VLD in the VNFD for this VL.",
537 vimConnectionId = serializers.CharField(
538 help_text="Identifier of the VIM connection to manage this resource.",
543 resourceProviderId = serializers.CharField(
544 help_text="Identifies the entity responsible for the management of this resource.",
549 resourceId = serializers.CharField(
550 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
555 class GrantLinksSerializer(serializers.Serializer):
556 self = LinkSerializer(
557 help_text="URI of this resource.",
560 vnfLcmOpOcc = LinkSerializer(
561 help_text="Related VNF lifecycle management operation occurrence.",
564 vnfInstance = LinkSerializer(
565 help_text="Related VNF instance.",
570 class GrantSerializer(serializers.Serializer):
571 id = serializers.CharField(
572 help_text="Identifier of the grant.",
575 vnfInstanceId = serializers.CharField(
578 vnfLcmOpOccId = serializers.CharField(
579 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
584 vimConnections = VimConnectionInfoSerializer(
585 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
588 zones = ZoneInfoSerializer(
589 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
592 zoneGroups = ZoneGroupInfoSerializer(
593 help_text="Information about groups of resource zones.",
596 computeReservationId = serializers.CharField(
597 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
602 networkReservationId = serializers.CharField(
603 help_text="Information that identifies a reservation applicable to the network resource requirements.",
608 storageReservationId = serializers.CharField(
609 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
614 addResources = GrantInfoSerializer(
615 help_text="List of resources that are approved to be added.",
618 tempResources = GrantInfoSerializer(
619 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
622 removeResources = GrantInfoSerializer(
623 help_text="List of resources that are approved to be removed.",
626 updateResources = GrantInfoSerializer(
627 help_text="List of resources that are approved to be modified.",
630 vimAssets = VimAssetsSerializer(
631 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
635 extVirtualLinks = ExtVirtualLinkDataSerializer(
636 help_text="Information about external VLs to connect the VNF to.",
639 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
640 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
643 _links = GrantLinksSerializer(
644 help_text="Links to resources related to this resource.",