1 # Copyright (c) 2018, CMCC Technologies Co., Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 from rest_framework import serializers
17 class VnfInstanceDataSerializer(serializers.Serializer):
18 vnfInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances are "
19 "moved to", required=True)
20 vnfProfileId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
21 required=False, allow_null=True)
24 class InstantiateVnfDataSerializer(serializers.Serializer):
25 vnfdId = serializers.CharField(help_text="Information sufficient to identify the VNFD which defines the VNF to be"
26 " instantiated. ", required=True)
27 vnfFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
29 vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
30 "flavour to be instantiated. ", required=False,
32 vnfInstanceName = serializers.CharField(help_text="Human-readable name of the VNF instance to be created.",
33 required=False, allow_null=True)
36 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
37 macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
38 ipAddresses = serializers.ListField(help_text="List of IP addresses to assign to the extCP instance.",
39 required=False, allow_null=True)
42 class CpProtocolDataSerializer(serializers.Serializer):
43 layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s).",
44 choices=["IP_OVER_ETHERNET"], required=True)
45 ipOverEthernet = IpOverEthernetAddressDataSerializer(
46 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
47 required=False, allow_null=True)
50 class VnfExtCpConfigSerializer(serializers.Serializer):
51 cpInstanceId = serializers.CharField(help_text="Identifier of the external CP instance to which this set of "
52 "configuration parameters is requested to be applied.",
53 required=False, allow_null=True)
54 linkPortId = serializers.CharField(help_text="Identifier of a pre-conFigured link port to which the external CP "
55 "will be associated.", required=False, allow_null=True)
56 cpProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the link "
57 "port that connects the CP to a VL",
58 child=(CpProtocolDataSerializer(help_text="This type represents network "
59 "protocol data.", required=True)),
60 required=False, allow_null=True)
63 class VnfExtCpData(serializers.Serializer):
64 cpdId = serializers.CharField(help_text="The identifier of the CPD in the VNFD.", required=True)
65 cpConfig = serializers.ListField(help_text="List of instance data that need to be conFigured on the CP instances "
66 "created from the respective CPD.",
67 child=(VnfExtCpConfigSerializer(help_text="Config of vnf ext cp", required=True)),
68 required=False, allow_null=True)
71 class ResourceHandleSerializer(serializers.Serializer):
72 vimId = serializers.CharField(help_text="Identifier of the VIM under whose control this resource is placed.",
73 required=False, allow_null=True)
74 resourceProviderId = serializers.CharField(help_text="Identifier of the entity responsible for the management of "
75 "the resource.", required=False, allow_null=True)
76 resourceId = serializers.CharField(help_text="Identifier of the resource in the scope of the VIM or the "
77 "resource provider.", required=True)
78 vimLevelResourceType = serializers.CharField(help_text="Type of the resource in the scope of the VIM or the "
79 "resource provider.", required=False, allow_null=True)
82 class ExtLinkPortDataSerializer(serializers.Serializer):
83 id = serializers.CharField(help_text="Provided by the entity that has created the link port", required=True)
84 resourceHandle = ResourceHandleSerializer(help_text="Identifier(s) of the virtualised network resource(s) "
85 "realizing the VL instance", required=True)
88 class ExtVirtualLinkDataSerializer(serializers.Serializer):
89 extVirtualLinkId = serializers.CharField(help_text="The identifier of the external VL instance, if provided. ",
90 required=False, allow_null=True)
91 vimId = serializers.CharField(help_text="Identifier of the VIM that manages this resource.",
92 required=False, allow_null=True)
93 resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of "
94 "this resource.", required=False, allow_null=True)
95 resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or the"
96 " resource provider.", required=True)
97 extCps = serializers.ListField(VnfExtCpData(help_text="External CPs of the VNF to be connected to this external "
98 "VL.", required=True), required=False, allow_null=True)
99 extLinkPorts = serializers.ListField(help_text="Externally provided link ports to be used to connect external "
100 "connection points to this external VL. ",
101 child=(ExtLinkPortDataSerializer(help_text="This type represents an externally"
102 "provided link port to be used to "
103 "connect a VNF external connection "
104 "point to an external VL",
106 required=False, allow_null=True)
109 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
110 extManagedVirtualLinkId = serializers.CharField(help_text="The identifier of the externally-managed internal VL "
111 "instance,if provided.", required=False, allow_null=True)
112 virtualLinkDescId = serializers.CharField(help_text="The identifier of the VLD in the VNFD for this VL.",
115 vimId = serializers.CharField(help_text="Identifier of the VIMthat manage this resource.",
116 required=False, allow_null=True)
118 resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of"
119 "this resource.", required=False, allow_null=True)
120 resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or"
121 "the resource provider.", required=True)
124 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
125 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance to be modified.", required=True)
126 newFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
128 instantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
129 "flavour to be instantiated.",
130 required=False, allow_null=True)
131 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to connect the VNF to.",
132 child=(ExtVirtualLinkDataSerializer(help_text="This type represents "
135 required=False, allow_null=True)
136 extManagedVirtualLinks = serializers.ListField(help_text="Information about internal VLs that are managed by NFVO",
137 child=ExtManagedVirtualLinkDataSerializer(
138 help_text="This type represents an externally-managed internal"
139 "VL.", required=True), required=False, allow_null=True)
140 additionalParams = serializers.CharField(help_text="Additional input parameters for the flavour change process",
141 required=False, allow_null=True)
144 class OperationalStatesSerializer(serializers.Serializer):
145 OperationalStates = serializers.ChoiceField(help_text="State of operation",
146 choices=["STARTED", "STOPPED"])
149 class StopTypeSerializer(serializers.Serializer):
150 StopType = serializers.ChoiceField(help_text="Type of stop", choices=["FORCEFUL", "GRACEFUL"])
153 class OperateVnfDataSerializer(serializers.Serializer):
154 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
155 changeStateTo = OperationalStatesSerializer(help_text="The desired operational state to change the VNF to.",
157 stopType = StopTypeSerializer(help_text="It signals whether forceful or graceful stop is requested.",
158 required=False, allow_null=True)
159 gracefulStopTimeout = serializers.CharField(help_text="The time interval to wait for the VNF to be taken out of"
160 "service during graceful stop.",
161 required=False, allow_null=True)
164 class ModifyVnfInfoDataSerializer(serializers.Serializer):
165 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance", required=True)
166 vnfInstanceName = serializers.CharField(help_text="New value of the vnfInstanceName attribute in VnfInstance",
167 required=False, allow_null=True)
168 vnfInstanceDescription = serializers.CharField(help_text="New value of the vnfInstanceDescription attribute in"
169 "VnfInstance", required=False, allow_null=True)
172 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
173 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True, allow_null=True)
174 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to change",
175 child=(ExtVirtualLinkDataSerializer(
176 help_text="Data of ext virtual link", required=True)),
177 required=False, allow_null=True)
178 additionalParams = serializers.CharField(help_text="Additional parameters passed by the OSS as input to the "
179 "external connectivity change process",
180 required=False, allow_null=True)
183 class SapDataSerializer(serializers.Serializer):
184 sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
185 sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
186 description = serializers.CharField(help_text="Human readable description for the SAP. ", required=True)
187 sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the SAP.",
188 child=(CpProtocolDataSerializer(
189 help_text="This type represents network protocol data.", required=True)),
190 required=False, allow_null=True)
193 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
194 newNsdId = serializers.CharField(help_text="Identifier of the new NSD version that is to be associated to the NS "
195 "instance. ", required=True)
198 class MoveVnfInstanceDataSerializer(serializers.Serializer):
199 targetNsInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances "
200 "are moved to.", required=True)
201 vnfInstanceId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
202 required=False, allow_null=True)
205 class NsCpHandleSerializer(serializers.Serializer):
206 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated to the CP instance.",
207 required=False, allow_null=True)
208 vnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the VNF external CP instance in the scope "
209 "of the VNF instance. ", required=False, allow_null=True)
210 pnfInfoId = serializers.CharField(help_text="Identifier of the PNF instance associated to the CP instance.",
211 required=False, allow_null=True)
212 pnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the PNF external CP instance in the scope "
213 "of the PNF.", required=False, allow_null=True)
214 nsInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated to the SAP instance.",
215 required=False, allow_null=True)
216 nsSapInstanceId = serializers.CharField(help_text="Identifier of the SAP instance in the scope of the NS instance",
217 required=False, allow_null=True)
220 class PortRangeSerializer(serializers.Serializer):
221 lowerPort = serializers.CharField(help_text="Identifies the lower bound of the port range. ", required=True)
222 upperPort = serializers.CharField(help_text="Identifies the upper bound of the port range ", required=True)
225 class MaskSerializer(serializers.Serializer):
226 startingPoint = serializers.CharField(help_text="Indicates the offset between the last bit of the source mac "
227 "address and the first bit of the sequence of bits to "
228 "be matched.", required=True)
229 length = serializers.CharField(help_text="Indicates the number of bits to be matched. ", required=True)
230 value = serializers.CharField(help_text="Provide the sequence of bit values to be matched. ", required=True)
233 class NfpRuleSerializer(serializers.Serializer):
234 etherDestinationAddress = serializers.CharField(help_text="Indicates a destination Mac address ",
235 required=False, allow_null=True)
236 etherSourceAddress = serializers.CharField(help_text="Indicates a source Mac address",
237 required=False, allow_null=True)
238 etherType = serializers.ChoiceField(help_text="Indicates the protocol carried over the Ethernet layer.",
239 choices=["IPV4", "IPV6"], required=False, allow_null=True)
240 vlanTag = serializers.CharField(help_text="Indicates a VLAN identifier in an IEEE 802.1Q-2014 tag [6] ",
241 required=False, allow_null=True)
242 protocol = serializers.ChoiceField(help_text="Indicates the L4 protocol",
243 choices=["TCP", "UDP", "ICMP"], required=False, allow_null=True)
244 dscp = serializers.CharField(help_text="For IPv4 [7] a string of 0 and 1 digits that corresponds to the 6-bit "
245 "Differentiated Services Code Point (DSCP) field of the IP header",
246 required=False, allow_null=True)
247 sourcePortRange = PortRangeSerializer(help_text="Indicates a range of source ports. ",
248 required=False, allow_null=True)
249 destinationPortRange = PortRangeSerializer(help_text="Indicates a range of destination ports.",
250 required=False, allow_null=True)
251 sourceIpAddressPrefix = serializers.CharField(
252 help_text="Prefix of source ip address", required=False, allow_null=True)
253 destinationIpAddressPrefix = serializers.CharField(
254 help_text="Prefix of destination ip address", required=False, allow_null=True)
255 extendedCriteria = serializers.ListField(help_text="Indicates values of specific bits in a frame.",
256 child=(MaskSerializer(help_text="Mask serializer", required=True)),
257 required=False, allow_null=True)
260 class NfpDataSerializer(serializers.Serializer):
261 nfpInfoId = serializers.CharField(help_text="Identifier of the NFP to be modified.",
262 required=False, allow_null=True)
263 nfpName = serializers.CharField(help_text="Human readable name for the NFP.", required=False, allow_null=True)
264 description = serializers.CharField(help_text="Human readable description for the NFP",
265 required=False, allow_null=True)
266 nsCpHandle = serializers.ListField(help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
267 child=(NsCpHandleSerializer(
268 help_text="This type represents an identifier of the CP or SAP instance.",
269 required=True)), required=False, allow_null=True)
270 nfpRule = NfpRuleSerializer(help_text="NFP classification and selection rule.", required=False, allow_null=True)
273 class UpdateVnffgDataSerializer(serializers.Serializer):
274 vnffgInfoId = serializers.CharField(help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
276 nfp = serializers.ListField(help_text="nfp", child=(NfpDataSerializer(help_text="This type contains information "
277 "used to create or modify NFP "
278 "instance parameters for the update"
279 "of an existing VNFFG instance. ",
281 required=False, allow_null=True)
282 nfpInfoId = serializers.ListField(help_text="Identifier(s) of the NFP to be deleted from a given VNFFG.",
283 required=False, allow_null=True)
286 class ChangeNsFlavourDataSerializer(serializers.Serializer):
287 newNsFlavourId = serializers.CharField(
288 help_text="Identifier of the new NS DF to apply to this NS instance.", required=True)
289 instantiationLevelId = serializers.CharField(
290 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
291 required=False, allow_null=True)
294 class IdentifierInPnfSerializer(serializers.Serializer):
295 IdentifierInPnf = serializers.Serializer(help_text="An Identifier that is unique within respect to a PNF.")
298 class IdentifierInNsdSerializer(serializers.Serializer):
299 IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
302 class PnfExtCpDataSerializer(serializers.Serializer):
303 cpInstanceI16 = IdentifierInPnfSerializer(help_text="Identifier of the CP. Shall be present for existing CP.",
304 required=False, allow_null=True)
305 cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
306 required=False, allow_null=True)
307 cpProtocolData = serializers.ListField(help_text="Address assigned for this CP.",
308 child=(CpProtocolDataSerializer(
309 help_text="This type represents network protocol data.", required=True)),
310 required=False, allow_null=True)
313 class AddPnfDataSerializer(serializers.Serializer):
314 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
315 pnfName = serializers.CharField(help_text="Name of the PNF.", required=True)
316 pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
317 pnfProfileId = serializers.CharField(
318 help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
319 cpData = serializers.ListField(help_text="Address assigned for the PNF external CP(s). ",
320 child=(PnfExtCpDataSerializer(
321 help_text="Serializer data of pnf ext cp", required=True)),
322 required=False, allow_null=True)
325 class ModifyPnfDataSerializer(serializers.Serializer):
326 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
327 pnfName = serializers.CharField(help_text="Name of the PNF", required=False, allow_null=True)
328 cpData = serializers.ListField(
329 help_text="Address assigned for the PNF external CP(s).",
330 child=(PnfExtCpDataSerializer(
331 help_text="This type represents the configuration data on the external CP of the PNF.")),
332 required=False, allow_null=True)
335 class DateTimeSerializer(serializers.Serializer):
336 DateTime = serializers.Serializer(help_text="Date-time stamp.")
339 class UpdateNsReqSerializer(serializers.Serializer):
340 updateType = serializers.ChoiceField(help_text="The type of update.",
341 choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
342 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
343 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
344 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
345 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
346 "MODIFY_PNF", "REMOVE_PNF"], required=True)
347 addVnfInstance = serializers.ListField(help_text="Identifies an existing VNF instance to be added to the NS "
349 child=(VnfInstanceDataSerializer(help_text="Data of vnf instance",
351 required=False, allow_null=True)
352 removeVnfInstanceId = serializers.ListField(help_text="Identifies an existing VNF instance to be removed from "
353 "the NS instance.", required=False, allow_null=True)
354 instantiateVnfData = serializers.ListField(help_text="Identifies the new VNF to be instantiated.",
355 child=(InstantiateVnfDataSerializer(help_text="Data of vnf instance",
357 required=False, allow_null=True)
358 changeVnfFlavourData = serializers.ListField(help_text="Identifies the new DF of the VNF instance to be "
360 child=(ChangeVnfFlavourDataSerizlizer(
361 help_text="The type represents the information that is requested "
362 "to be changed deployment flavour for an existing "
363 "VNF instance.", required=True)),
364 required=False, allow_null=True)
365 operateVnfData = serializers.ListField(help_text="This type represents a VNF instance for which the operational "
366 "state needs to be changed and the requested new state.",
367 child=(OperateVnfDataSerializer(
368 help_text="This type represents a VNF instance for which the operational"
369 " state needs to be changed and the requested new state",
370 required=True)), required=False, allow_null=True)
371 modifyVnfInfoData = serializers.ListField(help_text="This type represents the information that is requested to be"
372 " modified for a VNF instance. ",
373 child=(ModifyVnfInfoDataSerializer(
374 help_text="This type represents the information that is requested to "
375 "be modified for a VNF instance. ", required=True)),
376 required=False, allow_null=True)
377 changeExtVnfConnectivityData = serializers.ListField(help_text="Specifies the new external connectivity data of the"
378 "VNF instance to be changed",
379 child=(ChangeExtVnfConnectivityDataSerializer(
380 help_text="This type describes the information invoked by"
381 "the NFVO to change the external VNF "
382 "connectivity information maintained by"
383 " the VNFM.", required=True)),
384 required=False, allow_null=True)
385 addSap = serializers.ListField(help_text="Identifies a new SAP to be added to the NS instance.",
386 child=(SapDataSerializer(help_text="This type represents the information related to "
387 "a SAP of a NS", required=True)),
388 required=False, allow_null=True)
389 removeSapId = serializers.ListField(help_text="The identifier an existing SAP to be removed from the "
390 "NS instance", required=False, allow_null=True)
391 addNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to "
392 "the NS instance", required=False, allow_null=True)
393 removeNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be "
394 "removed from the NS instance.",
395 required=False, allow_null=True)
396 assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(help_text="Specify the new NSD to be used for the NS "
397 "instance.", required=False, allow_null=True)
398 moveVnfInstanceData = serializers.ListField(help_text="Specify existing VNF instance to be moved from one NS "
399 "instance to another NS instance",
400 child=(MoveVnfInstanceDataSerializer()),
401 required=False, allow_null=True)
402 addVnffg = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to the"
403 " NS instance.", required=False, allow_null=True)
404 removeVnffgId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be removed "
405 "from the NS instance", required=False, allow_null=True)
406 updateVnffg = serializers.ListField(help_text="Specify the new VNFFG Information data to be updated for a VNFFG"
407 " of the NS Instance",
408 child=(UpdateVnffgDataSerializer(help_text="This type specifies the parameters "
409 "used for the update of an existing "
410 "VNFFG instance.", required=True)),
411 required=False, allow_null=True)
412 changeNsFlavourData = ChangeNsFlavourDataSerializer(
413 help_text="Specifies the new DF to be applied to the NS instance", required=False, allow_null=True)
414 addPnfData = serializers.ListField(help_text="Specifies the PNF to be added into the NS instance.",
415 child=(AddPnfDataSerializer(help_text="Serializer data of add pnf", required=True)),
416 required=False, allow_null=True)
417 modifyPnfData = serializers.ListField(help_text="Specifies the PNF to be modified in the NS instance.",
418 child=(ModifyPnfDataSerializer(
419 help_text="This type specifies an PNF to be modified in the NS instance.",
421 required=False, allow_null=True)
422 removePnfId = serializers.ListField(help_text="Identifier of the PNF to be deleted from the NS instance.",
423 required=False, allow_null=True)
424 updateTime = DateTimeSerializer(help_text="Timestamp indicating the update time of the NS",
425 required=False, allow_null=True)