a677c43f8d3b0d9d8ee462fab5ef060e6a2c8744
[vfc/nfvo/lcm.git] / lcm / ns / serializers / 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.pub_serializers import IpAddressSerialzier
18 from lcm.ns.serializers.pub_serializers import CpProtocolDataSerializer
19 from lcm.ns.serializers.create_ns_serializers import ResourceHandleSerializer
20
21
22 class VnfInstanceDataSerializer(serializers.Serializer):
23     vnfInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances are "
24                                                     "moved to", required=True)
25     vnfProfileId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
26                                          required=False, allow_null=True)
27
28
29 class InstantiateVnfDataSerializer(serializers.Serializer):
30     vnfdId = serializers.CharField(help_text="Information sufficient to identify the VNFD which defines the VNF to be"
31                                              " instantiated. ", required=True)
32     vnfFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
33                                          required=True)
34     vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
35                                                               "flavour to be instantiated. ", required=False,
36                                                     allow_null=True)
37     vnfInstanceName = serializers.CharField(help_text="Human-readable name of the VNF instance to be created.",
38                                             required=False, allow_null=True)
39
40
41 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
42     macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
43     ipAddresses = IpAddressSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
44                                       required=False, allow_null=True, many=True)
45
46
47 class VnfExtCpConfigSerializer(serializers.Serializer):
48     cpInstanceId = serializers.CharField(help_text="Identifier of the external CP instance to which this set of "
49                                                    "configuration parameters is requested to be applied.",
50                                          required=False, allow_null=True)
51     linkPortId = serializers.CharField(help_text="Identifier of a pre-conFigured link port to which the external CP "
52                                                  "will be associated.", required=False, allow_null=True)
53     cpProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the link "
54                                                      "port that connects the CP to a VL",
55                                            child=(CpProtocolDataSerializer(help_text="This type represents network "
56                                                                                      "protocol data.", required=True)),
57                                            required=False, allow_null=True)
58
59
60 class VnfExtCpData(serializers.Serializer):
61     cpdId = serializers.CharField(help_text="The identifier of the CPD in the VNFD.", required=True)
62     cpConfig = serializers.ListField(help_text="List of instance data that need to be conFigured on the CP instances "
63                                                "created from the respective CPD.",
64                                      child=(VnfExtCpConfigSerializer(help_text="Config of vnf ext cp", required=True)),
65                                      required=False, allow_null=True)
66
67
68 # class ResourceHandleSerializer(serializers.Serializer):
69 #     vimId = serializers.CharField(help_text="Identifier of the VIM under whose control this resource is placed.",
70 #                                   required=False, allow_null=True)
71 #     resourceProviderId = serializers.CharField(help_text="Identifier of the entity responsible for the management of "
72 #                                                          "the resource.", required=False, allow_null=True)
73 #     resourceId = serializers.CharField(help_text="Identifier of the resource in the scope of the VIM or the "
74 #                                                  "resource provider.", required=True)
75 #     vimLevelResourceType = serializers.CharField(help_text="Type of the resource in the scope of the VIM or the "
76 #                                                            "resource provider.", required=False, allow_null=True)
77
78
79 class ExtLinkPortDataSerializer(serializers.Serializer):
80     id = serializers.CharField(help_text="Provided by the entity that has created the link port", required=True)
81     resourceHandle = ResourceHandleSerializer(help_text="Identifier(s) of the virtualised network resource(s) "
82                                                         "realizing the VL instance", required=True)
83
84
85 class ExtVirtualLinkDataSerializer(serializers.Serializer):
86     extVirtualLinkId = serializers.CharField(help_text="The identifier of the external VL instance, if provided. ",
87                                              required=False, allow_null=True)
88     vimId = serializers.CharField(help_text="Identifier of the VIM that manages this resource.",
89                                   required=False, allow_null=True)
90     resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of "
91                                                          "this resource.", required=False, allow_null=True)
92     resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or the"
93                                                  " resource provider.", required=True)
94     extCps = serializers.ListField(child=VnfExtCpData(help_text="External CPs of the VNF to be connected to this external "
95                                                       "VL.", required=True), required=False, allow_null=True)
96     extLinkPorts = serializers.ListField(help_text="Externally provided link ports to be used to connect external "
97                                                    "connection points to this external VL. ",
98                                          child=(ExtLinkPortDataSerializer(help_text="This type represents an externally"
99                                                                                     "provided link port to be used to "
100                                                                                     "connect a VNF external connection "
101                                                                                     "point to an external VL",
102                                                                           required=True)),
103                                          required=False, allow_null=True)
104
105
106 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
107     extManagedVirtualLinkId = serializers.CharField(help_text="The identifier of the externally-managed internal VL "
108                                                               "instance,if provided.", required=False, allow_null=True)
109     virtualLinkDescId = serializers.CharField(help_text="The identifier of the VLD in the VNFD for this VL.",
110                                               required=True)
111
112     vimId = serializers.CharField(help_text="Identifier of the VIMthat manage this resource.",
113                                   required=False, allow_null=True)
114
115     resourceProviderId = serializers.CharField(help_text="Identifies the entity responsible for the management of"
116                                                          "this resource.", required=False, allow_null=True)
117     resourceId = serializers.CharField(help_text="The identifier of the resource in the scope of the VIM or"
118                                                  "the resource provider.", required=True)
119
120
121 class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
122     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance to be modified.", required=True)
123     newFlavourId = serializers.CharField(help_text="Identifier of the VNF deployment flavour to be instantiated.",
124                                          required=True)
125     instantiationLevelId = serializers.CharField(help_text="Identifier of the instantiation level of the deployment "
126                                                            "flavour to be instantiated.",
127                                                  required=False, allow_null=True)
128     extVirtualLinks = serializers.ListField(help_text="Information about external VLs to connect the VNF to.",
129                                             child=(ExtVirtualLinkDataSerializer(help_text="This type represents "
130                                                                                           "an external VL",
131                                                                                 required=True)),
132                                             required=False, allow_null=True)
133     extManagedVirtualLinks = serializers.ListField(help_text="Information about internal VLs that are managed by NFVO",
134                                                    child=ExtManagedVirtualLinkDataSerializer(
135                                                        help_text="This type represents an externally-managed internal"
136                                                                  "VL.", required=True), required=False, allow_null=True)
137     additionalParams = serializers.CharField(help_text="Additional input parameters for the flavour change process",
138                                              required=False, allow_null=True)
139
140
141 class OperationalStatesSerializer(serializers.Serializer):
142     OperationalStates = serializers.ChoiceField(help_text="State of operation",
143                                                 choices=["STARTED", "STOPPED"])
144
145
146 class StopTypeSerializer(serializers.Serializer):
147     StopType = serializers.ChoiceField(help_text="Type of stop", choices=["FORCEFUL", "GRACEFUL"])
148
149
150 class OperateVnfDataSerializer(serializers.Serializer):
151     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
152     changeStateTo = OperationalStatesSerializer(help_text="The desired operational state to change the VNF to.",
153                                                 required=True)
154     stopType = StopTypeSerializer(help_text="It signals whether forceful or graceful stop is requested.",
155                                   required=False, allow_null=True)
156     gracefulStopTimeout = serializers.CharField(help_text="The time interval to wait for the VNF to be taken out of"
157                                                           "service during graceful stop.",
158                                                 required=False, allow_null=True)
159
160
161 class ModifyVnfInfoDataSerializer(serializers.Serializer):
162     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance", required=True)
163     vnfInstanceName = serializers.CharField(help_text="New value of the vnfInstanceName attribute in VnfInstance",
164                                             required=False, allow_null=True)
165     vnfInstanceDescription = serializers.CharField(help_text="New value of the vnfInstanceDescription attribute in"
166                                                              "VnfInstance", required=False, allow_null=True)
167
168
169 class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
170     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True, allow_null=True)
171     extVirtualLinks = serializers.ListField(help_text="Information about external VLs to change",
172                                             child=(ExtVirtualLinkDataSerializer(
173                                                 help_text="Data of ext virtual link", required=True)),
174                                             required=False, allow_null=True)
175     additionalParams = serializers.CharField(help_text="Additional parameters passed by the OSS as input to the "
176                                                        "external connectivity change process",
177                                              required=False, allow_null=True)
178
179
180 class SapDataSerializer(serializers.Serializer):
181     sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
182     sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
183     description = serializers.CharField(help_text="Human readable description for the SAP. ", required=True)
184     sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on the SAP.",
185                                             child=(CpProtocolDataSerializer(
186                                                 help_text="This type represents network protocol data.", required=True)),
187                                             required=False, allow_null=True)
188
189
190 class AssocNewNsdVersionDataSerializer(serializers.Serializer):
191     newNsdId = serializers.CharField(help_text="Identifier of the new NSD version that is to be associated to the NS "
192                                                "instance. ", required=True)
193
194
195 class MoveVnfInstanceDataSerializer(serializers.Serializer):
196     targetNsInstanceId = serializers.CharField(help_text="Specify the target NS instance where the VNF instances "
197                                                          "are moved to.", required=True)
198     vnfInstanceId = serializers.CharField(help_text="Specify the VNF instance that is moved.",
199                                           required=False, allow_null=True)
200
201
202 class NsCpHandleSerializer(serializers.Serializer):
203     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated to the CP instance.",
204                                           required=False, allow_null=True)
205     vnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the VNF external CP instance in the scope "
206                                                          "of the VNF instance. ", required=False, allow_null=True)
207     pnfInfoId = serializers.CharField(help_text="Identifier of the PNF instance associated to the CP instance.",
208                                       required=False, allow_null=True)
209     pnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the PNF external CP instance in the scope "
210                                                          "of the PNF.", required=False, allow_null=True)
211     nsInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated to the SAP instance.",
212                                          required=False, allow_null=True)
213     nsSapInstanceId = serializers.CharField(help_text="Identifier of the SAP instance in the scope of the NS instance",
214                                             required=False, allow_null=True)
215
216
217 class PortRangeSerializer(serializers.Serializer):
218     lowerPort = serializers.CharField(help_text="Identifies the lower bound of the port range. ", required=True)
219     upperPort = serializers.CharField(help_text="Identifies the upper bound of the port range ", required=True)
220
221
222 class MaskSerializer(serializers.Serializer):
223     startingPoint = serializers.CharField(help_text="Indicates the offset between the last bit of the source mac "
224                                                     "address and the first bit of the sequence of bits to "
225                                                     "be matched.", required=True)
226     length = serializers.CharField(help_text="Indicates the number of bits to be matched. ", required=True)
227     value = serializers.CharField(help_text="Provide the sequence of bit values to be matched. ", required=True)
228
229
230 class NfpRuleSerializer(serializers.Serializer):
231     etherDestinationAddress = serializers.CharField(help_text="Indicates a destination Mac address ",
232                                                     required=False, allow_null=True)
233     etherSourceAddress = serializers.CharField(help_text="Indicates a source Mac address",
234                                                required=False, allow_null=True)
235     etherType = serializers.ChoiceField(help_text="Indicates the protocol carried over the Ethernet layer.",
236                                         choices=["IPV4", "IPV6"], required=False, allow_null=True)
237     vlanTag = serializers.CharField(help_text="Indicates a VLAN identifier in an IEEE 802.1Q-2014 tag [6] ",
238                                     required=False, allow_null=True)
239     protocol = serializers.ChoiceField(help_text="Indicates the L4 protocol",
240                                        choices=["TCP", "UDP", "ICMP"], required=False, allow_null=True)
241     dscp = serializers.CharField(help_text="For IPv4 [7] a string of 0 and 1 digits that corresponds to the 6-bit "
242                                            "Differentiated Services Code Point (DSCP) field of the IP header",
243                                  required=False, allow_null=True)
244     sourcePortRange = PortRangeSerializer(help_text="Indicates a range of source ports. ",
245                                           required=False, allow_null=True)
246     destinationPortRange = PortRangeSerializer(help_text="Indicates a range of destination ports.",
247                                                required=False, allow_null=True)
248     sourceIpAddressPrefix = serializers.CharField(
249         help_text="Prefix of source ip address", required=False, allow_null=True)
250     destinationIpAddressPrefix = serializers.CharField(
251         help_text="Prefix of destination ip address", required=False, allow_null=True)
252     extendedCriteria = serializers.ListField(help_text="Indicates values of specific bits in a frame.",
253                                              child=(MaskSerializer(help_text="Mask serializer", required=True)),
254                                              required=False, allow_null=True)
255
256
257 class NfpDataSerializer(serializers.Serializer):
258     nfpInfoId = serializers.CharField(help_text="Identifier of the NFP to be modified.",
259                                       required=False, allow_null=True)
260     nfpName = serializers.CharField(help_text="Human readable name for the NFP.", required=False, allow_null=True)
261     description = serializers.CharField(help_text="Human readable description for the NFP",
262                                         required=False, allow_null=True)
263     nsCpHandle = serializers.ListField(help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
264                                        child=(NsCpHandleSerializer(
265                                            help_text="This type represents an identifier of the CP or SAP instance.",
266                                            required=True)), required=False, allow_null=True)
267     nfpRule = NfpRuleSerializer(help_text="NFP classification and selection rule.", required=False, allow_null=True)
268
269
270 class UpdateVnffgDataSerializer(serializers.Serializer):
271     vnffgInfoId = serializers.CharField(help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
272                                         required=True)
273     nfp = serializers.ListField(help_text="nfp", child=(NfpDataSerializer(help_text="This type contains information "
274                                                                                     "used to create or modify NFP "
275                                                                                     "instance parameters for the update"
276                                                                                     "of an existing VNFFG instance. ",
277                                                                           required=True)),
278                                 required=False, allow_null=True)
279     nfpInfoId = serializers.ListField(help_text="Identifier(s) of the NFP to be deleted from a given VNFFG.",
280                                       required=False, allow_null=True)
281
282
283 class ChangeNsFlavourDataSerializer(serializers.Serializer):
284     newNsFlavourId = serializers.CharField(
285         help_text="Identifier of the new NS DF to apply to this NS instance.", required=True)
286     instantiationLevelId = serializers.CharField(
287         help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
288         required=False, allow_null=True)
289
290
291 class IdentifierInPnfSerializer(serializers.Serializer):
292     IdentifierInPnf = serializers.Serializer(help_text="An Identifier that is unique within respect to a PNF.")
293
294
295 class IdentifierInNsdSerializer(serializers.Serializer):
296     IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")
297
298
299 class PnfExtCpDataSerializer(serializers.Serializer):
300     cpInstanceI16 = IdentifierInPnfSerializer(help_text="Identifier of the CP. Shall be present for existing CP.",
301                                               required=False, allow_null=True)
302     cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
303                                       required=False, allow_null=True)
304     cpProtocolData = CpProtocolDataSerializer(help_text="Address assigned for this CP.",
305                                               required=False, allow_null=True, many=True)
306
307
308 class AddPnfDataSerializer(serializers.Serializer):
309     pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
310     pnfName = serializers.CharField(help_text="Name of the PNF.", required=True)
311     pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
312     pnfProfileId = serializers.CharField(
313         help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
314     cpData = PnfExtCpDataSerializer(help_text="Address assigned for the PNF external CP(s). ",
315                                     required=False, allow_null=True, many=True)
316
317
318 class ModifyPnfDataSerializer(serializers.Serializer):
319     pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True)
320     pnfName = serializers.CharField(help_text="Name of the PNF", required=False, allow_null=True)
321     cpData = serializers.ListField(
322         help_text="Address assigned for the PNF external CP(s).",
323         child=(PnfExtCpDataSerializer(
324             help_text="This type represents the configuration data on the external CP of the PNF.")),
325         required=False, allow_null=True)
326
327
328 class DateTimeSerializer(serializers.Serializer):
329     DateTime = serializers.Serializer(help_text="Date-time stamp.")
330
331
332 class UpdateNsReqSerializer(serializers.Serializer):
333     updateType = serializers.ChoiceField(help_text="The type of update.",
334                                          choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
335                                                   "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
336                                                   "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
337                                                   "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
338                                                   "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
339                                                   "MODIFY_PNF", "REMOVE_PNF"], required=True)
340     addVnfInstance = serializers.ListField(help_text="Identifies an existing VNF instance to be added to the NS "
341                                                      "instance.",
342                                            child=(VnfInstanceDataSerializer(help_text="Data of vnf instance",
343                                                                             required=True)),
344                                            required=False, allow_null=True)
345     removeVnfInstanceId = serializers.ListField(help_text="Identifies an existing VNF instance to be removed from "
346                                                           "the NS instance.", required=False, allow_null=True)
347     instantiateVnfData = serializers.ListField(help_text="Identifies the new VNF to be instantiated.",
348                                                child=(InstantiateVnfDataSerializer(help_text="Data of vnf instance",
349                                                                                    required=True)),
350                                                required=False, allow_null=True)
351     changeVnfFlavourData = serializers.ListField(help_text="Identifies the new DF of the VNF instance to be "
352                                                            "changed to.",
353                                                  child=(ChangeVnfFlavourDataSerizlizer(
354                                                      help_text="The type represents the information that is requested "
355                                                                "to be changed deployment flavour for an existing "
356                                                                "VNF instance.", required=True)),
357                                                  required=False, allow_null=True)
358     operateVnfData = serializers.ListField(help_text="This type represents a VNF instance for which the operational "
359                                                      "state needs to be changed and the requested new state.",
360                                            child=(OperateVnfDataSerializer(
361                                                help_text="This type represents a VNF instance for which the operational"
362                                                          " state needs to be changed and the requested new state",
363                                                          required=True)), required=False, allow_null=True)
364     modifyVnfInfoData = serializers.ListField(help_text="This type represents the information that is requested to be"
365                                                         " modified for a VNF instance. ",
366                                               child=(ModifyVnfInfoDataSerializer(
367                                                   help_text="This type represents the information that is requested to "
368                                                             "be modified for a VNF instance. ", required=True)),
369                                               required=False, allow_null=True)
370     changeExtVnfConnectivityData = serializers.ListField(help_text="Specifies the new external connectivity data of the"
371                                                                    "VNF instance to be changed",
372                                                          child=(ChangeExtVnfConnectivityDataSerializer(
373                                                              help_text="This type describes the information invoked by"
374                                                                        "the NFVO to change the external VNF "
375                                                                        "connectivity information maintained by"
376                                                                        " the VNFM.", required=True)),
377                                                          required=False, allow_null=True)
378     addSap = serializers.ListField(help_text="Identifies a new SAP to be added to the NS instance.",
379                                    child=(SapDataSerializer(help_text="This type represents the information related to "
380                                                                       "a SAP of a NS", required=True)),
381                                    required=False, allow_null=True)
382     removeSapId = serializers.ListField(help_text="The identifier an existing SAP to be removed from the "
383                                                   "NS instance", required=False, allow_null=True)
384     addNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to "
385                                                     "the NS instance", required=False, allow_null=True)
386     removeNestedNsId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be "
387                                                        "removed from the NS instance.",
388                                              required=False, allow_null=True)
389     assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(help_text="Specify the new NSD to be used for the NS "
390                                                                         "instance.", required=False, allow_null=True)
391     moveVnfInstanceData = serializers.ListField(help_text="Specify existing VNF instance to be moved from one NS "
392                                                           "instance to another NS instance",
393                                                 child=(MoveVnfInstanceDataSerializer()),
394                                                 required=False, allow_null=True)
395     addVnffg = serializers.ListField(help_text="The identifier of an existing nested NS instance to be added to the"
396                                                " NS instance.", required=False, allow_null=True)
397     removeVnffgId = serializers.ListField(help_text="The identifier of an existing nested NS instance to be removed "
398                                                     "from the NS instance", required=False, allow_null=True)
399     updateVnffg = serializers.ListField(help_text="Specify the new VNFFG Information data to be updated for a VNFFG"
400                                                   " of the NS Instance",
401                                         child=(UpdateVnffgDataSerializer(help_text="This type specifies the parameters "
402                                                                                    "used for the update of an existing "
403                                                                                    "VNFFG instance.", required=True)),
404                                         required=False, allow_null=True)
405     changeNsFlavourData = ChangeNsFlavourDataSerializer(
406         help_text="Specifies the new DF to be applied to the NS instance", required=False, allow_null=True)
407     addPnfData = serializers.ListField(help_text="Specifies the PNF to be added into the NS instance.",
408                                        child=(AddPnfDataSerializer(help_text="Serializer data of add pnf", required=True)),
409                                        required=False, allow_null=True)
410     modifyPnfData = serializers.ListField(help_text="Specifies the PNF to be modified in the NS instance.",
411                                           child=(ModifyPnfDataSerializer(
412                                               help_text="This type specifies an PNF to be modified in the NS instance.",
413                                               required=True)),
414                                           required=False, allow_null=True)
415     removePnfId = serializers.ListField(help_text="Identifier of the PNF to be deleted from the NS instance.",
416                                         required=False, allow_null=True)
417     updateTime = DateTimeSerializer(help_text="Timestamp indicating the update time of the NS",
418                                     required=False, allow_null=True)