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
15 from lcm.ns.serializers.ns_serializers import IpAddress
18 class VnfInstanceDataSerializer(serializers.Serializer):
19 vnfInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances are "
20 "moved to", required=True)
21 vnfProfileId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
22 required=False, allow_null=True)
25 class InstantiateVnfDataSerializer(serializers.Serializer):
26 vnfdId = serializers.CharField(help_text="Information sufficient to identify the VNFD which defines the VNF to be"
27 " instantiated. ", required=True)
28 vnfFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
30 vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
31 "flavour to be instantiated. ", required=False,
33 vnfInstanceName = serializers.CharField(help_text="Human-readable name of the VNF instance to be created.",
34 required=False, allow_null=True)
37 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
38 macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
39 ipAddresses = serializers.ListField(help_text="List of IP addresses to assign to the extCP instance.", child=IpAddress(help_text="IP addresses to assign to the extCP instance.", required=False), 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(child=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 OperateVnfDataSerializer(serializers.Serializer):
150 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
151 changeStateTo = OperationalStatesSerializer(help_text="The desired operational state to change the VNF to.",
153 stopType = serializers.ChoiceField(help_text="It signals whether forceful or graceful stop is requested.",
154 choices=["FORCEFUL", "GRACEFUL"], required=False, allow_null=True)
155 gracefulStopTimeout = serializers.CharField(help_text="The time interval to wait for the VNF to be taken out of"
156 "service during graceful stop.",
157 required=False, allow_null=True)
160 class ModifyVnfInfoDataSerializer(serializers.Serializer):
161 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance", required=True)
162 vnfInstanceName = serializers.CharField(help_text="New value of the vnfInstanceName attribute in VnfInstance",
163 required=False, allow_null=True)
164 vnfInstanceDescription = serializers.CharField(help_text="New value of the vnfInstanceDescription attribute in"
165 "VnfInstance", required=False, allow_null=True)
168 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
169 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True, allow_null=True)
170 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to change",
171 child=(ExtVirtualLinkDataSerializer(
172 help_text="Data of ext virtual link", required=True)),
173 required=False, allow_null=True)
174 additionalParams = serializers.CharField(help_text="Additional parameters passed by the OSS as input to the "
175 "external connectivity change process",
176 required=False, allow_null=True)
179 class SapDataSerializer(serializers.Serializer):
180 sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
181 sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
182 description = serializers.CharField(help_text="Human readable description for the SAP. ", required=True)
183 sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the SAP.",
184 child=(CpProtocolDataSerializer(
185 help_text="This type represents network protocol data.", required=True)),
186 required=False, allow_null=True)
189 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
190 newNsdId = serializers.CharField(help_text="Identifier of the new NSD version that is to be associated to the NS "
191 "instance. ", required=True)
194 class MoveVnfInstanceDataSerializer(serializers.Serializer):
195 targetNsInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances "
196 "are moved to.", required=True)
197 vnfInstanceId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
198 required=False, allow_null=True)
201 class NsCpHandleSerializer(serializers.Serializer):
202 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated to the CP instance.",
203 required=False, allow_null=True)
204 vnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the VNF external CP instance in the scope "
205 "of the VNF instance. ", required=False, allow_null=True)
206 pnfInfoId = serializers.CharField(help_text="Identifier of the PNF instance associated to the CP instance.",
207 required=False, allow_null=True)
208 pnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the PNF external CP instance in the scope "
209 "of the PNF.", required=False, allow_null=True)
210 nsInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated to the SAP instance.",
211 required=False, allow_null=True)
212 nsSapInstanceId = serializers.CharField(help_text="Identifier of the SAP instance in the scope of the NS instance",
213 required=False, allow_null=True)
216 class PortRangeSerializer(serializers.Serializer):
217 lowerPort = serializers.CharField(help_text="Identifies the lower bound of the port range. ", required=True)
218 upperPort = serializers.CharField(help_text="Identifies the upper bound of the port range ", required=True)
221 class MaskSerializer(serializers.Serializer):
222 startingPoint = serializers.CharField(help_text="Indicates the offset between the last bit of the source mac "
223 "address and the first bit of the sequence of bits to "
224 "be matched.", required=True)
225 length = serializers.CharField(help_text="Indicates the number of bits to be matched. ", required=True)
226 value = serializers.CharField(help_text="Provide the sequence of bit values to be matched. ", required=True)
229 class NfpRuleSerializer(serializers.Serializer):
230 etherDestinationAddress = serializers.CharField(help_text="Indicates a destination Mac address ",
231 required=False, allow_null=True)
232 etherSourceAddress = serializers.CharField(help_text="Indicates a source Mac address",
233 required=False, allow_null=True)
234 etherType = serializers.ChoiceField(help_text="Indicates the protocol carried over the Ethernet layer.",
235 choices=["IPV4", "IPV6"], required=False, allow_null=True)
236 vlanTag = serializers.CharField(help_text="Indicates a VLAN identifier in an IEEE 802.1Q-2014 tag [6] ",
237 required=False, allow_null=True)
238 protocol = serializers.ChoiceField(help_text="Indicates the L4 protocol",
239 choices=["TCP", "UDP", "ICMP"], required=False, allow_null=True)
240 dscp = serializers.CharField(help_text="For IPv4 [7] a string of 0 and 1 digits that corresponds to the 6-bit "
241 "Differentiated Services Code Point (DSCP) field of the IP header",
242 required=False, allow_null=True)
243 sourcePortRange = PortRangeSerializer(help_text="Indicates a range of source ports. ",
244 required=False, allow_null=True)
245 destinationPortRange = PortRangeSerializer(help_text="Indicates a range of destination ports.",
246 required=False, allow_null=True)
247 sourceIpAddressPrefix = serializers.CharField(
248 help_text="Prefix of source ip address", required=False, allow_null=True)
249 destinationIpAddressPrefix = serializers.CharField(
250 help_text="Prefix of destination ip address", required=False, allow_null=True)
251 extendedCriteria = serializers.ListField(help_text="Indicates values of specific bits in a frame.",
252 child=(MaskSerializer(help_text="Mask serializer", required=True)),
253 required=False, allow_null=True)
256 class NfpDataSerializer(serializers.Serializer):
257 nfpInfoId = serializers.CharField(help_text="Identifier of the NFP to be modified.",
258 required=False, allow_null=True)
259 nfpName = serializers.CharField(help_text="Human readable name for the NFP.", required=False, allow_null=True)
260 description = serializers.CharField(help_text="Human readable description for the NFP",
261 required=False, allow_null=True)
262 nsCpHandle = serializers.ListField(help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
263 child=(NsCpHandleSerializer(
264 help_text="This type represents an identifier of the CP or SAP instance.",
265 required=True)), required=False, allow_null=True)
266 nfpRule = NfpRuleSerializer(help_text="NFP classification and selection rule.", required=False, allow_null=True)
269 class UpdateVnffgDataSerializer(serializers.Serializer):
270 vnffgInfoId = serializers.CharField(help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
272 nfp = serializers.ListField(help_text="nfp", child=(NfpDataSerializer(help_text="This type contains information "
273 "used to create or modify NFP "
274 "instance parameters for the update"
275 "of an existing VNFFG instance. ",
277 required=False, allow_null=True)
278 nfpInfoId = serializers.ListField(help_text="Identifier(s) of the NFP to be deleted from a given VNFFG.",
279 required=False, allow_null=True)
282 class ChangeNsFlavourDataSerializer(serializers.Serializer):
283 newNsFlavourId = serializers.CharField(
284 help_text="Identifier of the new NS DF to apply to this NS instance.", required=True)
285 instantiationLevelId = serializers.CharField(
286 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
287 required=False, allow_null=True)
290 class IdentifierInPnfSerializer(serializers.Serializer):
291 IdentifierInPnf = serializers.Serializer(help_text="An Identifier that is unique within respect to a PNF.")
294 class IdentifierInNsdSerializer(serializers.Serializer):
295 IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
298 class PnfExtCpDataSerializer(serializers.Serializer):
299 cpInstanceI16 = IdentifierInPnfSerializer(help_text="Identifier of the CP. Shall be present for existing CP.",
300 required=False, allow_null=True)
301 cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
302 required=False, allow_null=True)
303 cpProtocolData = serializers.ListField(help_text="Address assigned for this CP.",
304 child=(CpProtocolDataSerializer(
305 help_text="This type represents network protocol data.", required=True)),
306 required=False, allow_null=True)
309 class AddPnfDataSerializer(serializers.Serializer):
310 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
311 pnfName = serializers.CharField(help_text="Name of the PNF.", required=True)
312 pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
313 pnfProfileId = serializers.CharField(
314 help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
315 cpData = serializers.ListField(help_text="Address assigned for the PNF external CP(s). ",
316 child=(PnfExtCpDataSerializer(
317 help_text="Serializer data of pnf ext cp", required=True)),
318 required=False, allow_null=True)
321 class ModifyPnfDataSerializer(serializers.Serializer):
322 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
323 pnfName = serializers.CharField(help_text="Name of the PNF", required=False, allow_null=True)
324 cpData = serializers.ListField(
325 help_text="Address assigned for the PNF external CP(s).",
326 child=(PnfExtCpDataSerializer(
327 help_text="This type represents the configuration data on the external CP of the PNF.")),
328 required=False, allow_null=True)
331 class DateTimeSerializer(serializers.Serializer):
332 DateTime = serializers.Serializer(help_text="Date-time stamp.")
335 class UpdateNsReqSerializer(serializers.Serializer):
336 updateType = serializers.ChoiceField(help_text="The type of update.",
337 choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
338 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
339 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
340 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
341 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
342 "MODIFY_PNF", "REMOVE_PNF"], required=True)
343 addVnfInstance = serializers.ListField(help_text="Identifies an existing VNF instance to be added to the NS "
345 child=(VnfInstanceDataSerializer(help_text="Data of vnf instance",
347 required=False, allow_null=True)
348 removeVnfInstanceId = serializers.ListField(help_text="Identifies an existing VNF instance to be removed from "
349 "the NS instance.", required=False, allow_null=True)
350 instantiateVnfData = serializers.ListField(help_text="Identifies the new VNF to be instantiated.",
351 child=(InstantiateVnfDataSerializer(help_text="Data of vnf instance",
353 required=False, allow_null=True)
354 changeVnfFlavourData = serializers.ListField(help_text="Identifies the new DF of the VNF instance to be "
356 child=(ChangeVnfFlavourDataSerizlizer(
357 help_text="The type represents the information that is requested "
358 "to be changed deployment flavour for an existing "
359 "VNF instance.", required=True)),
360 required=False, allow_null=True)
361 operateVnfData = serializers.ListField(help_text="This type represents a VNF instance for which the operational "
362 "state needs to be changed and the requested new state.",
363 child=(OperateVnfDataSerializer(
364 help_text="This type represents a VNF instance for which the operational"
365 " state needs to be changed and the requested new state",
366 required=True)), required=False, allow_null=True)
367 modifyVnfInfoData = serializers.ListField(help_text="This type represents the information that is requested to be"
368 " modified for a VNF instance. ",
369 child=(ModifyVnfInfoDataSerializer(
370 help_text="This type represents the information that is requested to "
371 "be modified for a VNF instance. ", required=True)),
372 required=False, allow_null=True)
373 changeExtVnfConnectivityData = serializers.ListField(help_text="Specifies the new external connectivity data of the"
374 "VNF instance to be changed",
375 child=(ChangeExtVnfConnectivityDataSerializer(
376 help_text="This type describes the information invoked by"
377 "the NFVO to change the external VNF "
378 "connectivity information maintained by"
379 " the VNFM.", required=True)),
380 required=False, allow_null=True)
381 addSap = serializers.ListField(help_text="Identifies a new SAP to be added to the NS instance.",
382 child=(SapDataSerializer(help_text="This type represents the information related to "
383 "a SAP of a NS", required=True)),
384 required=False, allow_null=True)
385 removeSapId = serializers.ListField(help_text="The identifier an existing SAP to be removed from the "
386 "NS instance", required=False, allow_null=True)
387 addNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to "
388 "the NS instance", required=False, allow_null=True)
389 removeNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be "
390 "removed from the NS instance.",
391 required=False, allow_null=True)
392 assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(help_text="Specify the new NSD to be used for the NS "
393 "instance.", required=False, allow_null=True)
394 moveVnfInstanceData = serializers.ListField(help_text="Specify existing VNF instance to be moved from one NS "
395 "instance to another NS instance",
396 child=(MoveVnfInstanceDataSerializer()),
397 required=False, allow_null=True)
398 addVnffg = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to the"
399 " NS instance.", required=False, allow_null=True)
400 removeVnffgId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be removed "
401 "from the NS instance", required=False, allow_null=True)
402 updateVnffg = serializers.ListField(help_text="Specify the new VNFFG Information data to be updated for a VNFFG"
403 " of the NS Instance",
404 child=(UpdateVnffgDataSerializer(help_text="This type specifies the parameters "
405 "used for the update of an existing "
406 "VNFFG instance.", required=True)),
407 required=False, allow_null=True)
408 changeNsFlavourData = ChangeNsFlavourDataSerializer(
409 help_text="Specifies the new DF to be applied to the NS instance", required=False, allow_null=True)
410 addPnfData = serializers.ListField(help_text="Specifies the PNF to be added into the NS instance.",
411 child=(AddPnfDataSerializer(help_text="Serializer data of add pnf", required=True)),
412 required=False, allow_null=True)
413 modifyPnfData = serializers.ListField(help_text="Specifies the PNF to be modified in the NS instance.",
414 child=(ModifyPnfDataSerializer(
415 help_text="This type specifies an PNF to be modified in the NS instance.",
417 required=False, allow_null=True)
418 removePnfId = serializers.ListField(help_text="Identifier of the PNF to be deleted from the NS instance.",
419 required=False, allow_null=True)
420 updateTime = DateTimeSerializer(help_text="Timestamp indicating the update time of the NS",
421 required=False, allow_null=True)