aboutsummaryrefslogtreecommitdiffstats
path: root/lcm/ns/serializers/sol/update_serializers.py
blob: f953984d5f1466b437fcebdeb1c6c6e1bdca300e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# Copyright (c) 2018, CMCC Technologies Co., Ltd.

# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from rest_framework import serializers

from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
from lcm.ns.serializers.sol.ns_instance import NsCpHandleSerializer, NfpRuleSerializer
from lcm.ns.serializers.sol.cp_serializers import CpProtocolDataSerializer
from lcm.ns.serializers.sol.cp_serializers import IpAddressesDataSerialzier


class VnfInstanceDataSerializer(serializers.Serializer):
    vnfInstanceId = serializers.CharField(
        help_text="Specify the target NS instance where the VNF instances are moved to",
        required=True)
    vnfProfileId = serializers.CharField(
        help_text="Specify the VNF instance that is moved.",
        required=False,
        allow_null=True)


class InstantiateVnfDataSerializer(serializers.Serializer):
    vnfdId = serializers.CharField(
        help_text="Information sufficient to identify the VNFD which defines the VNF to be instantiated.",
        required=True)
    vnfFlavourId = serializers.CharField(
        help_text="Identifier of the VNF deployment flavour to be instantiated.",
        required=True)
    vnfInstantiationLevelId = serializers.CharField(
        help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
        required=False,
        allow_null=True)
    vnfInstanceName = serializers.CharField(
        help_text="Human-readable name of the VNF instance to be created.",
        required=False,
        allow_null=True)


class IpOverEthernetAddressDataSerializer(serializers.Serializer):
    macAddress = serializers.CharField(
        help_text="Mac address",
        required=False,
        allow_null=True)
    ipAddresses = IpAddressesDataSerialzier(
        help_text="List of IP addresses to assign to the extCP instance.",
        required=False,
        allow_null=True,
        many=True)


class VnfExtCpConfigSerializer(serializers.Serializer):
    cpInstanceId = serializers.CharField(
        help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
        required=False,
        allow_null=True)
    linkPortId = serializers.CharField(
        help_text="Identifier of a pre-conFigured link port to which the external CP will be associated.",
        required=False,
        allow_null=True)
    cpProtocolData = serializers.ListField(
        help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL",
        child=CpProtocolDataSerializer(
            help_text="This type represents network protocol data.",
            required=True),
        required=False,
        allow_null=True)


class VnfExtCpData(serializers.Serializer):
    cpdId = serializers.CharField(
        help_text="The identifier of the CPD in the VNFD.",
        required=True)
    cpConfig = serializers.ListField(
        help_text="List of instance data that need to be conFigured on the CP instances created from the respective CPD.",
        child=(VnfExtCpConfigSerializer(
            help_text="Config of vnf ext cp",
            required=True)),
        required=False,
        allow_null=True)


class ExtLinkPortDataSerializer(serializers.Serializer):
    id = serializers.CharField(
        help_text="Provided by the entity that has created the link port.",
        required=True)
    resourceHandle = ResourceHandleSerializer(
        help_text="Identifier(s) of the virtualised network resource(s) realizing the VL instance.",
        required=True)


class ExtVirtualLinkDataSerializer(serializers.Serializer):
    extVirtualLinkId = serializers.CharField(
        help_text="The identifier of the external VL instance, if provided.",
        required=False,
        allow_null=True)
    vimId = serializers.CharField(
        help_text="Identifier of the VIM that manages this resource.",
        required=False,
        allow_null=True)
    resourceProviderId = serializers.CharField(
        help_text="Identifies the entity responsible for the management of this resource.",
        required=False,
        allow_null=True)
    resourceId = serializers.CharField(
        help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
        required=True)
    extCps = serializers.ListField(
        help_text="External CPs of the VNF to be connected to this external VL.",
        child=VnfExtCpData(),
        required=False,
        allow_null=True)
    extLinkPorts = serializers.ListField(
        help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
        child=(ExtLinkPortDataSerializer(
            help_text="This type represents an externally provided link port to be used to connect a VNF external connection point to an external VL",
            required=True)),
        required=False,
        allow_null=True)


