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
18 from lcm.ns.serializers.pub_serializers import CpProtocolDataSerializer
19 from lcm.ns.serializers.create_ns_serializers import ResourceHandleSerializer, NsCpHandleSerializer, \
23 class VnfInstanceDataSerializer(serializers.Serializer):
24 vnfInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances are "
25 "moved to", required=True)
26 vnfProfileId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
27 required=False, allow_null=True)
30 class InstantiateVnfDataSerializer(serializers.Serializer):
31 vnfdId = serializers.CharField(help_text="Information sufficient to identify the VNFD which defines the VNF to be"
32 " instantiated. ", required=True)
33 vnfFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
35 vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
36 "flavour to be instantiated. ", required=False,
38 vnfInstanceName = serializers.CharField(help_text="Human-readable name of the VNF instance to be created.",
39 required=False, allow_null=True)
42 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
43 macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
44 ipAddresses = IpAddressSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
45 required=False, allow_null=True, many=True)
48 class VnfExtCpConfigSerializer(serializers.Serializer):
49 cpInstanceId = serializers.CharField(help_text="Identifier of the external CP instance to which this set of "
50 "configuration parameters is requested to be applied.",
51 required=False, allow_null=True)
52 linkPortId = serializers.CharField(help_text="Identifier of a pre-conFigured link port to which the external CP "
53 "will be associated.", required=False, allow_null=True)
54 cpProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the link "
55 "port that connects the CP to a VL",
56 child=(CpProtocolDataSerializer(help_text="This type represents network "
57 "protocol data.", required=True)),
58 required=False, allow_null=True)
61 class VnfExtCpData(serializers.Serializer):
62 cpdId = serializers.CharField(help_text="The identifier of the CPD in the VNFD.", required=True)
63 cpConfig = serializers.ListField(help_text="List of instance data that need to be conFigured on the CP instances "
64 "created from the respective CPD.",
65 child=(VnfExtCpConfigSerializer(help_text="Config of vnf ext cp", required=True)),
66 required=False, allow_null=True)
69 class ExtLinkPortDataSerializer(serializers.Serializer):
70 id = serializers.CharField(help_text="Provided by the entity that has created the link port", required=True)
71 resourceHandle = ResourceHandleSerializer(help_text="Identifier(s) of the virtualised network resource(s) "
72 "realizing the VL instance", required=True)
75 class ExtVirtualLinkDataSerializer(serializers.Serializer):
76 extVirtualLinkId = serializers.CharField(help_text="The identifier of the external VL instance, if provided. ",
77 required=False, allow_null=True)
78 vimId = serializers.CharField(help_text="Identifier of the VIM that manages this resource.",
79 required=False, allow_null=True)
80 resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of "
81 "this resource.", required=False, allow_null=True)
82 resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or the"
83 " resource provider.", required=True)
84 extCps = serializers.ListField(child=VnfExtCpData(help_text="External CPs of the VNF to be connected to this external "
85 "VL.", required=True), required=False, allow_null=True)
86 extLinkPorts = serializers.ListField(help_text="Externally provided link ports to be used to connect external "
87 "connection points to this external VL. ",
88 child=(ExtLinkPortDataSerializer(help_text="This type represents an externally"
89 "provided link port to be used to "
90 "connect a VNF external connection "
91 "point to an external VL",
93 required=False, allow_null=True)
96 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
97 extManagedVirtualLinkId = serializers.CharField(help_text="The identifier of the externally-managed internal VL "
98 "instance,if provided.", required=False, allow_null=True)
99 virtualLinkDescId = serializers.CharField(help_text="The identifier of the VLD in the VNFD for this VL.",
102 vimId = serializers.CharField(help_text="Identifier of the VIMthat manage this resource.",
103 required=False, allow_null=True)
105 resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of"
106 "this resource.", required=False, allow_null=True)
107 resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or"
108 "the resource provider.", required=True)
111 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
112 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance to be modified.", required=True)
113 newFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
115 instantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
116 "flavour to be instantiated.",
117 required=False, allow_null=True)
118 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to connect the VNF to.",
119 child=(ExtVirtualLinkDataSerializer(help_text="This type represents "
122 required=False, allow_null=True)
123 extManagedVirtualLinks = serializers.ListField(help_text="Information about internal VLs that are managed by NFVO",
124 child=ExtManagedVirtualLinkDataSerializer(
125 help_text="This type represents an externally-managed internal"
126 "VL.", required=True), required=False, allow_null=True)
127 additionalParams = serializers.CharField(help_text="Additional input parameters for the flavour change process",
128 required=False, allow_null=True)
131 class OperationalStatesSerializer(serializers.Serializer):
132 OperationalStates = serializers.ChoiceField(help_text="State of operation",
133 choices=["STARTED", "STOPPED"])
136 class StopTypeSerializer(serializers.Serializer):
137 StopType = serializers.ChoiceField(help_text="Type of stop", choices=["FORCEFUL", "GRACEFUL"])
140 class OperateVnfDataSerializer(serializers.Serializer):
141 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
142 changeStateTo = OperationalStatesSerializer(help_text="The desired operational state to change the VNF to.",
144 stopType = StopTypeSerializer(help_text="It signals whether forceful or graceful stop is requested.",
145 required=False, allow_null=True)
146 gracefulStopTimeout = serializers.CharField(help_text="The time interval to wait for the VNF to be taken out of"
147 "service during graceful stop.",
148 required=False, allow_null=True)
151 class ModifyVnfInfoDataSerializer(serializers.Serializer):
152 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance", required=True)
153 vnfInstanceName = serializers.CharField(help_text="New value of the vnfInstanceName attribute in VnfInstance",
154 required=False, allow_null=True)
155 vnfInstanceDescription = serializers.CharField(help_text="New value of the vnfInstanceDescription attribute in"
156 "VnfInstance", required=False, allow_null=True)
159 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
160 vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True, allow_null=True)
161 extVirtualLinks = serializers.ListField(help_text="Information about external VLs to change",
162 child=(ExtVirtualLinkDataSerializer(
163 help_text="Data of ext virtual link", required=True)),
164 required=False, allow_null=True)
165 additionalParams = serializers.CharField(help_text="Additional parameters passed by the OSS as input to the "
166 "external connectivity change process",
167 required=False, allow_null=True)
170 class SapDataSerializer(serializers.Serializer):
171 sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
172 sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
173 description = serializers.CharField(help_text="Human readable description for the SAP. ", required=True)
174 sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the SAP.",
175 child=(CpProtocolDataSerializer(
176 help_text="This type represents network protocol data.", required=True)),
177 required=False, allow_null=True)
180 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
181 newNsdId = serializers.CharField(help_text="Identifier of the new NSD version that is to be associated to the NS "
182 "instance. ", required=True)
185 class MoveVnfInstanceDataSerializer(serializers.Serializer):
186 targetNsInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances "
187 "are moved to.", required=True)
188 vnfInstanceId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
189 required=False, allow_null=True)
192 class PortRangeSerializer(serializers.Serializer):
193 lowerPort = serializers.CharField(help_text="Identifies the lower bound of the port range. ", required=True)
194 upperPort = serializers.CharField(help_text="Identifies the upper bound of the port range ", required=True)
197 class NfpDataSerializer(serializers.Serializer):
198 nfpInfoId = serializers.CharField(help_text="Identifier of the NFP to be modified.",
199 required=False, allow_null=True)
200 nfpName = serializers.CharField(help_text="Human readable name for the NFP.", required=False, allow_null=True)
201 description = serializers.CharField(help_text="Human readable description for the NFP",
202 required=False, allow_null=True)
203 nsCpHandle = serializers.ListField(help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
204 child=(NsCpHandleSerializer(
205 help_text="This type represents an identifier of the CP or SAP instance.",
206 required=True)), required=False, allow_null=True)
207 nfpRule = NfpRuleSerializer(help_text="NFP classification and selection rule.", required=False, allow_null=True)
210 class UpdateVnffgDataSerializer(serializers.Serializer):
211 vnffgInfoId = serializers.CharField(help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
213 nfp = serializers.ListField(help_text="nfp", child=(NfpDataSerializer(help_text="This type contains information "
214 "used to create or modify NFP "
215 "instance parameters for the update"
216 "of an existing VNFFG instance. ",
218 required=False, allow_null=True)
219 nfpInfoId = serializers.ListField(help_text="Identifier(s) of the NFP to be deleted from a given VNFFG.",
220 required=False, allow_null=True)
223 class ChangeNsFlavourDataSerializer(serializers.Serializer):
224 newNsFlavourId = serializers.CharField(
225 help_text="Identifier of the new NS DF to apply to this NS instance.", required=True)
226 instantiationLevelId = serializers.CharField(
227 help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
228 required=False, allow_null=True)
231 class IdentifierInPnfSerializer(serializers.Serializer):
232 IdentifierInPnf = serializers.Serializer(help_text="An Identifier that is unique within respect to a PNF.")
235 class IdentifierInNsdSerializer(serializers.Serializer):
236 IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
239 class PnfExtCpDataSerializer(serializers.Serializer):
240 cpInstanceI16 = IdentifierInPnfSerializer(help_text="Identifier of the CP. Shall be present for existing CP.",
241 required=False, allow_null=True)
242 cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
243 required=False, allow_null=True)
244 cpProtocolData = CpProtocolDataSerializer(help_text="Address assigned for this CP.",
245 required=False, allow_null=True, many=True)
248 class AddPnfDataSerializer(serializers.Serializer):
249 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
250 pnfName = serializers.CharField(help_text="Name of the PNF.", required=True)
251 pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
252 pnfProfileId = serializers.CharField(
253 help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
254 cpData = PnfExtCpDataSerializer(help_text="Address assigned for the PNF external CP(s). ",
255 required=False, allow_null=True, many=True)
258 class ModifyPnfDataSerializer(serializers.Serializer):
259 pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
260 pnfName = serializers.CharField(help_text="Name of the PNF", required=False, allow_null=True)
261 cpData = serializers.ListField(
262 help_text="Address assigned for the PNF external CP(s).",
263 child=(PnfExtCpDataSerializer(
264 help_text="This type represents the configuration data on the external CP of the PNF.")),
265 required=False, allow_null=True)
268 class DateTimeSerializer(serializers.Serializer):
269 DateTime = serializers.Serializer(help_text="Date-time stamp.")
272 class UpdateNsReqSerializer(serializers.Serializer):
273 updateType = serializers.ChoiceField(help_text="The type of update.",
274 choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
275 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
276 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
277 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
278 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
279 "MODIFY_PNF", "REMOVE_PNF"], required=True)
280 addVnfInstance = serializers.ListField(help_text="Identifies an existing VNF instance to be added to the NS "
282 child=(VnfInstanceDataSerializer(help_text="Data of vnf instance",
284 required=False, allow_null=True)
285 removeVnfInstanceId = serializers.ListField(help_text="Identifies an existing VNF instance to be removed from "
286 "the NS instance.", required=False, allow_null=True)
287 instantiateVnfData = serializers.ListField(help_text="Identifies the new VNF to be instantiated.",
288 child=(InstantiateVnfDataSerializer(help_text="Data of vnf instance",
290 required=False, allow_null=True)
291 changeVnfFlavourData = serializers.ListField(help_text="Identifies the new DF of the VNF instance to be "
293 child=(ChangeVnfFlavourDataSerizlizer(
294 help_text="The type represents the information that is requested "
295 "to be changed deployment flavour for an existing "
296 "VNF instance.", required=True)),
297 required=False, allow_null=True)
298 operateVnfData = serializers.ListField(help_text="This type represents a VNF instance for which the operational "
299 "state needs to be changed and the requested new state.",
300 child=(OperateVnfDataSerializer(
301 help_text="This type represents a VNF instance for which the operational"
302 " state needs to be changed and the requested new state",
303 required=True)), required=False, allow_null=True)
304 modifyVnfInfoData = serializers.ListField(help_text="This type represents the information that is requested to be"
305 " modified for a VNF instance. ",
306 child=(ModifyVnfInfoDataSerializer(
307 help_text="This type represents the information that is requested to "
308 "be modified for a VNF instance. ", required=True)),
309 required=False, allow_null=True)
310 changeExtVnfConnectivityData = serializers.ListField(help_text="Specifies the new external connectivity data of the"
311 "VNF instance to be changed",
312 child=(ChangeExtVnfConnectivityDataSerializer(
313 help_text="This type describes the information invoked by"
314 "the NFVO to change the external VNF "
315 "connectivity information maintained by"
316 " the VNFM.", required=True)),
317 required=False, allow_null=True)
318 addSap = serializers.ListField(help_text="Identifies a new SAP to be added to the NS instance.",
319 child=(SapDataSerializer(help_text="This type represents the information related to "
320 "a SAP of a NS", required=True)),
321 required=False, allow_null=True)
322 removeSapId = serializers.ListField(help_text="The identifier an existing SAP to be removed from the "
323 "NS instance", required=False, allow_null=True)
324 addNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to "
325 "the NS instance", required=False, allow_null=True)
326 removeNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be "
327 "removed from the NS instance.",
328 required=False, allow_null=True)
329 assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(help_text="Specify the new NSD to be used for the NS "
330 "instance.", required=False, allow_null=True)
331 moveVnfInstanceData = serializers.ListField(help_text="Specify existing VNF instance to be moved from one NS "
332 "instance to another NS instance",
333 child=(MoveVnfInstanceDataSerializer()),
334 required=False, allow_null=True)
335 addVnffg = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to the"
336 " NS instance.", required=False, allow_null=True)
337 removeVnffgId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be removed "
338 "from the NS instance", required=False, allow_null=True)
339 updateVnffg = serializers.ListField(help_text="Specify the new VNFFG Information data to be updated for a VNFFG"
340 " of the NS Instance",
341 child=(UpdateVnffgDataSerializer(help_text="This type specifies the parameters "
342 "used for the update of an existing "
343 "VNFFG instance.", required=True)),
344 required=False, allow_null=True)
345 changeNsFlavourData = ChangeNsFlavourDataSerializer(
346 help_text="Specifies the new DF to be applied to the NS instance", required=False, allow_null=True)
347 addPnfData = serializers.ListField(help_text="Specifies the PNF to be added into the NS instance.",
348 child=(AddPnfDataSerializer(help_text="Serializer data of add pnf", required=True)),
349 required=False, allow_null=True)
350 modifyPnfData = serializers.ListField(help_text="Specifies the PNF to be modified in the NS instance.",
351 child=(ModifyPnfDataSerializer(
352 help_text="This type specifies an PNF to be modified in the NS instance.",
354 required=False, allow_null=True)
355 removePnfId = serializers.ListField(help_text="Identifier of the PNF to be deleted from the NS instance.",
356 required=False, allow_null=True)
357 updateTime = DateTimeSerializer(help_text="Timestamp indicating the update time of the NS",
358 required=False, allow_null=True)