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 GrantRequestSerializer(serializers.Serializer):
73 vnfInstanceId = serializers.CharField(
74 help_text="Identifier of the VNF instance which this grant request is related to.",
77 vnfLcmOpOccId = serializers.CharField(
78 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
83 vnfdId = serializers.CharField(
84 help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
89 flavourId = serializers.CharField(
90 help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
95 operation = serializers.ChoiceField(
96 help_text="The lifecycle management operation for which granting is requested.",
97 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
100 isAutomaticInvocation = serializers.BooleanField(
101 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.",
104 instantiationLevelId = serializers.CharField(
105 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.",
110 addResources = ResourceDefinitionSerializer(
111 help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
114 tempResources = ResourceDefinitionSerializer(
115 help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
118 removeResources = ResourceDefinitionSerializer(
119 help_text="Provides the definitions of resources to be removed by the LCM operation.",
122 updateResources = ResourceDefinitionSerializer(
123 help_text="Provides the definitions of resources to be modified by the LCM operation.",
128 class VimConnectionInfoSerializer(serializers.Serializer):
129 id = serializers.CharField(
130 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
133 vimId = serializers.CharField(
134 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
139 vimType = serializers.CharField(
140 help_text="Discriminator for the different types of the VIM information.",
145 interfaceInfo = serializers.DictField(
146 help_text="Information about the interface or interfaces to the VIM.",
147 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
151 accessInfo = serializers.DictField(
152 help_text="Authentication credentials for accessing the VIM.",
153 child=serializers.CharField(help_text="Access Info", allow_blank=True),
157 extra = serializers.DictField(
158 help_text="VIM type specific additional information.",
159 child=serializers.CharField(help_text="Extra", allow_blank=True),
165 class ZoneInfoSerializer(serializers.Serializer):
166 id = serializers.CharField(
167 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
170 zoneId = serializers.CharField(
171 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
176 vimConnectionId = serializers.CharField(
177 help_text="Identifier of the connection to the VIM that manages the resource zone.",
182 resourceProviderId = serializers.CharField(
183 help_text="Identifies the entity responsible for the management the resource zone.",
190 class ZoneGroupInfoSerializer(serializers.Serializer):
191 zoneId = serializers.ListSerializer(
192 help_text="References of identifiers of ZoneInfo structures.",
193 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
199 class GrantInfoSerializer(serializers.Serializer):
200 resourceDefinitionId = serializers.CharField(
201 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
204 reservationId = serializers.CharField(
205 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
210 vimConnectionId = serializers.CharField(
211 help_text="Identifier of the VIM connection to be used to manage this resource.",
216 resourceProviderId = serializers.CharField(
217 help_text="Identifies the entity responsible for the management of the virtualised resource.",
222 zoneId = serializers.CharField(
223 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
228 resourceGroupId = serializers.CharField(
229 help_text="Identifier of the infrastructure resource group.",
236 class VimComputeResourceFlavourSerializer(serializers.Serializer):
237 vimConnectionId = serializers.CharField(
238 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
243 resourceProviderId = serializers.CharField(
244 help_text="Identifies the entity responsible for the management of the virtualised resource.",
249 vnfdVirtualComputeDescId = serializers.CharField(
250 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
255 vimFlavourId = serializers.CharField(
256 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
263 class VimSoftwareImageSerializer(serializers.Serializer):
264 vimConnectionId = serializers.CharField(
265 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
270 resourceProviderId = serializers.CharField(
271 help_text="Identifies the entity responsible for the management of the virtualised resource.",
276 vnfdSoftwareImageId = serializers.CharField(
277 help_text="Identifier which references the software image descriptor in the VNFD.",
282 vimSoftwareImageId = serializers.CharField(
283 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
290 class VimAssetsSerializer(serializers.Serializer):
291 computeResourceFlavours = VimComputeResourceFlavourSerializer(
292 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
295 softwareImages = VimSoftwareImageSerializer(
296 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
301 class AddressRangeSerializer(serializers.Serializer):
302 minAddress = serializers.CharField(
303 help_text="Lowest IP address belonging to the range.",
306 maxAddress = serializers.CharField(
307 help_text="Highest IP address belonging to the range.",
312 class IpAddresseSerializer(serializers.Serializer):
313 type = serializers.ChoiceField(
314 help_text="The type of the IP addresses.",
315 choices=["IPV4", "IPV6"],
318 fixedAddresses = serializers.ListSerializer(
319 help_text="Fixed addresses to assign.",
320 child=serializers.CharField(help_text="IpAddress"),
324 numDynamicAddresses = serializers.IntegerField(
325 help_text="Number of dynamic addresses to assign.",
328 addressRange = AddressRangeSerializer(
329 help_text="An IP address range to be used, e.g. in case of egress connections.",
333 subnetId = serializers.CharField(
334 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
341 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
342 macAddress = serializers.CharField(
343 help_text="MAC address.",
348 ipAddresses = IpAddresseSerializer(
349 help_text="List of IP addresses to assign to the CP instance.",
354 class CpProtocolDataSerializer(serializers.Serializer):
355 layerProtocol = serializers.ChoiceField(
356 help_text="Identifier of layer(s) and protocol(s).",
357 choices=["IP_OVER_ETHERNET"],
360 ipOverEthernet = IpOverEthernetAddressDataSerializer(
361 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
367 class VnfExtCpConfigSerializer(serializers.Serializer):
368 cpInstanceId = serializers.CharField(
369 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
374 linkPortId = serializers.CharField(
375 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
380 cpProtocolData = CpProtocolDataSerializer(
381 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
386 class VnfExtCpDataSerializer(serializers.Serializer):
387 cpdId = serializers.CharField(
388 help_text="The identifier of the CPD in the VNFD.",
391 cpConfig = VnfExtCpConfigSerializer(
392 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
397 class ExtLinkPortDataSerializer(serializers.Serializer):
398 id = serializers.CharField(
399 help_text="Identifier of this link port as provided by the entity that has created the link port.",
402 resourceHandle = serializers.CharField(
403 help_text="Reference to the virtualised resource realizing this link port.",
408 class ExtVirtualLinkDataSerializer(serializers.Serializer):
409 id = serializers.CharField(
410 help_text="The identifier of the external VL instance.",
413 vimConnectionId = serializers.CharField(
414 help_text="Identifier of the VIM connection to manage this resource.",
419 resourceProviderId = serializers.CharField(
420 help_text="Identifies the entity responsible for the management of this resource.",
425 resourceId = serializers.CharField(
426 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
429 extCps = VnfExtCpDataSerializer(
430 help_text="External CPs of the VNF to be connected to this external VL.",
433 extLinkPorts = ExtLinkPortDataSerializer(
434 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
439 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
440 id = serializers.CharField(
441 help_text="The identifier of the externally-managed internal VL instance.",
444 virtualLinkDescId = serializers.CharField(
445 help_text="The identifier of the VLD in the VNFD for this VL.",
448 vimConnectionId = serializers.CharField(
449 help_text="Identifier of the VIM connection to manage this resource.",
454 resourceProviderId = serializers.CharField(
455 help_text="Identifies the entity responsible for the management of this resource.",
460 resourceId = serializers.CharField(
461 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
466 class LinkSerializer(serializers.Serializer):
467 href = serializers.CharField(
468 help_text="URI of the referenced resource.",
473 class GrantLinksSerializer(serializers.Serializer):
474 self = LinkSerializer(
475 help_text="URI of this resource.",
478 vnfLcmOpOcc = LinkSerializer(
479 help_text="Related VNF lifecycle management operation occurrence.",
482 vnfInstance = LinkSerializer(
483 help_text="Related VNF instance.",
488 class GrantSerializer(serializers.Serializer):
489 id = serializers.CharField(
490 help_text="Identifier of the grant.",
493 vnfInstanceId = serializers.CharField(
496 vnfLcmOpOccId = serializers.CharField(
497 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
502 vimConnections = VimConnectionInfoSerializer(
503 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
506 zones = ZoneInfoSerializer(
507 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
510 zoneGroups = ZoneGroupInfoSerializer(
511 help_text="Information about groups of resource zones.",
514 computeReservationId = serializers.CharField(
515 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
520 networkReservationId = serializers.CharField(
521 help_text="Information that identifies a reservation applicable to the network resource requirements.",
526 storageReservationId = serializers.CharField(
527 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
532 addResources = GrantInfoSerializer(
533 help_text="List of resources that are approved to be added.",
536 tempResources = GrantInfoSerializer(
537 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
540 removeResources = GrantInfoSerializer(
541 help_text="List of resources that are approved to be removed.",
544 updateResources = GrantInfoSerializer(
545 help_text="List of resources that are approved to be modified.",
548 vimAssets = VimAssetsSerializer(
549 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
553 extVirtualLinks = ExtVirtualLinkDataSerializer(
554 help_text="Information about external VLs to connect the VNF to.",
557 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
558 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
561 _links = GrantLinksSerializer(
562 help_text="Links to resources related to this resource.",