class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
    extManagedVirtualLinkId = serializers.CharField(
        help_text="The identifier of the externally-managed internal VL instance,if provided.",
        required=False,
        allow_null=True)
    virtualLinkDescId = serializers.CharField(
        help_text="The identifier of the VLD in the VNFD for this VL.",
        required=True)
    vimId = serializers.CharField(
        help_text="Identifier of the VIMthat manage this resource.",
        required=False,
        allow_null=True)
    resourceProviderId = serializers.CharField(
        help_text="Identifies the entity responsible for the management of this resource.",
        required=False,
        allow_null=True)
    resourceId = serializers.CharField(
        help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
        required=True)


class ChangeVnfFlavourDataSerizlizer(serializers.Serializer):
    vnfInstanceId = serializers.CharField(
        help_text="Identifier of the VNF instance to be modified.",
        required=True)
    newFlavourId = serializers.CharField(
        help_text="Identifier of the VNF deployment flavour to be instantiated.",
        required=True)
    instantiationLevelId = serializers.CharField(
        help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
        required=False,
        allow_null=True)
    extVirtualLinks = serializers.ListField(
        help_text="Information about external VLs to connect the VNF to.",
        child=ExtVirtualLinkDataSerializer(
            help_text="This type represents an external VL",
            required=True),
        required=False,
        allow_null=True)
    extManagedVirtualLinks = serializers.ListField(
        help_text="Information about internal VLs that are managed by NFVO.",
        child=ExtManagedVirtualLinkDataSerializer(
            help_text="This type represents an externally-managed internal VL.",
            required=True),
        required=False,
        allow_null=True)
    additionalParams = serializers.CharField(
        help_text="Additional input parameters for the flavour change process",
        required=False,
        allow_null=True)


class OperationalStatesSerializer(serializers.Serializer):
    OperationalStates = serializers.ChoiceField(
        help_text="State of operation",
        choices=["STARTED", "STOPPED"])


class StopTypeSerializer(serializers.Serializer):
    StopType = serializers.ChoiceField(
        help_text="Type of stop",
        choices=["FORCEFUL", "GRACEFUL"])


class OperateVnfDataSerializer(serializers.Serializer):
    vnfInstanceId = serializers.CharField(
        help_text="Identifier of the VNF instance.",
        required=True)
    changeStateTo = OperationalStatesSerializer(
        help_text="The desired operational state to change the VNF to.",
        required=True)
    stopType = StopTypeSerializer(
        help_text="It signals whether forceful or graceful stop is requested.",
        required=False,
        allow_null=True)
    gracefulStopTimeout = serializers.CharField(
        help_text="The time interval to wait for the VNF to be taken out of service during graceful stop.",
        required=False,
        allow_null=True)


class ModifyVnfInfoDataSerializer(serializers.Serializer):
    vnfInstanceId = serializers.UUIDField(
        help_text="Identifier of the VNF instance."
    )
    vnfInstanceName = serializers.CharField(
        help_text="New value of the 'vnfInstanceName' attribute in 'VnfInstance', or 'null' to remove the attribute.",
        max_length=255,
        required=False,
        allow_null=True,
        allow_blank=True)
    vnfInstanceDescription = serializers.CharField(
        help_text="If present, this attribute signals modifications of the 'vnfInstanceDescription' attribute in 'VnfInstance'",
        required=False,
        allow_null=True,
        allow_blank=True)
    vnfPkgId = serializers.UUIDField(
        help_text="New value of the 'vnfPkgId' attribute in 'VnfInstance' The value 'null' is not permitted.."
    )
    vnfConfigurableProperties = serializers.DictField(
        help_text="Modifications to entries in the 'vnfConfigurableProperties' list, as defined below this Table.",
        child=serializers.CharField(
            help_text="KeyValue Pairs",
            allow_blank=True),
        required=False,
        allow_null=True)
    metaData = serializers.DictField(
        help_text="If present, this attribute signals modifications of certain 'metadata' attribute in 'vnfInstance'.",
        child=serializers.CharField(
            help_text="KeyValue Pairs",
            allow_blank=True),
        required=False,
        allow_null=True)
    extensions = serializers.DictField(
        help_text="If present,this attribute signals modifications of certain 'extensions' attribute in 'vnfInstance'.",
        child=serializers.CharField(
            help_text="KeyValue Pairs",
            allow_blank=True),
        required=False,
        allow_null=True)


