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 driver.interfaces.serializers.link import LinkSerializer
17 from rest_framework import serializers
20 class VimConnectionSerializer(serializers.Serializer):
21 id = serializers.CharField(
22 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
25 vimId = serializers.CharField(
26 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
30 vimType = serializers.CharField(
31 help_text="Discriminator for the different types of the VIM information.",
35 interfaceInfo = serializers.DictField(
36 help_text="Information about the interface or interfaces to the VIM.",
37 child=serializers.CharField(help_text="Interface Info", allow_blank=True),
41 accessInfo = serializers.DictField(
42 help_text="Authentication credentials for accessing the VIM.",
43 child=serializers.CharField(help_text="Access Info", allow_blank=True),
47 extra = serializers.DictField(
48 help_text="VIM type specific additional information.",
49 child=serializers.CharField(help_text="Extra", allow_blank=True),
55 class ZoneInfoSerializer(serializers.Serializer):
56 id = serializers.CharField(
57 help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
60 zoneId = serializers.CharField(
61 help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
64 vimConnectionId = serializers.CharField(
65 help_text="Identifier of the connection to the VIM that manages the resource zone.",
68 resourceProviderId = serializers.CharField(
69 help_text="Identifies the entity responsible for the management the resource zone.",
74 class ZoneGroupInfoSerializer(serializers.Serializer):
75 zoneId = serializers.ListSerializer(
76 help_text="References of identifiers of ZoneInfo structures.",
77 child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
82 class GrantInfoSerializer(serializers.Serializer):
83 resourceDefinitionId = serializers.CharField(
84 help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
87 reservationId = serializers.CharField(
88 help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
91 vimConnectionId = serializers.CharField(
92 help_text="Identifier of the VIM connection to be used to manage this resource.",
95 resourceProviderId = serializers.CharField(
96 help_text="Identifies the entity responsible for the management of the virtualised resource.",
99 zoneId = serializers.CharField(
100 help_text="Reference to the identifier of the ZoneInfo in the Grant.",
103 resourceGroupId = serializers.CharField(
104 help_text="Identifier of the infrastructure resource group.",
109 class VimComputeResourceFlavourSerializer(serializers.Serializer):
110 vimConnectionId = serializers.CharField(
111 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
114 resourceProviderId = serializers.CharField(
115 help_text="Identifies the entity responsible for the management of the virtualised resource.",
118 vnfdVirtualComputeDescId = serializers.CharField(
119 help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
122 vimFlavourId = serializers.CharField(
123 help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
128 class VimSoftwareImageSerializer(serializers.Serializer):
129 vimConnectionId = serializers.CharField(
130 help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
133 resourceProviderId = serializers.CharField(
134 help_text="Identifies the entity responsible for the management of the virtualised resource.",
137 vnfdSoftwareImageId = serializers.CharField(
138 help_text="Identifier which references the software image descriptor in the VNFD.",
141 vimSoftwareImageId = serializers.CharField(
142 help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
147 class VimAssetsSerializer(serializers.Serializer):
148 computeResourceFlavours = VimComputeResourceFlavourSerializer(
149 help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
153 softwareImages = VimSoftwareImageSerializer(
154 help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
160 class AddressRangeSerializer(serializers.Serializer):
161 minAddress = serializers.CharField(
162 help_text="Lowest IP address belonging to the range.",
165 maxAddress = serializers.CharField(
166 help_text="Highest IP address belonging to the range.",
171 class IpAddresseSerializer(serializers.Serializer):
172 type = serializers.ChoiceField(
173 help_text="The type of the IP addresses.",
174 choices=["IPV4", "IPV6"],
177 fixedAddresses = serializers.ListSerializer(
178 help_text="Fixed addresses to assign.",
179 child=serializers.CharField(help_text="IpAddress"),
182 numDynamicAddresses = serializers.IntegerField(
183 help_text="Number of dynamic addresses to assign.",
186 addressRange = AddressRangeSerializer(
187 help_text="An IP address range to be used, e.g. in case of egress connections.",
190 subnetId = serializers.CharField(
191 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
196 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
197 macAddress = serializers.CharField(
198 help_text="MAC address.",
201 ipAddresses = IpAddresseSerializer(
202 help_text="List of IP addresses to assign to the CP instance.",
208 class CpProtocolDataSerializer(serializers.Serializer):
209 layerProtocol = serializers.ChoiceField(
210 help_text="Identifier of layer(s) and protocol(s).",
211 choices=["IP_OVER_ETHERNET"],
214 ipOverEthernet = IpOverEthernetAddressDataSerializer(
215 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
220 class VnfExtCpConfigSerializer(serializers.Serializer):
221 cpInstanceId = serializers.CharField(
222 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
225 linkPortId = serializers.CharField(
226 help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
229 cpProtocolData = CpProtocolDataSerializer(
230 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
235 class VnfExtCpDataSerializer(serializers.Serializer):
236 cpdId = serializers.CharField(
237 help_text="The identifier of the CPD in the VNFD.",
240 cpConfig = VnfExtCpConfigSerializer(
241 help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
247 class ExtLinkPortDataSerializer(serializers.Serializer):
248 id = serializers.CharField(
249 help_text="Identifier of this link port as provided by the entity that has created the link port.",
252 resourceHandle = serializers.CharField(
253 help_text="Reference to the virtualised resource realizing this link port.",
258 class ExtVirtualLinkDataSerializer(serializers.Serializer):
259 id = serializers.CharField(
260 help_text="The identifier of the external VL instance.",
263 vimConnectionId = serializers.CharField(
264 help_text="Identifier of the VIM connection to manage this resource.",
267 resourceProviderId = serializers.CharField(
268 help_text="Identifies the entity responsible for the management of this resource.",
271 resourceId = serializers.CharField(
272 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
275 extCps = VnfExtCpDataSerializer(
276 help_text="External CPs of the VNF to be connected to this external VL.",
280 extLinkPorts = ExtLinkPortDataSerializer(
281 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
287 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
288 id = serializers.CharField(
289 help_text="The identifier of the externally-managed internal VL instance.",
292 virtualLinkDescId = serializers.CharField(
293 help_text="The identifier of the VLD in the VNFD for this VL.",
296 vimConnectionId = serializers.CharField(
297 help_text="Identifier of the VIM connection to manage this resource.",
300 resourceProviderId = serializers.CharField(
301 help_text="Identifies the entity responsible for the management of this resource.",
304 resourceId = serializers.CharField(
305 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
310 class GrantLinksSerializer(serializers.Serializer):
311 self = LinkSerializer(
312 help_text="URI of this resource.",
315 vnfLcmOpOcc = LinkSerializer(
316 help_text="Related VNF lifecycle management operation occurrence.",
319 vnfInstance = LinkSerializer(
320 help_text="Related VNF instance.",
325 class GrantSerializer(serializers.Serializer):
326 id = serializers.CharField(
327 help_text="Identifier of the grant.",
330 vnfInstanceId = serializers.CharField(
331 help_text="Identifier of the related VNF instance.",
334 vnfLcmOpOccId = serializers.CharField(
335 help_text="Identifier of the related VNF lifecycle management operation occurrence.",
338 vimConnections = VimConnectionSerializer(
339 help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
343 zones = ZoneInfoSerializer(
344 help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
348 zoneGroups = ZoneGroupInfoSerializer(
349 help_text="Information about groups of resource zones.",
353 computeReservationId = serializers.CharField(
354 help_text="Information that identifies a reservation applicable to the compute resource requirements.",
357 networkReservationId = serializers.CharField(
358 help_text="Information that identifies a reservation applicable to the network resource requirements.",
361 storageReservationId = serializers.CharField(
362 help_text="Information that identifies a reservation applicable to the storage resource requirements.",
365 addResources = GrantInfoSerializer(
366 help_text="List of resources that are approved to be added.",
370 tempResources = GrantInfoSerializer(
371 help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
375 removeResources = GrantInfoSerializer(
376 help_text="List of resources that are approved to be removed.",
380 updateResources = GrantInfoSerializer(
381 help_text="List of resources that are approved to be modified.",
385 vimAssets = VimAssetsSerializer(
386 help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
389 extVirtualLinks = ExtVirtualLinkDataSerializer(
390 help_text="Information about external VLs to connect the VNF to.",
394 extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
395 help_text="Information about internal VLs that are managed by other entities than the VNFM.",
399 additionalParams = serializers.DictField(
400 help_text="Additional parameters passed by the NFVO, \
401 specific to the VNF and the LCM operation.",
402 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
405 _links = GrantLinksSerializer(
406 help_text="Links to resources related to this resource.",