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