class ChangeExtVnfConnectivityDataSerializer(serializers.Serializer):
    vnfInstanceId = serializers.CharField(
        help_text="Identifier of the VNF instance.",
        required=True,
        allow_null=True)
    extVirtualLinks = serializers.ListField(
        help_text="Information about external VLs to change",
        child=ExtVirtualLinkDataSerializer(
            help_text="Data of ext virtual link",
            required=True),
        required=False,
        allow_null=True)
    additionalParams = serializers.CharField(
        help_text="Additional parameters passed by the OSS as input to the external connectivity change process",
        required=False,
        allow_null=True)


class SapDataSerializer(serializers.Serializer):
    sapdId = serializers.CharField(
        help_text="Reference to the SAPD for this SAP.",
        required=True)
    sapName = serializers.CharField(
        help_text="Human readable name for the SAP.",
        required=True)
    description = serializers.CharField(
        help_text="Human readable description for the SAP. ",
        required=True)
    sapProtocolData = serializers.ListField(
        help_text="Parameters for configuring the network protocols on the SAP.",
        child=CpProtocolDataSerializer(
            help_text="This type represents network protocol data.",
            required=True),
        required=False,
        allow_null=True)


class AssocNewNsdVersionDataSerializer(serializers.Serializer):
    newNsdId = serializers.CharField(
        help_text="Identifier of the new NSD version that is to be associated to the NS instance.",
        required=True)


class MoveVnfInstanceDataSerializer(serializers.Serializer):
    targetNsInstanceId = serializers.CharField(
        help_text="Specify the target NS instance where the VNF instances are moved to.",
        required=True)
    vnfInstanceId = serializers.CharField(
        help_text="Specify the VNF instance that is moved.",
        required=False,
        allow_null=True)


class PortRangeSerializer(serializers.Serializer):
    lowerPort = serializers.CharField(
        help_text="Identifies the lower bound of the port range.",
        required=True)
    upperPort = serializers.CharField(
        help_text="Identifies the upper bound of the port range ",
        required=True)


class NfpDataSerializer(serializers.Serializer):
    nfpInfoId = serializers.CharField(
        help_text="Identifier of the NFP to be modified.",
        required=False,
        allow_null=True)
    nfpName = serializers.CharField(
        help_text="Human readable name for the NFP.",
        required=False,
        allow_null=True)
    description = serializers.CharField(
        help_text="Human readable description for the NFP.",
        required=False,
        allow_null=True)
    nsCpHandle = serializers.ListField(
        help_text="HanIdentifier(s) of the CPs and SAPs which the NFP passes by.",
        child=NsCpHandleSerializer(
            help_text="This type represents an identifier of the CP or SAP instance.",
            required=True),
        required=False,
        allow_null=True)
    nfpRule = NfpRuleSerializer(
        help_text="NFP classification and selection rule.",
        required=False,
        allow_null=True)


class UpdateVnffgDataSerializer(serializers.Serializer):
    vnffgInfoId = serializers.CharField(
        help_text="Identifier of an existing VNFFG to be updated for the NS Instance.",
        required=True)
    nfp = serializers.ListField(
        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.",
        child=NfpDataSerializer(),
        required=False,
        allow_null=True)
    nfpInfoId = serializers.ListField(
        help_text="Identifiers of the NFP to be deleted from a given VNFFG.",
        child=serializers.CharField(help_text="Identifier of the NFP to be deleted from a given VNFFG."),
        required=False,
        allow_null=True)


