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.sol.resource_handle import ResourceHandleSerializer
18 from lcm.ns.serializers.sol.ns_instance import NsCpHandleSerializer, NfpRuleSerializer
19 from lcm.ns.serializers.sol.cp_serializers import CpProtocolDataSerializer
20 from lcm.ns.serializers.sol.cp_serializers import IpAddressesDataSerialzier
23 class VnfInstanceDataSerializer(serializers.Serializer):
24 vnfInstanceId = serializers.CharField(
25 help_text="Specify the target NS instance where the VNF instances are moved to",
27 vnfProfileId = serializers.CharField(
28 help_text="Specify the VNF instance that is moved.",
33 class InstantiateVnfDataSerializer(serializers.Serializer):
34 vnfdId = serializers.CharField(
35 help_text="Information sufficient to identify the VNFD which defines the VNF to be instantiated.",
37 vnfFlavourId = serializers.CharField(
38 help_text="Identifier of the VNF deployment flavour to be instantiated.",
40 vnfInstantiationLevelId = serializers.CharField(
41 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
44 vnfInstanceName = serializers.CharField(
45 help_text="Human-readable name of the VNF instance to be created.",
50 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
51 macAddress = serializers.CharField(
52 help_text="Mac address",
55 ipAddresses = IpAddressesDataSerialzier(
56 help_text="List of IP addresses to assign to the extCP instance.",
62 class VnfExtCpConfigSerializer(serializers.Serializer):
63 cpInstanceId = serializers.CharField(
64 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
67 linkPortId = serializers.CharField(
68 help_text="Identifier of a pre-conFigured link port to which the external CP will be associated.",
71 cpProtocolData = serializers.ListField(
72 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL",
73 child=CpProtocolDataSerializer(
74 help_text="This type represents network protocol data.",
80 class VnfExtCpData(serializers.Serializer):
81 cpdId = serializers.CharField(
82 help_text="The identifier of the CPD in the VNFD.",
84 cpConfig = serializers.ListField(
85 help_text="List of instance data that need to be conFigured on the CP instances created from the respective CPD.",
86 child=(VnfExtCpConfigSerializer(
87 help_text="Config of vnf ext cp",
93 class ExtLinkPortDataSerializer(serializers.Serializer):
94 id = serializers.CharField(
95 help_text="Provided by the entity that has created the link port.",
97 resourceHandle = ResourceHandleSerializer(
98 help_text="Identifier(s) of the virtualised network resource(s) realizing the VL instance.",
102 class ExtVirtualLinkDataSerializer(serializers.Serializer):
103 extVirtualLinkId = serializers.CharField(
104 help_text="The identifier of the external VL instance, if provided.",
107 vimId = serializers.CharField(
108 help_text="Identifier of the VIM that manages this resource.",
111 resourceProviderId = serializers.CharField(
112 help_text="Identifies the entity responsible for the management of this resource.",
115 resourceId = serializers.CharField(
116 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
118 extCps = serializers.ListField(
119 help_text="External CPs of the VNF to be connected to this external VL.",
120 child=VnfExtCpData(),
123 extLinkPorts = serializers.ListField(
124 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
125 child=(ExtLinkPortDataSerializer(
126 help_text="This type represents an externally provided link port to be used to connect a VNF external connection point to an external VL",
132 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
133 extManagedVirtualLinkId = serializers.CharField(
134 help_text="The identifier of the externally-managed internal VL instance,if provided.",
137 virtualLinkDescId = serializers.CharField(
138 help_text="The identifier of the VLD in the VNFD for this VL.",
140 vimId = serializers.CharField(
141 help_text="Identifier of the VIMthat manage this resource.",
144 resourceProviderId = serializers.CharField(
145 help_text="Identifies the entity responsible for the management of this resource.",
148 resourceId = serializers.CharField(
149 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
153 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
154 vnfInstanceId = serializers.CharField(
155 help_text="Identifier of the VNF instance to be modified.",
157 newFlavourId = serializers.CharField(
158 help_text="Identifier of the VNF deployment flavour to be instantiated.",
160 instantiationLevelId = serializers.CharField(
161 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
164 extVirtualLinks = serializers.ListField(
165 help_text="Information about external VLs to connect the VNF to.",
166 child=ExtVirtualLinkDataSerializer(
167 help_text="This type represents an external VL",
171 extManagedVirtualLinks = serializers.ListField(
172 help_text="Information about internal VLs that are managed by NFVO.",
173 child=ExtManagedVirtualLinkDataSerializer(
174 help_text="This type represents an externally-managed internal VL.",
178 additionalParams = serializers.CharField(
179 help_text="Additional input parameters for the flavour change process",
184 class OperationalStatesSerializer(serializers.Serializer):
185 OperationalStates = serializers.ChoiceField(
186 help_text="State of operation",
187 choices=["STARTED", "STOPPED"])
190 class StopTypeSerializer(serializers.Serializer):
191 StopType = serializers.ChoiceField(
192 help_text="Type of stop",
193 choices=["FORCEFUL", "GRACEFUL"])
196 class OperateVnfDataSerializer(serializers.Serializer):
197 vnfInstanceId = serializers.CharField(
198 help_text="Identifier of the VNF instance.",
200 changeStateTo = OperationalStatesSerializer(
201 help_text="The desired operational state to change the VNF to.",
203 stopType = StopTypeSerializer(
204 help_text="It signals whether forceful or graceful stop is requested.",
207 gracefulStopTimeout = serializers.CharField(
208 help_text="The time interval to wait for the VNF to be taken out of service during graceful stop.",
213 class ModifyVnfInfoDataSerializer(serializers.Serializer):
214 vnfInstanceId = serializers.UUIDField(
215 help_text="Identifier of the VNF instance."
217 vnfInstanceName = serializers.CharField(
218 help_text="New value of the 'vnfInstanceName' attribute in 'VnfInstance', or 'null' to remove the attribute.",
223 vnfInstanceDescription = serializers.CharField(
224 help_text="If present, this attribute signals modifications of the 'vnfInstanceDescription' attribute in 'VnfInstance'",
228 vnfPkgId = serializers.UUIDField(
229 help_text="New value of the 'vnfPkgId' attribute in 'VnfInstance' The value 'null' is not permitted.."
231 vnfConfigurableProperties = serializers.DictField(
232 help_text="Modifications to entries in the 'vnfConfigurableProperties' list, as defined below this Table.",
233 child=serializers.CharField(
234 help_text="KeyValue Pairs",
238 metaData = serializers.DictField(
239 help_text="If present, this attribute signals modifications of certain 'metadata' attribute in 'vnfInstance'.",
240 child=serializers.CharField(
241 help_text="KeyValue Pairs",
245 extensions = serializers.DictField(
246 help_text="If present,this attribute signals modifications of certain 'extensions' attribute in 'vnfInstance'.",
247 child=serializers.CharField(
248 help_text="KeyValue Pairs",
254 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
255 vnfInstanceId = serializers.CharField(
256 help_text="Identifier of the VNF instance.",
259 extVirtualLinks = serializers.ListField(
260 help_text="Information about external VLs to change",
261 child=ExtVirtualLinkDataSerializer(
262 help_text="Data of ext virtual link",
266 additionalParams = serializers.CharField(
267 help_text="Additional parameters passed by the OSS as input to the external connectivity change process",
272 class SapDataSerializer(serializers.Serializer):
273 sapdId = serializers.CharField(
274 help_text="Reference to the SAPD for this SAP.",
276 sapName = serializers.CharField(
277 help_text="Human readable name for the SAP.",
279 description = serializers.CharField(
280 help_text="Human readable description for the SAP. ",
282 sapProtocolData = serializers.ListField(
283 help_text="Parameters for configuring the network protocols on the SAP.",
284 child=CpProtocolDataSerializer(
285 help_text="This type represents network protocol data.",
291 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
292 newNsdId = serializers.CharField(
293 help_text="Identifier of the new NSD version that is to be associated to the NS instance.",
297 class MoveVnfInstanceDataSerializer(serializers.Serializer):
298 targetNsInstanceId = serializers.CharField(
299 help_text="Specify the target NS instance where the VNF instances are moved to.",
301 vnfInstanceId = serializers.CharField(
302 help_text="Specify the VNF instance that is moved.",
307 class PortRangeSerializer(serializers.Serializer):
308 lowerPort = serializers.CharField(
309 help_text="Identifies the lower bound of the port range.",
311 upperPort = serializers.CharField(
312 help_text="Identifies the upper bound of the port range ",
316 class NfpDataSerializer(serializers.Serializer):
317 nfpInfoId = serializers.CharField(
318 help_text="Identifier of the NFP to be modified.",
321 nfpName = serializers.CharField(
322 help_text="Human readable name for the NFP.",
325 description = serializers.CharField(
326 help_text="Human readable description for the NFP.",
329 nsCpHandle = serializers.ListField(
330 help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
331 child=NsCpHandleSerializer(
332 help_text="This type represents an identifier of the CP or SAP instance.",
336 nfpRule = NfpRuleSerializer(
337 help_text="NFP classification and selection rule.",
342 class UpdateVnffgDataSerializer(serializers.Serializer):
343 vnffgInfoId = serializers.CharField(
344 help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
346 nfp = serializers.ListField(
347 help_text="Indicate the desired new NFP(s) for a given VNFFG after the operations of addition/removal of NS components (e.g. VNFs, VLs, etc.) have been completed, or indicate the updated or newly created NFP classification and selection rule which applied to an existing NFP.",
348 child=NfpDataSerializer(),
351 nfpInfoId = serializers.ListField(
352 help_text="Identifiers of the NFP to be deleted from a given VNFFG.",
353 child=serializers.CharField(help_text="Identifier of the NFP to be deleted from a given VNFFG."),
358 class ChangeNsFlavourDataSerializer(serializers.Serializer):
359 newNsFlavourId = serializers.CharField(
360 help_text="Identifier of the new NS DF to apply to this NS instance.",
362 instantiationLevelId = serializers.CharField(
363 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
368 # class IdentifierInPnfSerializer(serializers.Serializer):
369 # IdentifierInPnf = serializers.Serializer(
370 # help_text="An Identifier that is unique within respect to a PNF.")
373 # class IdentifierInNsdSerializer(serializers.Serializer):
374 # IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
377 class PnfExtCpDataSerializer(serializers.Serializer):
378 cpInstanceId = serializers.CharField( # sol 2.05.01 cpInstanceI16 typo
379 help_text="Identifier of the CP. Shall be present for existing CP.",
382 cpdId = serializers.CharField(
383 help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
384 required=False, allow_null=True)
385 cpProtocolData = CpProtocolDataSerializer(
386 help_text="Address assigned for this CP.",
392 class AddPnfDataSerializer(serializers.Serializer):
393 pnfId = serializers.CharField(
394 help_text="Identifier of the PNF.",
396 pnfName = serializers.CharField(
397 help_text="Name of the PNF.",
399 pnfdId = serializers.CharField(
400 help_text="Identifier of the PNFD on which the PNF is based.",
402 pnfProfileId = serializers.CharField(
403 help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.",
405 cpData = PnfExtCpDataSerializer(
406 help_text="Address assigned for the PNF external CP(s).",
412 class ModifyPnfDataSerializer(serializers.Serializer):
413 pnfId = serializers.CharField(
414 help_text="Identifier of the PNF.",
416 pnfName = serializers.CharField(
417 help_text="Name of the PNF",
420 cpData = serializers.ListField(
421 help_text="Address assigned for the PNF external CP(s).",
422 child=PnfExtCpDataSerializer(
423 help_text="This type represents the configuration data on the external CP of the PNF."),
428 # class DateTimeSerializer(serializers.Serializer):
429 # DateTime = serializers.Serializer(help_text="Date-time stamp.")
432 class UpdateNsReqSerializer(serializers.Serializer):
433 updateType = serializers.ChoiceField(
434 help_text="The type of update.",
435 choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
436 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
437 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
438 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
439 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
440 "MODIFY_PNF", "REMOVE_PNF"],
442 addVnfInstance = serializers.ListField(
443 help_text="Identifies an existing VNF instance to be added to the NS instance.",
444 child=VnfInstanceDataSerializer(
445 help_text="Data of vnf instance",
449 removeVnfInstanceId = serializers.ListField(
450 help_text="Identifies an existing VNF instance to be removed from the NS instance.",
451 child=serializers.CharField(),
454 instantiateVnfData = serializers.ListField(
455 help_text="Identifies the new VNF to be instantiated.",
456 child=(InstantiateVnfDataSerializer(
457 help_text="Data of vnf instance.",
461 changeVnfFlavourData = serializers.ListField(
462 help_text="Identifies the new DF of the VNF instance to be changed to.",
463 child=(ChangeVnfFlavourDataSerizlizer(
464 help_text="The type represents the information that is requested to be changed deployment flavour for an existing VNF instance.",
468 operateVnfData = serializers.ListField(
469 help_text="This type represents a VNF instance for which the operational state needs to be changed and the requested new state.",
470 child=(OperateVnfDataSerializer(
471 help_text="This type represents a VNF instance for which the operational state needs to be changed and the requested new state",
475 modifyVnfInfoData = serializers.ListField(
476 help_text="This type represents the information that is requested to be modified for a VNF instance. ",
477 child=(ModifyVnfInfoDataSerializer(
478 help_text="This type represents the information that is requested to be modified for a VNF instance. ",
482 changeExtVnfConnectivityData = serializers.ListField(
483 help_text="Specifies the new external connectivity datas of the VNF instance to be changed.",
484 child=ChangeExtVnfConnectivityDataSerializer(
485 help_text="This type describes the information invoked by the NFVO to change the external VNF connectivity information maintained by the VNFM.",
489 addSap = serializers.ListField(
490 help_text="Identifies a new SAP to be added to the NS instance.",
491 child=SapDataSerializer(help_text="This type represents the information related to a SAP of a NS",
495 removeSapId = serializers.ListField(
496 help_text="The identifier an existing SAP to be removed from the NS instance",
499 addNestedNsId = serializers.ListField(
500 help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
503 removeNestedNsId = serializers.ListField(
504 help_text="The identifier of an existing nested NS instance to be removed from the NS instance.",
507 assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(
508 help_text="Specify the new NSD to be used for the NS instance.",
511 moveVnfInstanceData = serializers.ListField(
512 help_text="Specify existing VNF instance to be moved from one NS instance to another NS instance",
513 child=MoveVnfInstanceDataSerializer(),
516 addVnffg = serializers.ListField(
517 help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
520 removeVnffgId = serializers.ListField(
521 help_text="The identifier of an existing nested NS instance to be removed from the NS instance",
522 child=serializers.CharField(),
525 updateVnffg = serializers.ListField(
526 help_text="Specify the new VNFFG Information data to be updated for a VNFFG of the NS Instance.",
527 child=UpdateVnffgDataSerializer(
528 help_text="This type specifies the parameters used for the update of an existing VNFFG instance.",
532 changeNsFlavourData = ChangeNsFlavourDataSerializer(
533 help_text="Specifies the new DF to be applied to the NS instance.",
536 addPnfData = serializers.ListField(
537 help_text="Specifies the PNF to be added into the NS instance.",
538 child=AddPnfDataSerializer(
539 help_text="Serializer data of add PNF",
543 modifyPnfData = serializers.ListField(
544 help_text="Specifies the PNF to be modified in the NS instance.",
545 child=ModifyPnfDataSerializer(
546 help_text="This type specifies an PNF to be modified in the NS instance.",
550 removePnfId = serializers.ListField(
551 help_text="Identifier of the PNF to be deleted from the NS instance.",
554 updateTime = serializers.CharField(
555 help_text="Timestamp indicating the update time of the NS",