1 # Copyright (c) 2018, CMCC Technologies Co., Ltd.
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
17 from lcm.ns.serializers.pub_serializers import IpAddressSerialzier
20 class VnfInstanceDataSerializer(serializers.Serializer):
21 vnfInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances are "
22 "moved to", required=True)
23 vnfProfileId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
24 required=False, allow_null=True)
27 class InstantiateVnfDataSerializer(serializers.Serializer):
28 vnfdId = serializers.CharField(help_text="Information sufficient to identify the VNFD which defines the VNF to be"
29 " instantiated. ", required=True)
30 vnfFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
32 vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
33 "flavour to be instantiated. ", required=False,
35 vnfInstanceName = serializers.CharField(help_text="Human-readable name of the VNF instance to be created.",
36 required=False, allow_null=True)
39 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
40 macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
41 ipAddresses = IpAddressSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
42 required=False, allow_null=True, many=True)
45 class CpProtocolDataSerializer(serializers.Serializer):
46 layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s).",
47 choices=["IP_OVER_ETHERNET"], required=True)
48 ipOverEthernet = IpOverEthernetAddressDataSerializer(
49 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
50 required=False, allow_null=True)
53 class VnfExtCpConfigSerializer(serializers.Serializer):
54 cpInstanceId = serializers.CharField(help_text="Identifier of the external CP instance to which this set of "
55 "configuration parameters is requested to be applied.",
56 required=False, allow_null=True)
57 linkPortId = serializers.CharField(help_text="Identifier of a pre-conFigured link port to which the external CP "
58 "will be associated.", required=False, allow_null=True)
59 cpProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the link "
60 "port that connects the CP to a VL",
61 child=(CpProtocolDataSerializer(help_text="This type represents network "
62 "protocol data.", required=True)),
63 required=False, allow_null=True)
66 class VnfExtCpData(serializers.Serializer):
67 cpdId = serializers.CharField(help_text="The identifier of the CPD in the VNFD.", required=True)
68 cpConfig = serializers.ListField(help_text="List of instance data that need to be conFigured on the CP instances "
69 "created from the respective CPD.",
70 child=(VnfExtCpConfigSerializer(help_text="Config of vnf ext cp", required=True)),
71 required=False, allow_null=True)
74 class ResourceHandleSerializer(serializers.Serializer):
75 vimId = serializers.CharField(help_text="Identifier of the VIM under whose control this resource is placed.",
76 required=False, allow_null=True)
77 resourceProviderId = serializers.CharField(help_text="Identifier of the entity responsible for the management of "
78 "the resource.", required=False, allow_null=True)
79 resourceId = serializers.CharField(help_text="Identifier of the resource in the scope of the VIM or the "
80 "resource provider.", required=True)
81 vimLevelResourceType = serializers.CharField(help_text="Type of the resource in the scope of the VIM or the "
82 "resource provider.", required=False, allow_null=True)
85 class ExtLinkPortDataSerializer(serializers.Serializer):
86 id = serializers.CharField(help_text="Provided by the entity that has created the link port", required=True)
87 resourceHandle = ResourceHandleSerializer(help_text="Identifier(s) of the virtualised network resource(s) "
88 "realizing the VL instance", required=True)
91 class ExtVirtualLinkDataSerializer(serializers.Serializer):
92 extVirtualLinkId = serializers.CharField(help_text="The identifier of the external VL instance, if provided. ",
93 required=False, allow_null=True)
94 vimId = serializers.CharField(help_text="Identifier of the VIM that manages this resource.",
95 required=False, allow_null=True)
96 resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of "
97 "this resource.", required=False, allow_null=True)
98 resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or the"
99 " resource provider.", required=True)
100 extCps = serializers.ListField(child=VnfExtCpData(help_text="External CPs of the VNF to be connected to this external "
101 "VL.", required=True), required=False, allow_null=True)
102 extLinkPorts = serializers.ListField(help_text="Externally provided link ports to be used to connect external "
103 "connection points to this external VL. ",
104 child=(ExtLinkPortDataSerializer(help_text="This type represents an externally"
105 "provided link port to be used to "
106 "connect a VNF external connection "
107 "point to an external VL",
109 required=False, allow_null=True)
112 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
113 extManagedVirtualLinkId = serializers.CharField(help_text="The identifier of the externally-managed internal VL "
114 "instance,if provided.", required=False, allow_null=True)
115 virtualLinkDescId = serializers.CharField(help_text="The identifier of the VLD in the VNFD for this VL.",
118 vimId = serializers.CharField(help_text="Identifier of the VIMthat manage this resource.",
119 required=False, allow_null=True)
121 resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of"
122 "this resource.", required=False, allow_null=True)
123 resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or"
124 "the resource provider.", required=True)
127 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
128 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance to be modified.", required=True)
129 newFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
131 instantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
132 "flavour to be instantiated.",
133 required=False, allow_null=True)
134 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to connect the VNF to.",
135 child=(ExtVirtualLinkDataSerializer(help_text="This type represents "
138 required=False, allow_null=True)
139 extManagedVirtualLinks = serializers.ListField(help_text="Information about internal VLs that are managed by NFVO",
140 child=ExtManagedVirtualLinkDataSerializer(
141 help_text="This type represents an externally-managed internal"
142 "VL.", required=True), required=False, allow_null=True)
143 additionalParams = serializers.CharField(help_text="Additional input parameters for the flavour change process",
144 required=False, allow_null=True)
147 class OperationalStatesSerializer(serializers.Serializer):
148 OperationalStates = serializers.ChoiceField(help_text="State of operation",
149 choices=["STARTED", "STOPPED"])
152 class StopTypeSerializer(serializers.Serializer):
153 StopType = serializers.ChoiceField(help_text="Type of stop", choices=["FORCEFUL", "GRACEFUL"])
156 class OperateVnfDataSerializer(serializers.Serializer):
157 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
158 changeStateTo = OperationalStatesSerializer(help_text="The desired operational state to change the VNF to.",
160 stopType = StopTypeSerializer(help_text="It signals whether forceful or graceful stop is requested.",
161 required=False, allow_null=True)
162 gracefulStopTimeout = serializers.CharField(help_text="The time interval to wait for the VNF to be taken out of"
163 "service during graceful stop.",
164 required=False, allow_null=True)
167 class ModifyVnfInfoDataSerializer(serializers.Serializer):
168 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance", required=True)
169 vnfInstanceName = serializers.CharField(help_text="New value of the vnfInstanceName attribute in VnfInstance",
170 required=False, allow_null=True)
171 vnfInstanceDescription = serializers.CharField(help_text="New value of the vnfInstanceDescription attribute in"
172 "VnfInstance", required=False, allow_null=True)
175 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
176 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True, allow_null=True)
177 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to change",
178 child=(ExtVirtualLinkDataSerializer(
179 help_text="Data of ext virtual link", required=True)),
180 required=False, allow_null=True)
181 additionalParams = serializers.CharField(help_text="Additional parameters passed by the OSS as input to the "
182 "external connectivity change process",
183 required=False, allow_null=True)
186 class SapDataSerializer(serializers.Serializer):
187 sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
188 sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
189 description = serializers.CharField(help_text="Human readable description for the SAP. ", required=True)
190 sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the SAP.",
191 child=(CpProtocolDataSerializer(
192 help_text="This type represents network protocol data.", required=True)),
193 required=False, allow_null=True)
196 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
197 newNsdId = serializers.CharField(help_text="Identifier of the new NSD version that is to be associated to the NS "
198 "instance. ", required=True)
201 class MoveVnfInstanceDataSerializer(serializers.Serializer):
202 targetNsInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances "
203 "are moved to.", required=True)
204 vnfInstanceId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
205 required=False, allow_null=True)
208 class NsCpHandleSerializer(serializers.Serializer):
209 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated to the CP instance.",
210 required=False, allow_null=True)
211 vnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the VNF external CP instance in the scope "
212 "of the VNF instance. ", required=False, allow_null=True)
213 pnfInfoId = serializers.CharField(help_text="Identifier of the PNF instance associated to the CP instance.",
214 required=False, allow_null=True)
215 pnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the PNF external CP instance in the scope "
216 "of the PNF.", required=False, allow_null=True)
217 nsInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated to the SAP instance.",
218 required=False, allow_null=True)
219 nsSapInstanceId = serializers.CharField(help_text="Identifier of the SAP instance in the scope of the NS instance",
220 required=False, allow_null=True)
223 class PortRangeSerializer(serializers.Serializer):
224 lowerPort = serializers.CharField(help_text="Identifies the lower bound of the port range. ", required=True)
225 upperPort = serializers.CharField(help_text="Identifies the upper bound of the port range ", required=True)
228 class MaskSerializer(serializers.Serializer):
229 startingPoint = serializers.CharField(help_text="Indicates the offset between the last bit of the source mac "
230 "address and the first bit of the sequence of bits to "
231 "be matched.", required=True)
232 length = serializers.CharField(help_text="Indicates the number of bits to be matched. ", required=True)
233 value = serializers.CharField(help_text="Provide the sequence of bit values to be matched. ", required=True)
236 class NfpRuleSerializer(serializers.Serializer):
237 etherDestinationAddress = serializers.CharField(help_text="Indicates a destination Mac address ",
238 required=False, allow_null=True)
239 etherSourceAddress = serializers.CharField(help_text="Indicates a source Mac address",
240 required=False, allow_null=True)
241 etherType = serializers.ChoiceField(help_text="Indicates the protocol carried over the Ethernet layer.",
242 choices=["IPV4", "IPV6"], required=False, allow_null=True)
243 vlanTag = serializers.CharField(help_text="Indicates a VLAN identifier in an IEEE 802.1Q-2014 tag [6] ",
244 required=False, allow_null=True)
245 protocol = serializers.ChoiceField(help_text="Indicates the L4 protocol",
246 choices=["TCP", "UDP", "ICMP"], required=False, allow_null=True)
247 dscp = serializers.CharField(help_text="For IPv4 [7] a string of 0 and 1 digits that corresponds to the 6-bit "
248 "Differentiated Services Code Point (DSCP) field of the IP header",
249 required=False, allow_null=True)
250 sourcePortRange = PortRangeSerializer(help_text="Indicates a range of source ports. ",
251 required=False, allow_null=True)
252 destinationPortRange = PortRangeSerializer(help_text="Indicates a range of destination ports.",
253 required=False, allow_null=True)
254 sourceIpAddressPrefix = serializers.CharField(
255 help_text="Prefix of source ip address", required=False, allow_null=True)
256 destinationIpAddressPrefix = serializers.CharField(
257 help_text="Prefix of destination ip address", required=False, allow_null=True)
258 extendedCriteria = serializers.ListField(help_text="Indicates values of specific bits in a frame.",
259 child=(MaskSerializer(help_text="Mask serializer", required=True)),
260 required=False, allow_null=True)
263 class NfpDataSerializer(serializers.Serializer):
264 nfpInfoId = serializers.CharField(help_text="Identifier of the NFP to be modified.",
265 required=False, allow_null=True)
266 nfpName = serializers.CharField(help_text="Human readable name for the NFP.", required=False, allow_null=True)
267 description = serializers.CharField(help_text="Human readable description for the NFP",
268 required=False, allow_null=True)
269 nsCpHandle = serializers.ListField(help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
270 child=(NsCpHandleSerializer(
271 help_text="This type represents an identifier of the CP or SAP instance.",
272 required=True)), required=False, allow_null=True)
273 nfpRule = NfpRuleSerializer(help_text="NFP classification and selection rule.", required=False, allow_null=True)
276 class UpdateVnffgDataSerializer(serializers.Serializer):
277 vnffgInfoId = serializers.CharField(help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
279 nfp = serializers.ListField(help_text="nfp", child=(NfpDataSerializer(help_text="This type contains information "
280 "used to create or modify NFP "
281 "instance parameters for the update"
282 "of an existing VNFFG instance. ",
284 required=False, allow_null=True)
285 nfpInfoId = serializers.ListField(help_text="Identifier(s) of the NFP to be deleted from a given VNFFG.",
286 required=False, allow_null=True)
289 class ChangeNsFlavourDataSerializer(serializers.Serializer):
290 newNsFlavourId = serializers.CharField(
291 help_text="Identifier of the new NS DF to apply to this NS instance.", required=True)
292 instantiationLevelId = serializers.CharField(
293 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
294 required=False, allow_null=True)
297 class IdentifierInPnfSerializer(serializers.Serializer):
298 IdentifierInPnf = serializers.Serializer(help_text="An Identifier that is unique within respect to a PNF.")
301 class IdentifierInNsdSerializer(serializers.Serializer):
302 IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
305 class PnfExtCpDataSerializer(serializers.Serializer):
306 cpInstanceI16 = IdentifierInPnfSerializer(help_text="Identifier of the CP. Shall be present for existing CP.",
307 required=False, allow_null=True)
308 cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
309 required=False, allow_null=True)
310 cpProtocolData = CpProtocolDataSerializer(help_text="Address assigned for this CP.",
311 required=False, allow_null=True, many=True)
314 class AddPnfDataSerializer(serializers.Serializer):
315 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
316 pnfName = serializers.CharField(help_text="Name of the PNF.", required=True)
317 pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
318 pnfProfileId = serializers.CharField(
319 help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
320 cpData = PnfExtCpDataSerializer(help_text="Address assigned for the PNF external CP(s). ",
321 required=False, allow_null=True, many=True)
324 class ModifyPnfDataSerializer(serializers.Serializer):
325 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
326 pnfName = serializers.CharField(help_text="Name of the PNF", required=False, allow_null=True)
327 cpData = serializers.ListField(
328 help_text="Address assigned for the PNF external CP(s).",
329 child=(PnfExtCpDataSerializer(
330 help_text="This type represents the configuration data on the external CP of the PNF.")),
331 required=False, allow_null=True)
334 class DateTimeSerializer(serializers.Serializer):
335 DateTime = serializers.Serializer(help_text="Date-time stamp.")
338 class UpdateNsReqSerializer(serializers.Serializer):
339 updateType = serializers.ChoiceField(help_text="The type of update.",
340 choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
341 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
342 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
343 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
344 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
345 "MODIFY_PNF", "REMOVE_PNF"], required=True)
346 addVnfInstance = serializers.ListField(help_text="Identifies an existing VNF instance to be added to the NS "
348 child=(VnfInstanceDataSerializer(help_text="Data of vnf instance",
350 required=False, allow_null=True)
351 removeVnfInstanceId = serializers.ListField(help_text="Identifies an existing VNF instance to be removed from "
352 "the NS instance.", required=False, allow_null=True)
353 instantiateVnfData = serializers.ListField(help_text="Identifies the new VNF to be instantiated.",
354 child=(InstantiateVnfDataSerializer(help_text="Data of vnf instance",
356 required=False, allow_null=True)
357 changeVnfFlavourData = serializers.ListField(help_text="Identifies the new DF of the VNF instance to be "
359 child=(ChangeVnfFlavourDataSerizlizer(
360 help_text="The type represents the information that is requested "
361 "to be changed deployment flavour for an existing "
362 "VNF instance.", required=True)),
363 required=False, allow_null=True)
364 operateVnfData = serializers.ListField(help_text="This type represents a VNF instance for which the operational "
365 "state needs to be changed and the requested new state.",
366 child=(OperateVnfDataSerializer(
367 help_text="This type represents a VNF instance for which the operational"
368 " state needs to be changed and the requested new state",
369 required=True)), required=False, allow_null=True)
370 modifyVnfInfoData = serializers.ListField(help_text="This type represents the information that is requested to be"
371 " modified for a VNF instance. ",
372 child=(ModifyVnfInfoDataSerializer(
373 help_text="This type represents the information that is requested to "
374 "be modified for a VNF instance. ", required=True)),
375 required=False, allow_null=True)
376 changeExtVnfConnectivityData = serializers.ListField(help_text="Specifies the new external connectivity data of the"
377 "VNF instance to be changed",
378 child=(ChangeExtVnfConnectivityDataSerializer(
379 help_text="This type describes the information invoked by"
380 "the NFVO to change the external VNF "
381 "connectivity information maintained by"
382 " the VNFM.", required=True)),
383 required=False, allow_null=True)
384 addSap = serializers.ListField(help_text="Identifies a new SAP to be added to the NS instance.",
385 child=(SapDataSerializer(help_text="This type represents the information related to "
386 "a SAP of a NS", required=True)),
387 required=False, allow_null=True)
388 removeSapId = serializers.ListField(help_text="The identifier an existing SAP to be removed from the "
389 "NS instance", required=False, allow_null=True)
390 addNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to "
391 "the NS instance", required=False, allow_null=True)
392 removeNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be "
393 "removed from the NS instance.",
394 required=False, allow_null=True)
395 assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(help_text="Specify the new NSD to be used for the NS "
396 "instance.", required=False, allow_null=True)
397 moveVnfInstanceData = serializers.ListField(help_text="Specify existing VNF instance to be moved from one NS "
398 "instance to another NS instance",
399 child=(MoveVnfInstanceDataSerializer()),
400 required=False, allow_null=True)
401 addVnffg = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to the"
402 " NS instance.", required=False, allow_null=True)
403 removeVnffgId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be removed "
404 "from the NS instance", required=False, allow_null=True)
405 updateVnffg = serializers.ListField(help_text="Specify the new VNFFG Information data to be updated for a VNFFG"
406 " of the NS Instance",
407 child=(UpdateVnffgDataSerializer(help_text="This type specifies the parameters "
408 "used for the update of an existing "
409 "VNFFG instance.", required=True)),
410 required=False, allow_null=True)
411 changeNsFlavourData = ChangeNsFlavourDataSerializer(
412 help_text="Specifies the new DF to be applied to the NS instance", required=False, allow_null=True)
413 addPnfData = serializers.ListField(help_text="Specifies the PNF to be added into the NS instance.",
414 child=(AddPnfDataSerializer(help_text="Serializer data of add pnf", required=True)),
415 required=False, allow_null=True)
416 modifyPnfData = serializers.ListField(help_text="Specifies the PNF to be modified in the NS instance.",
417 child=(ModifyPnfDataSerializer(
418 help_text="This type specifies an PNF to be modified in the NS instance.",
420 required=False, allow_null=True)
421 removePnfId = serializers.ListField(help_text="Identifier of the PNF to be deleted from the NS instance.",
422 required=False, allow_null=True)
423 updateTime = DateTimeSerializer(help_text="Timestamp indicating the update time of the NS",
424 required=False, allow_null=True)