4ddfe8e63ad8bf753a741e5345c891e9a7ee3487
[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(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)
28
29
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.",
34                                          required=True)
35     vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
36                                                               "flavour to be instantiated. ", required=False,
37                                                     allow_null=True)
38     vnfInstanceName = serializers.CharField(help_text="Human-readable name of the VNF instance to be created.",
39                                             required=False, allow_null=True)
40
41
42 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
43     macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
44     ipAddresses = IpAddressesDataSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
45                                             required=False, allow_null=True, many=True)
46
47
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)
59
60
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)
67
68
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)
73
74
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",
92                                                                           required=True)),
93                                          required=False, allow_null=True)
94
95
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.",
100                                               required=True)
101
102     vimId = serializers.CharField(help_text="Identifier of the VIMthat manage this resource.",
103                                   required=False, allow_null=True)
104
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)
109
110
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.",
114                                          required=True)
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 "
120                                                                                           "an external VL",
121                                                                                 required=True)),
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)
129
130
131 class OperationalStatesSerializer(serializers.Serializer):
132     OperationalStates = serializers.ChoiceField(help_text="State of operation",
133                                                 choices=["STARTED", "STOPPED"])
134
135
136 class StopTypeSerializer(serializers.Serializer):
137     StopType = serializers.ChoiceField(help_text="Type of stop", choices=["FORCEFUL", "GRACEFUL"])
138
139
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.",
143                                                 required=True)
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)
149
150
151 class ModifyVnfInfoDataSerializer(serializers.Serializer):
152     vnfInstanceId = serializers.UUIDField(
153         help_text="Identifier of the VNF instance."
154     )
155     vnfInstanceName = serializers.CharField(
156         help_text="New value of the 'vnfInstanceName' attribute in 'VnfInstance', or 'null' to remove the attribute.",
157         max_length=255,
158         required=False,
159         allow_null=True,
160         allow_blank=True)
161     vnfInstanceDescription = serializers.CharField(
162         help_text="If present, this attribute signals modifications of the 'vnfInstanceDescription' attribute in "
163                   "'VnfInstance'",
164         required=False,
165         allow_null=True,
166         allow_blank=True)
167     vnfPkgId = serializers.UUIDField(
168         help_text="New value of the 'vnfPkgId' attribute in 'VnfInstance' The value 'null' is not permitted.."
169     )
170     vnfConfigurableProperties = serializers.DictField(
171         help_text="Modifications to entries in the 'vnfConfigurableProperties' list, as defined below this Table.",
172         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
173         required=False,
174         allow_null=True)
175     metaData = serializers.DictField(
176         help_text="If present, this attribute signals modifications of certain 'metadata' attribute in 'vnfInstance'.",
177         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
178         required=False,
179         allow_null=True)
180     extensions = serializers.DictField(
181         help_text="If present,this attribute signals modifications of certain 'extensions' attribute in 'vnfInstance'.",
182         child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
183         required=False,
184         allow_null=True)
185
186
187 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
188     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True, allow_null=True)
189     extVirtualLinks = serializers.ListField(help_text="Information about external VLs to change",
190                                             child=(ExtVirtualLinkDataSerializer(
191                                                 help_text="Data of ext virtual link", required=True)),
192                                             required=False, allow_null=True)
193     additionalParams = serializers.CharField(help_text="Additional parameters passed by the OSS as input to the "
194                                                        "external connectivity change process",
195                                              required=False, allow_null=True)
196
197
198 class SapDataSerializer(serializers.Serializer):
199     sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
200     sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
201     description = serializers.CharField(help_text="Human readable description for the SAP. ", required=True)
202     sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the SAP.",
203                                             child=(CpProtocolDataSerializer(
204                                                 help_text="This type represents network protocol data.", required=True)),
205                                             required=False, allow_null=True)
206
207
208 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
209     newNsdId = serializers.CharField(help_text="Identifier of the new NSD version that is to be associated to the NS "
210                                                "instance. ", required=True)
211
212
213 class MoveVnfInstanceDataSerializer(serializers.Serializer):
214     targetNsInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances "
215                                                          "are moved to.", required=True)
216     vnfInstanceId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
217                                           required=False, allow_null=True)
218
219
220 class PortRangeSerializer(serializers.Serializer):
221     lowerPort = serializers.CharField(help_text="Identifies the lower bound of the port range. ", required=True)
222     upperPort = serializers.CharField(help_text="Identifies the upper bound of the port range ", required=True)
223
224
225 class NfpDataSerializer(serializers.Serializer):
226     nfpInfoId = serializers.CharField(help_text="Identifier of the NFP to be modified.",
227                                       required=False, allow_null=True)
228     nfpName = serializers.CharField(help_text="Human readable name for the NFP.", required=False, allow_null=True)
229     description = serializers.CharField(help_text="Human readable description for the NFP",
230                                         required=False, allow_null=True)
231     nsCpHandle = serializers.ListField(help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
232                                        child=(NsCpHandleSerializer(
233                                            help_text="This type represents an identifier of the CP or SAP instance.",
234                                            required=True)), required=False, allow_null=True)
235     nfpRule = NfpRuleSerializer(help_text="NFP classification and selection rule.", required=False, allow_null=True)
236
237
238 class UpdateVnffgDataSerializer(serializers.Serializer):
239     vnffgInfoId = serializers.CharField(help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
240                                         required=True)
241     nfp = serializers.ListField(help_text="nfp", child=(NfpDataSerializer(help_text="This type contains information "
242                                                                                     "used to create or modify NFP "
243                                                                                     "instance parameters for the update"
244                                                                                     "of an existing VNFFG instance. ",
245                                                                           required=True)),
246                                 required=False, allow_null=True)
247     nfpInfoId = serializers.ListField(help_text="Identifier(s) of the NFP to be deleted from a given VNFFG.",
248                                       required=False, allow_null=True)
249
250
251 class ChangeNsFlavourDataSerializer(serializers.Serializer):
252     newNsFlavourId = serializers.CharField(
253         help_text="Identifier of the new NS DF to apply to this NS instance.", required=True)
254     instantiationLevelId = serializers.CharField(
255         help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
256         required=False, allow_null=True)
257
258
259 class IdentifierInPnfSerializer(serializers.Serializer):
260     IdentifierInPnf = serializers.Serializer(help_text="An Identifier that is unique within respect to a PNF.")
261
262
263 class IdentifierInNsdSerializer(serializers.Serializer):
264     IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
265
266
267 class PnfExtCpDataSerializer(serializers.Serializer):
268     cpInstanceI16 = IdentifierInPnfSerializer(help_text="Identifier of the CP. Shall be present for existing CP.",
269                                               required=False, allow_null=True)
270     cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
271                                       required=False, allow_null=True)
272     cpProtocolData = CpProtocolDataSerializer(help_text="Address assigned for this CP.",
273                                               required=False, allow_null=True, many=True)
274
275
276 class AddPnfDataSerializer(serializers.Serializer):
277     pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
278     pnfName = serializers.CharField(help_text="Name of the PNF.", required=True)
279     pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
280     pnfProfileId = serializers.CharField(
281         help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
282     cpData = PnfExtCpDataSerializer(help_text="Address assigned for the PNF external CP(s). ",
283                                     required=False, allow_null=True, many=True)
284
285
286 class ModifyPnfDataSerializer(serializers.Serializer):
287     pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
288     pnfName = serializers.CharField(help_text="Name of the PNF", required=False, allow_null=True)
289     cpData = serializers.ListField(
290         help_text="Address assigned for the PNF external CP(s).",
291         child=(PnfExtCpDataSerializer(
292             help_text="This type represents the configuration data on the external CP of the PNF.")),
293         required=False, allow_null=True)
294
295
296 class DateTimeSerializer(serializers.Serializer):
297     DateTime = serializers.Serializer(help_text="Date-time stamp.")
298
299
300 class UpdateNsReqSerializer(serializers.Serializer):
301     updateType = serializers.ChoiceField(help_text="The type of update.",
302                                          choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
303                                                   "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
304                                                   "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
305                                                   "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
306                                                   "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
307                                                   "MODIFY_PNF", "REMOVE_PNF"], required=True)
308     addVnfInstance = serializers.ListField(help_text="Identifies an existing VNF instance to be added to the NS "
309                                                      "instance.",
310                                            child=(VnfInstanceDataSerializer(help_text="Data of vnf instance",
311                                                                             required=True)),
312                                            required=False, allow_null=True)
313     removeVnfInstanceId = serializers.ListField(help_text="Identifies an existing VNF instance to be removed from "
314                                                           "the NS instance.", required=False, allow_null=True)
315     instantiateVnfData = serializers.ListField(help_text="Identifies the new VNF to be instantiated.",
316                                                child=(InstantiateVnfDataSerializer(help_text="Data of vnf instance",
317                                                                                    required=True)),
318                                                required=False, allow_null=True)
319     changeVnfFlavourData = serializers.ListField(help_text="Identifies the new DF of the VNF instance to be "
320                                                            "changed to.",
321                                                  child=(ChangeVnfFlavourDataSerizlizer(
322                                                      help_text="The type represents the information that is requested "
323                                                                "to be changed deployment flavour for an existing "
324                                                                "VNF instance.", required=True)),
325                                                  required=False, allow_null=True)
326     operateVnfData = serializers.ListField(help_text="This type represents a VNF instance for which the operational "
327                                                      "state needs to be changed and the requested new state.",
328                                            child=(OperateVnfDataSerializer(
329                                                help_text="This type represents a VNF instance for which the operational"
330                                                          " state needs to be changed and the requested new state",
331                                                          required=True)), required=False, allow_null=True)
332     modifyVnfInfoData = serializers.ListField(help_text="This type represents the information that is requested to be"
333                                                         " modified for a VNF instance. ",
334                                               child=(ModifyVnfInfoDataSerializer(
335                                                   help_text="This type represents the information that is requested to "
336                                                             "be modified for a VNF instance. ", required=True)),
337                                               required=False, allow_null=True)
338     changeExtVnfConnectivityData = serializers.ListField(help_text="Specifies the new external connectivity data of the"
339                                                                    "VNF instance to be changed",
340                                                          child=(ChangeExtVnfConnectivityDataSerializer(
341                                                              help_text="This type describes the information invoked by"
342                                                                        "the NFVO to change the external VNF "
343                                                                        "connectivity information maintained by"
344                                                                        " the VNFM.", required=True)),
345                                                          required=False, allow_null=True)
346     addSap = serializers.ListField(help_text="Identifies a new SAP to be added to the NS instance.",
347                                    child=(SapDataSerializer(help_text="This type represents the information related to "
348                                                                       "a SAP of a NS", required=True)),
349                                    required=False, allow_null=True)
350     removeSapId = serializers.ListField(help_text="The identifier an existing SAP to be removed from the "
351                                                   "NS instance", required=False, allow_null=True)
352     addNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to "
353                                                     "the NS instance", required=False, allow_null=True)
354     removeNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be "
355                                                        "removed from the NS instance.",
356                                              required=False, allow_null=True)
357     assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(help_text="Specify the new NSD to be used for the NS "
358                                                                         "instance.", required=False, allow_null=True)
359     moveVnfInstanceData = serializers.ListField(help_text="Specify existing VNF instance to be moved from one NS "
360                                                           "instance to another NS instance",
361                                                 child=(MoveVnfInstanceDataSerializer()),
362                                                 required=False, allow_null=True)
363     addVnffg = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to the"
364                                                " NS instance.", required=False, allow_null=True)
365     removeVnffgId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be removed "
366                                                     "from the NS instance", required=False, allow_null=True)
367     updateVnffg = serializers.ListField(help_text="Specify the new VNFFG Information data to be updated for a VNFFG"
368                                                   " of the NS Instance",
369                                         child=(UpdateVnffgDataSerializer(help_text="This type specifies the parameters "
370                                                                                    "used for the update of an existing "
371                                                                                    "VNFFG instance.", required=True)),
372                                         required=False, allow_null=True)
373     changeNsFlavourData = ChangeNsFlavourDataSerializer(
374         help_text="Specifies the new DF to be applied to the NS instance", required=False, allow_null=True)
375     addPnfData = serializers.ListField(help_text="Specifies the PNF to be added into the NS instance.",
376                                        child=(AddPnfDataSerializer(help_text="Serializer data of add pnf", required=True)),
377                                        required=False, allow_null=True)
378     modifyPnfData = serializers.ListField(help_text="Specifies the PNF to be modified in the NS instance.",
379                                           child=(ModifyPnfDataSerializer(
380                                               help_text="This type specifies an PNF to be modified in the NS instance.",
381                                               required=True)),
382                                           required=False, allow_null=True)
383     removePnfId = serializers.ListField(help_text="Identifier of the PNF to be deleted from the NS instance.",
384                                         required=False, allow_null=True)
385     updateTime = DateTimeSerializer(help_text="Timestamp indicating the update time of the NS",
386                                     required=False, allow_null=True)