class ChangeNsFlavourDataSerializer(serializers.Serializer):
    newNsFlavourId = serializers.CharField(
        help_text="Identifier of the new NS DF to apply to this NS instance.",
        required=True)
    instantiationLevelId = serializers.CharField(
        help_text="Identifier of the instantiation level of the deployment flavour to be instantiated.",
        required=False,
        allow_null=True)


# class IdentifierInPnfSerializer(serializers.Serializer):
#    IdentifierInPnf = serializers.Serializer(
#        help_text="An Identifier that is unique within respect to a PNF.")


# class IdentifierInNsdSerializer(serializers.Serializer):
#    IdentifierInNsd = serializers.Serializer(help_text="An identifier that is unique within a NS descriptor")


class PnfExtCpDataSerializer(serializers.Serializer):
    cpInstanceId = serializers.CharField(  # sol 2.05.01 cpInstanceI16 typo
        help_text="Identifier of the CP. Shall be present for existing CP.",
        required=False,
        allow_null=True)
    cpdId = serializers.CharField(
        help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
        required=False, allow_null=True)
    cpProtocolData = CpProtocolDataSerializer(
        help_text="Address assigned for this CP.",
        required=False,
        allow_null=True,
        many=True)


class AddPnfDataSerializer(serializers.Serializer):
    pnfId = serializers.CharField(
        help_text="Identifier of the PNF.",
        required=True)
    pnfName = serializers.CharField(
        help_text="Name of the PNF.",
        required=True)
    pnfdId = serializers.CharField(
        help_text="Identifier of the PNFD on which the PNF is based.",
        required=True)
    pnfProfileId = serializers.CharField(
        help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.",
        required=True)
    cpData = PnfExtCpDataSerializer(
        help_text="Address assigned for the PNF external CP(s).",
        required=False,
        allow_null=True,
        many=True)


class ModifyPnfDataSerializer(serializers.Serializer):
    pnfId = serializers.CharField(
        help_text="Identifier of the PNF.",
        required=True)
    pnfName = serializers.CharField(
        help_text="Name of the PNF",
        required=False,
        allow_null=True)
    cpData = serializers.ListField(
        help_text="Address assigned for the PNF external CP(s).",
        child=PnfExtCpDataSerializer(
            help_text="This type represents the configuration data on the external CP of the PNF."),
        required=False,
        allow_null=True)


# class DateTimeSerializer(serializers.Serializer):
#    DateTime = serializers.Serializer(help_text="Date-time stamp.")


