Fix NS update serializers error
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / update_serializers.py
1 # Copyright (c) 2018, CMCC Technologies Co., Ltd.
2
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
6
7 # http://www.apache.org/licenses/LICENSE-2.0
8
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.
14
15 from rest_framework import serializers
16
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
22
23 class VnfInstanceDataSerializer(serializers.Serializer):
24     vnfInstanceId = serializers.CharField(
25         help_text="Specify the target NS instance where the VNF instances are moved to",
26         required=True)
27     vnfProfileId = serializers.CharField(
28         help_text="Specify the VNF instance that is moved.",
29         required=False,
30         allow_null=True)
31
32
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.",
36         required=True)
37     vnfFlavourId = serializers.CharField(
38         help_text="Identifier of the VNF deployment flavour to be instantiated.",
39         required=True)
40     vnfInstantiationLevelId = serializers.CharField(
41         help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
42         required=False,
43         allow_null=True)
44     vnfInstanceName = serializers.CharField(
45         help_text="Human-readable name of the VNF instance to be created.",
46         required=False,
47         allow_null=True)
48
49
50 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
51     macAddress = serializers.CharField(
52         help_text="Mac address",
53         required=False,
54         allow_null=True)
55     ipAddresses = IpAddressesDataSerialzier(
56         help_text="List of IP addresses to assign to the extCP instance.",
57         required=False,
58         allow_null=True,
59         many=True)
60
61
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.",
65         required=False,
66         allow_null=True)
67     linkPortId = serializers.CharField(
68         help_text="Identifier of a pre-conFigured link port to which the external CP will be associated.",
69         required=False,
70         allow_null=True)
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.",
75             required=True),
76         required=False,
77         allow_null=True)
78
79
80 class VnfExtCpData(serializers.Serializer):
81     cpdId = serializers.CharField(
82         help_text="The identifier of the CPD in the VNFD.",
83         required=True)
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",
88             required=True)),
89         required=False,
90         allow_null=True)
91
92
93 class ExtLinkPortDataSerializer(serializers.Serializer):
94     id = serializers.CharField(
95         help_text="Provided by the entity that has created the link port.",
96         required=True)
97     resourceHandle = ResourceHandleSerializer(
98         help_text="Identifier(s) of the virtualised network resource(s) realizing the VL instance.",
99         required=True)
100
101
102 class ExtVirtualLinkDataSerializer(serializers.Serializer):
103     extVirtualLinkId = serializers.CharField(
104         help_text="The identifier of the external VL instance, if provided.",
105         required=False,
106         allow_null=True)
107     vimId = serializers.CharField(
108         help_text="Identifier of the VIM that manages this resource.",
109         required=False,
110         allow_null=True)
111     resourceProviderId = serializers.CharField(
112         help_text="Identifies the entity responsible for the management of this resource.",
113         required=False,
114         allow_null=True)
115     resourceId = serializers.CharField(
116         help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
117         required=True)
118     extCps = serializers.ListField(
119         help_text="External CPs of the VNF to be connected to this external VL.",
120         child=VnfExtCpData(),
121         required=False,
122         allow_null=True)
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",
127             required=True)),
128         required=False,
129         allow_null=True)
130
131
132 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
133     extManagedVirtualLinkId = serializers.CharField(
134         help_text="The identifier of the externally-managed internal VL instance,if provided.",
135         required=False,
136         allow_null=True)
137     virtualLinkDescId = serializers.CharField(
138         help_text="The identifier of the VLD in the VNFD for this VL.",
139         required=True)
140     vimId = serializers.CharField(
141         help_text="Identifier of the VIMthat manage this resource.",
142         required=False,
143         allow_null=True)
144     resourceProviderId = serializers.CharField(
145         help_text="Identifies the entity responsible for the management of this resource.",
146         required=False,
147         allow_null=True)
148     resourceId = serializers.CharField(
149         help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
150         required=True)
151
152
153 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
154     vnfInstanceId = serializers.CharField(
155         help_text="Identifier of the VNF instance to be modified.",
156         required=True)
157     newFlavourId = serializers.CharField(
158         help_text="Identifier of the VNF deployment flavour to be instantiated.",
159         required=True)
160     instantiationLevelId = serializers.CharField(
161         help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
162         required=False,
163         allow_null=True)
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",
168             required=True),
169         required=False,
170         allow_null=True)
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.",
175             required=True),
176         required=False,
177         allow_null=True)
178     additionalParams = serializers.CharField(
179         help_text="Additional input parameters for the flavour change process",
180         required=False,
181         allow_null=True)
182
183
184 class OperationalStatesSerializer(serializers.Serializer):
185     OperationalStates = serializers.ChoiceField(
186         help_text="State of operation",
187         choices=["STARTED", "STOPPED"])
188
189
190 class StopTypeSerializer(serializers.Serializer):
191     StopType = serializers.ChoiceField(
192         help_text="Type of stop",
193         choices=["FORCEFUL", "GRACEFUL"])
194
195
196 class OperateVnfDataSerializer(serializers.Serializer):
197     vnfInstanceId = serializers.CharField(
198         help_text="Identifier of the VNF instance.",
199         required=True)
200     changeStateTo = OperationalStatesSerializer(
201         help_text="The desired operational state to change the VNF to.",
202         required=True)
203     stopType = StopTypeSerializer(
204         help_text="It signals whether forceful or graceful stop is requested.",
205         required=False,
206         allow_null=True)
207     gracefulStopTimeout = serializers.CharField(
208         help_text="The time interval to wait for the VNF to be taken out of service during graceful stop.",
209         required=False,
210         allow_null=True)
211
212
213 class ModifyVnfInfoDataSerializer(serializers.Serializer):
214     vnfInstanceId = serializers.UUIDField(
215         help_text="Identifier of the VNF instance."
216     )
217     vnfInstanceName = serializers.CharField(
218         help_text="New value of the 'vnfInstanceName' attribute in 'VnfInstance', or 'null' to remove the attribute.",
219         max_length=255,
220         required=False,
221         allow_null=True,
222         allow_blank=True)
223     vnfInstanceDescription = serializers.CharField(
224         help_text="If present, this attribute signals modifications of the 'vnfInstanceDescription' attribute in 'VnfInstance'",
225         required=False,
226         allow_null=True,
227         allow_blank=True)
228     vnfPkgId = serializers.UUIDField(
229         help_text="New value of the 'vnfPkgId' attribute in 'VnfInstance' The value 'null' is not permitted.."
230     )
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",
235             allow_blank=True),
236         required=False,
237         allow_null=True)
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",
242             allow_blank=True),
243         required=False,
244         allow_null=True)
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",
249             allow_blank=True),
250         required=False,
251         allow_null=True)
252
253
254 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
255     vnfInstanceId = serializers.CharField(
256         help_text="Identifier of the VNF instance.",
257         required=True,
258         allow_null=True)
259     extVirtualLinks = serializers.ListField(
260         help_text="Information about external VLs to change",
261         child=ExtVirtualLinkDataSerializer(
262             help_text="Data of ext virtual link",
263             required=True),
264         required=False,
265         allow_null=True)
266     additionalParams = serializers.CharField(
267         help_text="Additional parameters passed by the OSS as input to the external connectivity change process",
268         required=False,
269         allow_null=True)
270
271
272 class SapDataSerializer(serializers.Serializer):
273     sapdId = serializers.CharField(
274         help_text="Reference to the SAPD for this SAP.",
275         required=True)
276     sapName = serializers.CharField(
277         help_text="Human readable name for the SAP.",
278         required=True)
279     description = serializers.CharField(
280         help_text="Human readable description for the SAP. ",
281         required=True)
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.",
286             required=True),
287         required=False,
288         allow_null=True)
289
290
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.",
294         required=True)
295
296
297 class MoveVnfInstanceDataSerializer(serializers.Serializer):
298     targetNsInstanceId = serializers.CharField(
299         help_text="Specify the target NS instance where the VNF instances are moved to.",
300         required=True)
301     vnfInstanceId = serializers.CharField(
302         help_text="Specify the VNF instance that is moved.",
303         required=False,
304         allow_null=True)
305
306
307 class PortRangeSerializer(serializers.Serializer):
308     lowerPort = serializers.CharField(
309         help_text="Identifies the lower bound of the port range.",
310         required=True)
311     upperPort = serializers.CharField(
312         help_text="Identifies the upper bound of the port range ",
313         required=True)
314
315
316 class NfpDataSerializer(serializers.Serializer):
317     nfpInfoId = serializers.CharField(
318         help_text="Identifier of the NFP to be modified.",
319         required=False,
320         allow_null=True)
321     nfpName = serializers.CharField(
322         help_text="Human readable name for the NFP.",
323         required=False,
324         allow_null=True)
325     description = serializers.CharField(
326         help_text="Human readable description for the NFP.",
327         required=False,
328         allow_null=True)
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.",
333             required=True),
334         required=False,
335         allow_null=True)
336     nfpRule = NfpRuleSerializer(
337         help_text="NFP classification and selection rule.",
338         required=False,
339         allow_null=True)
340
341
342 class UpdateVnffgDataSerializer(serializers.Serializer):
343     vnffgInfoId = serializers.CharField(
344         help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
345         required=True)
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(),
349         required=False,
350         allow_null=True)
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."),
354         required=False,
355         allow_null=True)
356
357
358 class ChangeNsFlavourDataSerializer(serializers.Serializer):
359     newNsFlavourId = serializers.CharField(
360         help_text="Identifier of the new NS DF to apply to this NS instance.",
361         required=True)
362     instantiationLevelId = serializers.CharField(
363         help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
364         required=False,
365         allow_null=True)
366
367
368 # class IdentifierInPnfSerializer(serializers.Serializer):
369 #    IdentifierInPnf = serializers.Serializer(
370 #        help_text="An Identifier that is unique within respect to a PNF.")
371
372
373 # class IdentifierInNsdSerializer(serializers.Serializer):
374 #    IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
375
376
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.",
380         required=False,
381         allow_null=True)
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.",
387         required=False,
388         allow_null=True,
389         many=True)
390
391
392 class AddPnfDataSerializer(serializers.Serializer):
393     pnfId = serializers.CharField(
394         help_text="Identifier of the PNF.",
395         required=True)
396     pnfName = serializers.CharField(
397         help_text="Name of the PNF.",
398         required=True)
399     pnfdId = serializers.CharField(
400         help_text="Identifier of the PNFD on which the PNF is based.",
401         required=True)
402     pnfProfileId = serializers.CharField(
403         help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.",
404         required=True)
405     cpData = PnfExtCpDataSerializer(
406         help_text="Address assigned for the PNF external CP(s).",
407         required=False,
408         allow_null=True,
409         many=True)
410
411
412 class ModifyPnfDataSerializer(serializers.Serializer):
413     pnfId = serializers.CharField(
414         help_text="Identifier of the PNF.",
415         required=True)
416     pnfName = serializers.CharField(
417         help_text="Name of the PNF",
418         required=False,
419         allow_null=True)
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."),
424         required=False,
425         allow_null=True)
426
427
428 # class DateTimeSerializer(serializers.Serializer):
429 #    DateTime = serializers.Serializer(help_text="Date-time stamp.")
430
431
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"],
441         required=True)
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",
446             required=True),
447         required=False,
448         allow_null=True)
449     removeVnfInstanceId = serializers.ListField(
450         help_text="Identifies an existing VNF instance to be removed from the NS instance.",
451         child=serializers.CharField(),
452         required=False,
453         allow_null=True)
454     instantiateVnfData = serializers.ListField(
455         help_text="Identifies the new VNF to be instantiated.",
456         child=(InstantiateVnfDataSerializer(
457             help_text="Data of vnf instance.",
458             required=True)),
459         required=False,
460         allow_null=True)
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.",
465             required=True)),
466         required=False,
467         allow_null=True)
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",
472             required=True)),
473         required=False,
474         allow_null=True)
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. ",
479             required=True)),
480         required=False,
481         allow_null=True)
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.",
486             required=True),
487         required=False,
488         allow_null=True)
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",
492                                 required=True),
493         required=False,
494         allow_null=True)
495     removeSapId = serializers.ListField(
496         help_text="The identifier an existing SAP to be removed from the NS instance",
497         required=False,
498         allow_null=True)
499     addNestedNsId = serializers.ListField(
500         help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
501         required=False,
502         allow_null=True)
503     removeNestedNsId = serializers.ListField(
504         help_text="The identifier of an existing nested NS instance to be removed from the NS instance.",
505         required=False,
506         allow_null=True)
507     assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(
508         help_text="Specify the new NSD to be used for the NS instance.",
509         required=False,
510         allow_null=True)
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(),
514         required=False,
515         allow_null=True)
516     addVnffg = serializers.ListField(
517         help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
518         required=False,
519         allow_null=True)
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(),
523         required=False,
524         allow_null=True)
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.",
529             required=True),
530         required=False,
531         allow_null=True)
532     changeNsFlavourData = ChangeNsFlavourDataSerializer(
533         help_text="Specifies the new DF to be applied to the NS instance.",
534         required=False,
535         allow_null=True)
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",
540             required=True),
541         required=False,
542         allow_null=True)
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.",
547             required=True),
548         required=False,
549         allow_null=True)
550     removePnfId = serializers.ListField(
551         help_text="Identifier of the PNF to be deleted from the NS instance.",
552         required=False,
553         allow_null=True)
554     updateTime = serializers.CharField(
555         help_text="Timestamp indicating the update time of the NS",
556         required=False
557     )