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
21 from lcm.ns.enum import OPERATIONAL_STATE, STOP_TYPE
22 from lcm.pub.utils.enumutil import enum_to_list
25 class VnfInstanceDataSerializer(serializers.Serializer):
26 vnfInstanceId = serializers.CharField(
27 help_text="Specify the target NS instance where the VNF instances are moved to",
29 vnfProfileId = serializers.CharField(
30 help_text="Specify the VNF instance that is moved.",
35 class InstantiateVnfDataSerializer(serializers.Serializer):
36 vnfdId = serializers.CharField(
37 help_text="Information sufficient to identify the VNFD which defines the VNF to be instantiated.",
39 vnfFlavourId = serializers.CharField(
40 help_text="Identifier of the VNF deployment flavour to be instantiated.",
42 vnfInstantiationLevelId = serializers.CharField(
43 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
46 vnfInstanceName = serializers.CharField(
47 help_text="Human-readable name of the VNF instance to be created.",
52 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
53 macAddress = serializers.CharField(
54 help_text="Mac address",
57 ipAddresses = IpAddressesDataSerialzier(
58 help_text="List of IP addresses to assign to the extCP instance.",
64 class VnfExtCpConfigSerializer(serializers.Serializer):
65 cpInstanceId = serializers.CharField(
66 help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
69 linkPortId = serializers.CharField(
70 help_text="Identifier of a pre-conFigured link port to which the external CP will be associated.",
73 cpProtocolData = serializers.ListField(
74 help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL",
75 child=CpProtocolDataSerializer(
76 help_text="This type represents network protocol data.",
82 class VnfExtCpData(serializers.Serializer):
83 cpdId = serializers.CharField(
84 help_text="The identifier of the CPD in the VNFD.",
86 cpConfig = serializers.ListField(
87 help_text="List of instance data that need to be conFigured on the CP instances created from the respective CPD.",
88 child=(VnfExtCpConfigSerializer(
89 help_text="Config of vnf ext cp",
95 class ExtLinkPortDataSerializer(serializers.Serializer):
96 id = serializers.CharField(
97 help_text="Provided by the entity that has created the link port.",
99 resourceHandle = ResourceHandleSerializer(
100 help_text="Identifier(s) of the virtualised network resource(s) realizing the VL instance.",
104 class ExtVirtualLinkDataSerializer(serializers.Serializer):
105 extVirtualLinkId = serializers.CharField(
106 help_text="The identifier of the external VL instance, if provided.",
109 vimId = serializers.CharField(
110 help_text="Identifier of the VIM that manages this resource.",
113 resourceProviderId = serializers.CharField(
114 help_text="Identifies the entity responsible for the management of this resource.",
117 resourceId = serializers.CharField(
118 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
120 extCps = serializers.ListField(
121 help_text="External CPs of the VNF to be connected to this external VL.",
122 child=VnfExtCpData(),
125 extLinkPorts = serializers.ListField(
126 help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
127 child=(ExtLinkPortDataSerializer(
128 help_text="This type represents an externally provided link port to be used to connect a VNF external connection point to an external VL",
134 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
135 extManagedVirtualLinkId = serializers.CharField(
136 help_text="The identifier of the externally-managed internal VL instance,if provided.",
139 virtualLinkDescId = serializers.CharField(
140 help_text="The identifier of the VLD in the VNFD for this VL.",
142 vimId = serializers.CharField(
143 help_text="Identifier of the VIMthat manage this resource.",
146 resourceProviderId = serializers.CharField(
147 help_text="Identifies the entity responsible for the management of this resource.",
150 resourceId = serializers.CharField(
151 help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
155 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
156 vnfInstanceId = serializers.CharField(
157 help_text="Identifier of the VNF instance to be modified.",
159 newFlavourId = serializers.CharField(
160 help_text="Identifier of the VNF deployment flavour to be instantiated.",
162 instantiationLevelId = serializers.CharField(
163 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
166 extVirtualLinks = serializers.ListField(
167 help_text="Information about external VLs to connect the VNF to.",
168 child=ExtVirtualLinkDataSerializer(
169 help_text="This type represents an external VL",
173 extManagedVirtualLinks = serializers.ListField(
174 help_text="Information about internal VLs that are managed by NFVO.",
175 child=ExtManagedVirtualLinkDataSerializer(
176 help_text="This type represents an externally-managed internal VL.",
180 additionalParams = serializers.CharField(
181 help_text="Additional input parameters for the flavour change process",
186 class OperationalStatesSerializer(serializers.Serializer):
187 OperationalStates = serializers.ChoiceField(
188 help_text="State of operation",
189 choices=enum_to_list(OPERATIONAL_STATE))
192 class StopTypeSerializer(serializers.Serializer):
193 StopType = serializers.ChoiceField(
194 help_text="Type of stop",
195 choices=enum_to_list(STOP_TYPE))
198 class OperateVnfDataSerializer(serializers.Serializer):
199 vnfInstanceId = serializers.CharField(
200 help_text="Identifier of the VNF instance.",
202 changeStateTo = OperationalStatesSerializer(
203 help_text="The desired operational state to change the VNF to.",
205 stopType = StopTypeSerializer(
206 help_text="It signals whether forceful or graceful stop is requested.",
209 gracefulStopTimeout = serializers.CharField(
210 help_text="The time interval to wait for the VNF to be taken out of service during graceful stop.",
215 class ModifyVnfInfoDataSerializer(serializers.Serializer):
216 vnfInstanceId = serializers.UUIDField(
217 help_text="Identifier of the VNF instance."
219 vnfInstanceName = serializers.CharField(
220 help_text="New value of the 'vnfInstanceName' attribute in 'VnfInstance', or 'null' to remove the attribute.",
225 vnfInstanceDescription = serializers.CharField(
226 help_text="If present, this attribute signals modifications of the 'vnfInstanceDescription' attribute in 'VnfInstance'",
230 vnfPkgId = serializers.UUIDField(
231 help_text="New value of the 'vnfPkgId' attribute in 'VnfInstance' The value 'null' is not permitted.."
233 vnfConfigurableProperties = serializers.DictField(
234 help_text="Modifications to entries in the 'vnfConfigurableProperties' list, as defined below this Table.",
235 child=serializers.CharField(
236 help_text="KeyValue Pairs",
240 metaData = serializers.DictField(
241 help_text="If present, this attribute signals modifications of certain 'metadata' attribute in 'vnfInstance'.",
242 child=serializers.CharField(
243 help_text="KeyValue Pairs",
247 extensions = serializers.DictField(
248 help_text="If present,this attribute signals modifications of certain 'extensions' attribute in 'vnfInstance'.",
249 child=serializers.CharField(
250 help_text="KeyValue Pairs",
256 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
257 vnfInstanceId = serializers.CharField(
258 help_text="Identifier of the VNF instance.",
261 extVirtualLinks = serializers.ListField(
262 help_text="Information about external VLs to change",
263 child=ExtVirtualLinkDataSerializer(
264 help_text="Data of ext virtual link",
268 additionalParams = serializers.CharField(
269 help_text="Additional parameters passed by the OSS as input to the external connectivity change process",
274 class SapDataSerializer(serializers.Serializer):
275 sapdId = serializers.CharField(
276 help_text="Reference to the SAPD for this SAP.",
278 sapName = serializers.CharField(
279 help_text="Human readable name for the SAP.",
281 description = serializers.CharField(
282 help_text="Human readable description for the SAP. ",
284 sapProtocolData = serializers.ListField(
285 help_text="Parameters for configuring the network protocols on the SAP.",
286 child=CpProtocolDataSerializer(
287 help_text="This type represents network protocol data.",
293 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
294 newNsdId = serializers.CharField(
295 help_text="Identifier of the new NSD version that is to be associated to the NS instance.",
299 class MoveVnfInstanceDataSerializer(serializers.Serializer):
300 targetNsInstanceId = serializers.CharField(
301 help_text="Specify the target NS instance where the VNF instances are moved to.",
303 vnfInstanceId = serializers.CharField(
304 help_text="Specify the VNF instance that is moved.",
309 class PortRangeSerializer(serializers.Serializer):
310 lowerPort = serializers.CharField(
311 help_text="Identifies the lower bound of the port range.",
313 upperPort = serializers.CharField(
314 help_text="Identifies the upper bound of the port range ",
318 class NfpDataSerializer(serializers.Serializer):
319 nfpInfoId = serializers.CharField(
320 help_text="Identifier of the NFP to be modified.",
323 nfpName = serializers.CharField(
324 help_text="Human readable name for the NFP.",
327 description = serializers.CharField(
328 help_text="Human readable description for the NFP.",
331 nsCpHandle = serializers.ListField(
332 help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
333 child=NsCpHandleSerializer(
334 help_text="This type represents an identifier of the CP or SAP instance.",
338 nfpRule = NfpRuleSerializer(
339 help_text="NFP classification and selection rule.",
344 class UpdateVnffgDataSerializer(serializers.Serializer):
345 vnffgInfoId = serializers.CharField(
346 help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
348 nfp = serializers.ListField(
349 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.",
350 child=NfpDataSerializer(),
353 nfpInfoId = serializers.ListField(
354 help_text="Identifiers of the NFP to be deleted from a given VNFFG.",
355 child=serializers.CharField(help_text="Identifier of the NFP to be deleted from a given VNFFG."),
360 class ChangeNsFlavourDataSerializer(serializers.Serializer):
361 newNsFlavourId = serializers.CharField(
362 help_text="Identifier of the new NS DF to apply to this NS instance.",
364 instantiationLevelId = serializers.CharField(
365 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
370 # class IdentifierInPnfSerializer(serializers.Serializer):
371 # IdentifierInPnf = serializers.Serializer(
372 # help_text="An Identifier that is unique within respect to a PNF.")
375 # class IdentifierInNsdSerializer(serializers.Serializer):
376 # IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
379 class PnfExtCpDataSerializer(serializers.Serializer):
380 cpInstanceId = serializers.CharField( # sol 2.05.01 cpInstanceI16 typo
381 help_text="Identifier of the CP. Shall be present for existing CP.",
384 cpdId = serializers.CharField(
385 help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
386 required=False, allow_null=True)
387 cpProtocolData = CpProtocolDataSerializer(
388 help_text="Address assigned for this CP.",
394 class AddPnfDataSerializer(serializers.Serializer):
395 pnfId = serializers.CharField(
396 help_text="Identifier of the PNF.",
398 pnfName = serializers.CharField(
399 help_text="Name of the PNF.",
401 pnfdId = serializers.CharField(
402 help_text="Identifier of the PNFD on which the PNF is based.",
404 pnfProfileId = serializers.CharField(
405 help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.",
407 cpData = PnfExtCpDataSerializer(
408 help_text="Address assigned for the PNF external CP(s).",
414 class ModifyPnfDataSerializer(serializers.Serializer):
415 pnfId = serializers.CharField(
416 help_text="Identifier of the PNF.",
418 pnfName = serializers.CharField(
419 help_text="Name of the PNF",
422 cpData = serializers.ListField(
423 help_text="Address assigned for the PNF external CP(s).",
424 child=PnfExtCpDataSerializer(
425 help_text="This type represents the configuration data on the external CP of the PNF."),
430 # class DateTimeSerializer(serializers.Serializer):
431 # DateTime = serializers.Serializer(help_text="Date-time stamp.")
434 class UpdateNsReqSerializer(serializers.Serializer):
435 updateType = serializers.ChoiceField(
436 help_text="The type of update.",
437 choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
438 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
439 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
440 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
441 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
442 "MODIFY_PNF", "REMOVE_PNF"],
444 addVnfInstance = serializers.ListField(
445 help_text="Identifies an existing VNF instance to be added to the NS instance.",
446 child=VnfInstanceDataSerializer(
447 help_text="Data of vnf instance",
451 removeVnfInstanceId = serializers.ListField(
452 help_text="Identifies an existing VNF instance to be removed from the NS instance.",
453 child=serializers.CharField(),
456 instantiateVnfData = serializers.ListField(
457 help_text="Identifies the new VNF to be instantiated.",
458 child=(InstantiateVnfDataSerializer(
459 help_text="Data of vnf instance.",
463 changeVnfFlavourData = serializers.ListField(
464 help_text="Identifies the new DF of the VNF instance to be changed to.",
465 child=(ChangeVnfFlavourDataSerizlizer(
466 help_text="The type represents the information that is requested to be changed deployment flavour for an existing VNF instance.",
470 operateVnfData = serializers.ListField(
471 help_text="This type represents a VNF instance for which the operational state needs to be changed and the requested new state.",
472 child=(OperateVnfDataSerializer(
473 help_text="This type represents a VNF instance for which the operational state needs to be changed and the requested new state",
477 modifyVnfInfoData = serializers.ListField(
478 help_text="This type represents the information that is requested to be modified for a VNF instance. ",
479 child=(ModifyVnfInfoDataSerializer(
480 help_text="This type represents the information that is requested to be modified for a VNF instance. ",
484 changeExtVnfConnectivityData = serializers.ListField(
485 help_text="Specifies the new external connectivity datas of the VNF instance to be changed.",
486 child=ChangeExtVnfConnectivityDataSerializer(
487 help_text="This type describes the information invoked by the NFVO to change the external VNF connectivity information maintained by the VNFM.",
491 addSap = serializers.ListField(
492 help_text="Identifies a new SAP to be added to the NS instance.",
493 child=SapDataSerializer(help_text="This type represents the information related to a SAP of a NS",
497 removeSapId = serializers.ListField(
498 help_text="The identifier an existing SAP to be removed from the NS instance",
501 addNestedNsId = serializers.ListField(
502 help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
505 removeNestedNsId = serializers.ListField(
506 help_text="The identifier of an existing nested NS instance to be removed from the NS instance.",
509 assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(
510 help_text="Specify the new NSD to be used for the NS instance.",
513 moveVnfInstanceData = serializers.ListField(
514 help_text="Specify existing VNF instance to be moved from one NS instance to another NS instance",
515 child=MoveVnfInstanceDataSerializer(),
518 addVnffg = serializers.ListField(
519 help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
522 removeVnffgId = serializers.ListField(
523 help_text="The identifier of an existing nested NS instance to be removed from the NS instance",
524 child=serializers.CharField(),
527 updateVnffg = serializers.ListField(
528 help_text="Specify the new VNFFG Information data to be updated for a VNFFG of the NS Instance.",
529 child=UpdateVnffgDataSerializer(
530 help_text="This type specifies the parameters used for the update of an existing VNFFG instance.",
534 changeNsFlavourData = ChangeNsFlavourDataSerializer(
535 help_text="Specifies the new DF to be applied to the NS instance.",
538 addPnfData = serializers.ListField(
539 help_text="Specifies the PNF to be added into the NS instance.",
540 child=AddPnfDataSerializer(
541 help_text="Serializer data of add PNF",
545 modifyPnfData = serializers.ListField(
546 help_text="Specifies the PNF to be modified in the NS instance.",
547 child=ModifyPnfDataSerializer(
548 help_text="This type specifies an PNF to be modified in the NS instance.",
552 removePnfId = serializers.ListField(
553 help_text="Identifier of the PNF to be deleted from the NS instance.",
556 updateTime = serializers.CharField(
557 help_text="Timestamp indicating the update time of the NS",