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 GrantRequestSerializer(serializers.Serializer):
126 vnfInstanceId = serializers.CharField(
127 help_text="Identifier of the VNF instance which this grant request is related to.",
130 vnfLcmOpOccId = serializers.CharField(
131 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
136 vnfdId = serializers.CharField(
137 help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
142 flavourId = serializers.CharField(
143 help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
148 operation = serializers.ChoiceField(
149 help_text="The lifecycle management operation for which granting is requested.",
150 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
153 isAutomaticInvocation = serializers.BooleanField(
154 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.",
157 instantiationLevelId = serializers.CharField(
158 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.",
163 addResources = ResourceDefinitionSerializer(
164 help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
167 tempResources = ResourceDefinitionSerializer(
168 help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
171 removeResources = ResourceDefinitionSerializer(
172 help_text="Provides the definitions of resources to be removed by the LCM operation.",
175 updateResources = ResourceDefinitionSerializer(
176 help_text="Provides the definitions of resources to be modified by the LCM operation.",
179 placementConstraints = PlacementConstraintSerializer(
180 help_text="Placement constraints that the VNFM may send to the NFVO in order to influence the resource placement decision.",
183 vimConstraints = VimConstraintSerializer(
184 help_text="Used by the VNFM to require that multiple resources are managed through the same VIM connection.",
189 class VimConnectionInfoSerializer(serializers.Serializer):
190 id = serializers.CharField(
191 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
194 vimId = serializers.CharField(
195 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
200 vimType = serializers.CharField(
201 help_text="Discriminator for the different types of the VIM information.",
206 interfaceInfo = serializers.DictField(
207 help_text="Information about the interface or interfaces to the VIM.",
208 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
212 accessInfo = serializers.DictField(
213 help_text="Authentication credentials for accessing the VIM.",
214 child=serializers.CharField(help_text="Access Info", allow_blank=True),
218 extra = serializers.DictField(
219 help_text="VIM type specific additional information.",
220 child=serializers.CharField(help_text="Extra", allow_blank=True),
226 class ZoneInfoSerializer(serializers.Serializer):
227 id = serializers.CharField(
228 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
231 zoneId = serializers.CharField(
232 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
237 vimConnectionId = serializers.CharField(
238 help_text="Identifier of the connection to the VIM that manages the resource zone.",
243 resourceProviderId = serializers.CharField(
244 help_text="Identifies the entity responsible for the management the resource zone.",
251 class ZoneGroupInfoSerializer(serializers.Serializer):
252 zoneId = serializers.ListSerializer(
253 help_text="References of identifiers of ZoneInfo structures.",
254 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
260 class GrantInfoSerializer(serializers.Serializer):
261 resourceDefinitionId = serializers.CharField(
262 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
265 reservationId = serializers.CharField(
266 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
271 vimConnectionId = serializers.CharField(
272 help_text="Identifier of the VIM connection to be used to manage this resource.",
277 resourceProviderId = serializers.CharField(
278 help_text="Identifies the entity responsible for the management of the virtualised resource.",
283 zoneId = serializers.CharField(
284 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
289 resourceGroupId = serializers.CharField(
290 help_text="Identifier of the infrastructure resource group.",
297 class VimComputeResourceFlavourSerializer(serializers.Serializer):
298 vimConnectionId = serializers.CharField(
299 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
304 resourceProviderId = serializers.CharField(
305 help_text="Identifies the entity responsible for the management of the virtualised resource.",
310 vnfdVirtualComputeDescId = serializers.CharField(
311 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
316 vimFlavourId = serializers.CharField(
317 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
324 class VimSoftwareImageSerializer(serializers.Serializer):
325 vimConnectionId = serializers.CharField(
326 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
331 resourceProviderId = serializers.CharField(
332 help_text="Identifies the entity responsible for the management of the virtualised resource.",
337 vnfdSoftwareImageId = serializers.CharField(
338 help_text="Identifier which references the software image descriptor in the VNFD.",
343 vimSoftwareImageId = serializers.CharField(
344 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
351 class VimAssetsSerializer(serializers.Serializer):
352 computeResourceFlavours = VimComputeResourceFlavourSerializer(
353 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
356 softwareImages = VimSoftwareImageSerializer(
357 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
362 class AddressRangeSerializer(serializers.Serializer):
363 minAddress = serializers.CharField(
364 help_text="Lowest IP address belonging to the range.",
367 maxAddress = serializers.CharField(
368 help_text="Highest IP address belonging to the range.",
373 class IpAddresseSerializer(serializers.Serializer):
374 type = serializers.ChoiceField(
375 help_text="The type of the IP addresses.",
376 choices=["IPV4", "IPV6"],
379 fixedAddresses = serializers.ListSerializer(
380 help_text="Fixed addresses to assign.",
381 child=serializers.CharField(help_text="IpAddress"),
385 numDynamicAddresses = serializers.IntegerField(
386 help_text="Number of dynamic addresses to assign.",
389 addressRange = AddressRangeSerializer(
390 help_text="An IP address range to be used, e.g. in case of egress connections.",
394 subnetId = serializers.CharField(
395 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
402 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
403 macAddress = serializers.CharField(
404 help_text="MAC address.",
409 ipAddresses = IpAddresseSerializer(
410 help_text="List of IP addresses to assign to the CP instance.",
415 class CpProtocolDataSerializer(serializers.Serializer):
416 layerProtocol = serializers.ChoiceField(
417 help_text="Identifier of layer(s) and protocol(s).",
418 choices=["IP_OVER_ETHERNET"],
421 ipOverEthernet = IpOverEthernetAddressDataSerializer(
422 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
428 class VnfExtCpConfigSerializer(serializers.Serializer):
429 cpInstanceId = serializers.CharField(
430 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
435 linkPortId = serializers.CharField(
436 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
441 cpProtocolData = CpProtocolDataSerializer(
442 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
447 class VnfExtCpDataSerializer(serializers.Serializer):
448 cpdId = serializers.CharField(
449 help_text="The identifier of the CPD in the VNFD.",
452 cpConfig = VnfExtCpConfigSerializer(
453 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
458 class ExtLinkPortDataSerializer(serializers.Serializer):
459 id = serializers.CharField(
460 help_text="Identifier of this link port as provided by the entity that has created the link port.",
463 resourceHandle = serializers.CharField(
464 help_text="Reference to the virtualised resource realizing this link port.",
469 class ExtVirtualLinkDataSerializer(serializers.Serializer):
470 id = serializers.CharField(
471 help_text="The identifier of the external VL instance.",
474 vimConnectionId = serializers.CharField(
475 help_text="Identifier of the VIM connection to manage this resource.",
480 resourceProviderId = serializers.CharField(
481 help_text="Identifies the entity responsible for the management of this resource.",
486 resourceId = serializers.CharField(
487 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
490 extCps = VnfExtCpDataSerializer(
491 help_text="External CPs of the VNF to be connected to this external VL.",
494 extLinkPorts = ExtLinkPortDataSerializer(
495 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
500 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
501 id = serializers.CharField(
502 help_text="The identifier of the externally-managed internal VL instance.",
505 virtualLinkDescId = serializers.CharField(
506 help_text="The identifier of the VLD in the VNFD for this VL.",
509 vimConnectionId = serializers.CharField(
510 help_text="Identifier of the VIM connection to manage this resource.",
515 resourceProviderId = serializers.CharField(
516 help_text="Identifies the entity responsible for the management of this resource.",
521 resourceId = serializers.CharField(
522 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
527 class LinkSerializer(serializers.Serializer):
528 href = serializers.CharField(
529 help_text="URI of the referenced resource.",
534 class GrantLinksSerializer(serializers.Serializer):
535 self = LinkSerializer(
536 help_text="URI of this resource.",
539 vnfLcmOpOcc = LinkSerializer(
540 help_text="Related VNF lifecycle management operation occurrence.",
543 vnfInstance = LinkSerializer(
544 help_text="Related VNF instance.",
549 class GrantSerializer(serializers.Serializer):
550 id = serializers.CharField(
551 help_text="Identifier of the grant.",
554 vnfInstanceId = serializers.CharField(
557 vnfLcmOpOccId = serializers.CharField(
558 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
563 vimConnections = VimConnectionInfoSerializer(
564 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
567 zones = ZoneInfoSerializer(
568 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
571 zoneGroups = ZoneGroupInfoSerializer(
572 help_text="Information about groups of resource zones.",
575 computeReservationId = serializers.CharField(
576 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
581 networkReservationId = serializers.CharField(
582 help_text="Information that identifies a reservation applicable to the network resource requirements.",
587 storageReservationId = serializers.CharField(
588 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
593 addResources = GrantInfoSerializer(
594 help_text="List of resources that are approved to be added.",
597 tempResources = GrantInfoSerializer(
598 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
601 removeResources = GrantInfoSerializer(
602 help_text="List of resources that are approved to be removed.",
605 updateResources = GrantInfoSerializer(
606 help_text="List of resources that are approved to be modified.",
609 vimAssets = VimAssetsSerializer(
610 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
614 extVirtualLinks = ExtVirtualLinkDataSerializer(
615 help_text="Information about external VLs to connect the VNF to.",
618 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
619 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
622 _links = GrantLinksSerializer(
623 help_text="Links to resources related to this resource.",