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 GrantRequestSerializer(serializers.Serializer):
114 vnfInstanceId = serializers.CharField(
115 help_text="Identifier of the VNF instance which this grant request is related to.",
118 vnfLcmOpOccId = serializers.CharField(
119 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
124 vnfdId = serializers.CharField(
125 help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
130 flavourId = serializers.CharField(
131 help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
136 operation = serializers.ChoiceField(
137 help_text="The lifecycle management operation for which granting is requested.",
138 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
141 isAutomaticInvocation = serializers.BooleanField(
142 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.",
145 instantiationLevelId = serializers.CharField(
146 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.",
151 addResources = ResourceDefinitionSerializer(
152 help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
155 tempResources = ResourceDefinitionSerializer(
156 help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
159 removeResources = ResourceDefinitionSerializer(
160 help_text="Provides the definitions of resources to be removed by the LCM operation.",
163 updateResources = ResourceDefinitionSerializer(
164 help_text="Provides the definitions of resources to be modified by the LCM operation.",
167 placementConstraints = PlacementConstraintSerializer(
168 help_text="Placement constraints that the VNFM may send to the NFVO in order to influence the resource placement decision.",
173 class VimConnectionInfoSerializer(serializers.Serializer):
174 id = serializers.CharField(
175 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
178 vimId = serializers.CharField(
179 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
184 vimType = serializers.CharField(
185 help_text="Discriminator for the different types of the VIM information.",
190 interfaceInfo = serializers.DictField(
191 help_text="Information about the interface or interfaces to the VIM.",
192 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
196 accessInfo = serializers.DictField(
197 help_text="Authentication credentials for accessing the VIM.",
198 child=serializers.CharField(help_text="Access Info", allow_blank=True),
202 extra = serializers.DictField(
203 help_text="VIM type specific additional information.",
204 child=serializers.CharField(help_text="Extra", allow_blank=True),
210 class ZoneInfoSerializer(serializers.Serializer):
211 id = serializers.CharField(
212 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
215 zoneId = serializers.CharField(
216 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
221 vimConnectionId = serializers.CharField(
222 help_text="Identifier of the connection to the VIM that manages the resource zone.",
227 resourceProviderId = serializers.CharField(
228 help_text="Identifies the entity responsible for the management the resource zone.",
235 class ZoneGroupInfoSerializer(serializers.Serializer):
236 zoneId = serializers.ListSerializer(
237 help_text="References of identifiers of ZoneInfo structures.",
238 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
244 class GrantInfoSerializer(serializers.Serializer):
245 resourceDefinitionId = serializers.CharField(
246 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
249 reservationId = serializers.CharField(
250 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
255 vimConnectionId = serializers.CharField(
256 help_text="Identifier of the VIM connection to be used to manage this resource.",
261 resourceProviderId = serializers.CharField(
262 help_text="Identifies the entity responsible for the management of the virtualised resource.",
267 zoneId = serializers.CharField(
268 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
273 resourceGroupId = serializers.CharField(
274 help_text="Identifier of the infrastructure resource group.",
281 class VimComputeResourceFlavourSerializer(serializers.Serializer):
282 vimConnectionId = serializers.CharField(
283 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
288 resourceProviderId = serializers.CharField(
289 help_text="Identifies the entity responsible for the management of the virtualised resource.",
294 vnfdVirtualComputeDescId = serializers.CharField(
295 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
300 vimFlavourId = serializers.CharField(
301 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
308 class VimSoftwareImageSerializer(serializers.Serializer):
309 vimConnectionId = serializers.CharField(
310 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
315 resourceProviderId = serializers.CharField(
316 help_text="Identifies the entity responsible for the management of the virtualised resource.",
321 vnfdSoftwareImageId = serializers.CharField(
322 help_text="Identifier which references the software image descriptor in the VNFD.",
327 vimSoftwareImageId = serializers.CharField(
328 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
335 class VimAssetsSerializer(serializers.Serializer):
336 computeResourceFlavours = VimComputeResourceFlavourSerializer(
337 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
340 softwareImages = VimSoftwareImageSerializer(
341 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
346 class AddressRangeSerializer(serializers.Serializer):
347 minAddress = serializers.CharField(
348 help_text="Lowest IP address belonging to the range.",
351 maxAddress = serializers.CharField(
352 help_text="Highest IP address belonging to the range.",
357 class IpAddresseSerializer(serializers.Serializer):
358 type = serializers.ChoiceField(
359 help_text="The type of the IP addresses.",
360 choices=["IPV4", "IPV6"],
363 fixedAddresses = serializers.ListSerializer(
364 help_text="Fixed addresses to assign.",
365 child=serializers.CharField(help_text="IpAddress"),
369 numDynamicAddresses = serializers.IntegerField(
370 help_text="Number of dynamic addresses to assign.",
373 addressRange = AddressRangeSerializer(
374 help_text="An IP address range to be used, e.g. in case of egress connections.",
378 subnetId = serializers.CharField(
379 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
386 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
387 macAddress = serializers.CharField(
388 help_text="MAC address.",
393 ipAddresses = IpAddresseSerializer(
394 help_text="List of IP addresses to assign to the CP instance.",
399 class CpProtocolDataSerializer(serializers.Serializer):
400 layerProtocol = serializers.ChoiceField(
401 help_text="Identifier of layer(s) and protocol(s).",
402 choices=["IP_OVER_ETHERNET"],
405 ipOverEthernet = IpOverEthernetAddressDataSerializer(
406 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
412 class VnfExtCpConfigSerializer(serializers.Serializer):
413 cpInstanceId = serializers.CharField(
414 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
419 linkPortId = serializers.CharField(
420 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
425 cpProtocolData = CpProtocolDataSerializer(
426 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
431 class VnfExtCpDataSerializer(serializers.Serializer):
432 cpdId = serializers.CharField(
433 help_text="The identifier of the CPD in the VNFD.",
436 cpConfig = VnfExtCpConfigSerializer(
437 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
442 class ExtLinkPortDataSerializer(serializers.Serializer):
443 id = serializers.CharField(
444 help_text="Identifier of this link port as provided by the entity that has created the link port.",
447 resourceHandle = serializers.CharField(
448 help_text="Reference to the virtualised resource realizing this link port.",
453 class ExtVirtualLinkDataSerializer(serializers.Serializer):
454 id = serializers.CharField(
455 help_text="The identifier of the external VL instance.",
458 vimConnectionId = serializers.CharField(
459 help_text="Identifier of the VIM connection to manage this resource.",
464 resourceProviderId = serializers.CharField(
465 help_text="Identifies the entity responsible for the management of this resource.",
470 resourceId = serializers.CharField(
471 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
474 extCps = VnfExtCpDataSerializer(
475 help_text="External CPs of the VNF to be connected to this external VL.",
478 extLinkPorts = ExtLinkPortDataSerializer(
479 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
484 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
485 id = serializers.CharField(
486 help_text="The identifier of the externally-managed internal VL instance.",
489 virtualLinkDescId = serializers.CharField(
490 help_text="The identifier of the VLD in the VNFD for this VL.",
493 vimConnectionId = serializers.CharField(
494 help_text="Identifier of the VIM connection to manage this resource.",
499 resourceProviderId = serializers.CharField(
500 help_text="Identifies the entity responsible for the management of this resource.",
505 resourceId = serializers.CharField(
506 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
511 class LinkSerializer(serializers.Serializer):
512 href = serializers.CharField(
513 help_text="URI of the referenced resource.",
518 class GrantLinksSerializer(serializers.Serializer):
519 self = LinkSerializer(
520 help_text="URI of this resource.",
523 vnfLcmOpOcc = LinkSerializer(
524 help_text="Related VNF lifecycle management operation occurrence.",
527 vnfInstance = LinkSerializer(
528 help_text="Related VNF instance.",
533 class GrantSerializer(serializers.Serializer):
534 id = serializers.CharField(
535 help_text="Identifier of the grant.",
538 vnfInstanceId = serializers.CharField(
541 vnfLcmOpOccId = serializers.CharField(
542 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
547 vimConnections = VimConnectionInfoSerializer(
548 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
551 zones = ZoneInfoSerializer(
552 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
555 zoneGroups = ZoneGroupInfoSerializer(
556 help_text="Information about groups of resource zones.",
559 computeReservationId = serializers.CharField(
560 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
565 networkReservationId = serializers.CharField(
566 help_text="Information that identifies a reservation applicable to the network resource requirements.",
571 storageReservationId = serializers.CharField(
572 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
577 addResources = GrantInfoSerializer(
578 help_text="List of resources that are approved to be added.",
581 tempResources = GrantInfoSerializer(
582 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
585 removeResources = GrantInfoSerializer(
586 help_text="List of resources that are approved to be removed.",
589 updateResources = GrantInfoSerializer(
590 help_text="List of resources that are approved to be modified.",
593 vimAssets = VimAssetsSerializer(
594 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
598 extVirtualLinks = ExtVirtualLinkDataSerializer(
599 help_text="Information about external VLs to connect the VNF to.",
602 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
603 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
606 _links = GrantLinksSerializer(
607 help_text="Links to resources related to this resource.",