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 GrantRequestSerializer(serializers.Serializer):
19 vnfInstanceId = serializers.CharField(
20 help_text="Identifier of the VNF instance which this grant request is related to.",
23 vnfLcmOpOccId = serializers.CharField(
24 help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
29 vnfdId = serializers.CharField(
30 help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
35 flavourId = serializers.CharField(
36 help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
41 operation = serializers.ChoiceField(
42 help_text="The lifecycle management operation for which granting is requested.",
43 choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
48 class VimConnectionInfoSerializer(serializers.Serializer):
49 id = serializers.CharField(
50 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
53 vimId = serializers.CharField(
54 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
59 vimType = serializers.CharField(
60 help_text="Discriminator for the different types of the VIM information.",
65 interfaceInfo = serializers.DictField(
66 help_text="Information about the interface or interfaces to the VIM.",
67 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
71 accessInfo = serializers.DictField(
72 help_text="Authentication credentials for accessing the VIM.",
73 child=serializers.CharField(help_text="Access Info", allow_blank=True),
77 extra = serializers.DictField(
78 help_text="VIM type specific additional information.",
79 child=serializers.CharField(help_text="Extra", allow_blank=True),
85 class ZoneInfoSerializer(serializers.Serializer):
86 id = serializers.CharField(
87 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
90 zoneId = serializers.CharField(
91 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
96 vimConnectionId = serializers.CharField(
97 help_text="Identifier of the connection to the VIM that manages the resource zone.",
102 resourceProviderId = serializers.CharField(
103 help_text="Identifies the entity responsible for the management the resource zone.",
110 class ZoneGroupInfoSerializer(serializers.Serializer):
111 zoneId = serializers.ListSerializer(
112 help_text="References of identifiers of ZoneInfo structures.",
113 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
119 class GrantInfoSerializer(serializers.Serializer):
120 resourceDefinitionId = serializers.CharField(
121 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
124 reservationId = serializers.CharField(
125 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
130 vimConnectionId = serializers.CharField(
131 help_text="Identifier of the VIM connection to be used to manage this resource.",
136 resourceProviderId = serializers.CharField(
137 help_text="Identifies the entity responsible for the management of the virtualised resource.",
142 zoneId = serializers.CharField(
143 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
148 resourceGroupId = serializers.CharField(
149 help_text="Identifier of the infrastructure resource group.",
156 class VimComputeResourceFlavourSerializer(serializers.Serializer):
157 vimConnectionId = serializers.CharField(
158 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
163 resourceProviderId = serializers.CharField(
164 help_text="Identifies the entity responsible for the management of the virtualised resource.",
169 vnfdVirtualComputeDescId = serializers.CharField(
170 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
175 vimFlavourId = serializers.CharField(
176 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
183 class VimSoftwareImageSerializer(serializers.Serializer):
184 vimConnectionId = serializers.CharField(
185 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
190 resourceProviderId = serializers.CharField(
191 help_text="Identifies the entity responsible for the management of the virtualised resource.",
196 vnfdSoftwareImageId = serializers.CharField(
197 help_text="Identifier which references the software image descriptor in the VNFD.",
202 vimSoftwareImageId = serializers.CharField(
203 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
210 class VimAssetsSerializer(serializers.Serializer):
211 computeResourceFlavours = VimComputeResourceFlavourSerializer(
212 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
215 softwareImages = VimSoftwareImageSerializer(
216 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
221 class AddressRangeSerializer(serializers.Serializer):
222 minAddress = serializers.CharField(
223 help_text="Lowest IP address belonging to the range.",
226 maxAddress = serializers.CharField(
227 help_text="Highest IP address belonging to the range.",
232 class IpAddresseSerializer(serializers.Serializer):
233 type = serializers.ChoiceField(
234 help_text="The type of the IP addresses.",
235 choices=["IPV4", "IPV6"],
238 fixedAddresses = serializers.ListSerializer(
239 help_text="Fixed addresses to assign.",
240 child=serializers.CharField(help_text="IpAddress"),
244 numDynamicAddresses = serializers.IntegerField(
245 help_text="Number of dynamic addresses to assign.",
248 addressRange = AddressRangeSerializer(
249 help_text="An IP address range to be used, e.g. in case of egress connections.",
253 subnetId = serializers.CharField(
254 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
261 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
262 macAddress = serializers.CharField(
263 help_text="MAC address.",
268 ipAddresses = IpAddresseSerializer(
269 help_text="List of IP addresses to assign to the CP instance.",
274 class CpProtocolDataSerializer(serializers.Serializer):
275 layerProtocol = serializers.ChoiceField(
276 help_text="Identifier of layer(s) and protocol(s).",
277 choices=["IP_OVER_ETHERNET"],
280 ipOverEthernet = IpOverEthernetAddressDataSerializer(
281 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
287 class VnfExtCpConfigSerializer(serializers.Serializer):
288 cpInstanceId = serializers.CharField(
289 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
294 linkPortId = serializers.CharField(
295 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
300 cpProtocolData = CpProtocolDataSerializer(
301 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
306 class VnfExtCpDataSerializer(serializers.Serializer):
307 cpdId = serializers.CharField(
308 help_text="The identifier of the CPD in the VNFD.",
311 cpConfig = VnfExtCpConfigSerializer(
312 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
317 class ExtLinkPortDataSerializer(serializers.Serializer):
318 id = serializers.CharField(
319 help_text="Identifier of this link port as provided by the entity that has created the link port.",
322 resourceHandle = serializers.CharField(
323 help_text="Reference to the virtualised resource realizing this link port.",
328 class ExtVirtualLinkDataSerializer(serializers.Serializer):
329 id = serializers.CharField(
330 help_text="The identifier of the external VL instance.",
333 vimConnectionId = serializers.CharField(
334 help_text="Identifier of the VIM connection to manage this resource.",
339 resourceProviderId = serializers.CharField(
340 help_text="Identifies the entity responsible for the management of this resource.",
345 resourceId = serializers.CharField(
346 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
349 extCps = VnfExtCpDataSerializer(
350 help_text="External CPs of the VNF to be connected to this external VL.",
353 extLinkPorts = ExtLinkPortDataSerializer(
354 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
359 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
360 id = serializers.CharField(
361 help_text="The identifier of the externally-managed internal VL instance.",
364 virtualLinkDescId = serializers.CharField(
365 help_text="The identifier of the VLD in the VNFD for this VL.",
368 vimConnectionId = serializers.CharField(
369 help_text="Identifier of the VIM connection to manage this resource.",
374 resourceProviderId = serializers.CharField(
375 help_text="Identifies the entity responsible for the management of this resource.",
380 resourceId = serializers.CharField(
381 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
386 class LinksSerializer(serializers.Serializer):
387 self = serializers.CharField(
388 help_text="URI of this resource.",
391 vnfLcmOpOcc = serializers.CharField(
392 help_text="Related VNF lifecycle management operation occurrence.",
395 vnfInstance = serializers.CharField(
396 help_text="Related VNF instance.",
401 class GrantSerializer(serializers.Serializer):
402 id = serializers.CharField(
403 help_text="Identifier of the grant.",
406 vnfInstanceId = serializers.CharField(
409 vnfLcmOpOccId = serializers.CharField(
410 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
415 vimConnections = VimConnectionInfoSerializer(
416 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
419 zones = ZoneInfoSerializer(
420 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
423 zoneGroups = ZoneGroupInfoSerializer(
424 help_text="Information about groups of resource zones.",
427 computeReservationId = serializers.CharField(
428 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
433 networkReservationId = serializers.CharField(
434 help_text="Information that identifies a reservation applicable to the network resource requirements.",
439 storageReservationId = serializers.CharField(
440 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
445 addResources = GrantInfoSerializer(
446 help_text="List of resources that are approved to be added.",
449 tempResources = GrantInfoSerializer(
450 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
453 removeResources = GrantInfoSerializer(
454 help_text="List of resources that are approved to be removed.",
457 updateResources = GrantInfoSerializer(
458 help_text="List of resources that are approved to be modified.",
461 vimAssets = VimAssetsSerializer(
462 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
466 extVirtualLinks = ExtVirtualLinkDataSerializer(
467 help_text="Information about external VLs to connect the VNF to.",
470 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
471 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
474 links = LinksSerializer(
475 help_text="Links to resources related to this resource.",