class UpdateNsReqSerializer(serializers.Serializer):
    updateType = serializers.ChoiceField(
        help_text="The type of update.",
        choices=["ADD_VNF", "REMOVE_VNF", "INSTANTIATE_VNF", "CHANGE_VNF_DF",
                 "OPERATE_VNF", "MODIFY_VNF_INFORMATION",
                 "CHANGE_EXTERNAL_VNF_CONNECTIVITY", "REMOVE_SAP", "ADD_NESTED_NS",
                 "REMOVE_NESTED_NS", "ASSOC_NEW_NSD_VERSION", "MOVE_VNF", "ADD_VNFFG",
                 "REMOVE_VNFFG", "UPDATE_VNFFG", "CHANGE_NS_DF", "ADD_PNF",
                 "MODIFY_PNF", "REMOVE_PNF"],
        required=True)
    addVnfInstance = serializers.ListField(
        help_text="Identifies an existing VNF instance to be added to the NS instance.",
        child=VnfInstanceDataSerializer(
            help_text="Data of vnf instance",
            required=True),
        required=False,
        allow_null=True)
    removeVnfInstanceId = serializers.ListField(
        help_text="Identifies an existing VNF instance to be removed from the NS instance.",
        child=serializers.CharField(),
        required=False,
        allow_null=True)
    instantiateVnfData = serializers.ListField(
        help_text="Identifies the new VNF to be instantiated.",
        child=(InstantiateVnfDataSerializer(
            help_text="Data of vnf instance.",
            required=True)),
        required=False,
        allow_null=True)
    changeVnfFlavourData = serializers.ListField(
        help_text="Identifies the new DF of the VNF instance to be changed to.",
        child=(ChangeVnfFlavourDataSerizlizer(
            help_text="The type represents the information that is requested to be changed deployment flavour for an existing VNF instance.",
            required=True)),
        required=False,
        allow_null=True)
    operateVnfData = serializers.ListField(
        help_text="This type represents a VNF instance for which the operational state needs to be changed and the requested new state.",
        child=(OperateVnfDataSerializer(
            help_text="This type represents a VNF instance for which the operational state needs to be changed and the requested new state",
            required=True)),
        required=False,
        allow_null=True)
    modifyVnfInfoData = serializers.ListField(
        help_text="This type represents the information that is requested to be modified for a VNF instance. ",
        child=(ModifyVnfInfoDataSerializer(
            help_text="This type represents the information that is requested to be modified for a VNF instance. ",
            required=True)),
        required=False,
        allow_null=True)
    changeExtVnfConnectivityData = serializers.ListField(
        help_text="Specifies the new external connectivity datas of the VNF instance to be changed.",
        child=ChangeExtVnfConnectivityDataSerializer(
            help_text="This type describes the information invoked by the NFVO to change the external VNF connectivity information maintained by the VNFM.",
            required=True),
        required=False,
        allow_null=True)
    addSap = serializers.ListField(
        help_text="Identifies a new SAP to be added to the NS instance.",
        child=SapDataSerializer(help_text="This type represents the information related to a SAP of a NS",
                                required=True),
        required=False,
        allow_null=True)
    removeSapId = serializers.ListField(
        help_text="The identifier an existing SAP to be removed from the NS instance",
        required=False,
        allow_null=True)
    addNestedNsId = serializers.ListField(
        help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
        required=False,
        allow_null=True)
    removeNestedNsId = serializers.ListField(
        help_text="The identifier of an existing nested NS instance to be removed from the NS instance.",
        required=False,
        allow_null=True)
    assocNewNsdVersionData = AssocNewNsdVersionDataSerializer(
        help_text="Specify the new NSD to be used for the NS instance.",
        required=False,
        allow_null=True)
    moveVnfInstanceData = serializers.ListField(
        help_text="Specify existing VNF instance to be moved from one NS instance to another NS instance",
        child=MoveVnfInstanceDataSerializer(),
        required=False,
        allow_null=True)
    addVnffg = serializers.ListField(
        help_text="The identifier of an existing nested NS instance to be added to the NS instance.",
        required=False,
        allow_null=True)
    removeVnffgId = serializers.ListField(
        help_text="The identifier of an existing nested NS instance to be removed from the NS instance",
        child=serializers.CharField(),
        required=False,
        allow_null=True)
    updateVnffg = serializers.ListField(
        help_text="Specify the new VNFFG Information data to be updated for a VNFFG of the NS Instance.",
        child=UpdateVnffgDataSerializer(
            help_text="This type specifies the parameters used for the update of an existing VNFFG instance.",
            required=True),
        required=False,
        allow_null=True)
    changeNsFlavourData = ChangeNsFlavourDataSerializer(
        help_text="Specifies the new DF to be applied to the NS instance.",
        required=False,
        allow_null=True)
    addPnfData = serializers.ListField(
        help_text="Specifies the PNF to be added into the NS instance.",
        child=AddPnfDataSerializer(
            help_text="Serializer data of add PNF",
            required=True),
        required=False,
        allow_null=True)
    modifyPnfData = serializers.ListField(
        help_text="Specifies the PNF to be modified in the NS instance.",
        child=ModifyPnfDataSerializer(
            help_text="This type specifies an PNF to be modified in the NS instance.",
            required=True),
        required=False,
        allow_null=True)
    removePnfId = serializers.ListField(
        help_text="Identifier of the PNF to be deleted from the NS instance.",
        required=False,
        allow_null=True)
    updateTime = serializers.CharField(
        help_text="Timestamp indicating the update time of the NS",
        required=False
    )