a2eae1b77e312edeaad9c162c87483346fc030c3
[vfc/nfvo/lcm.git] / lcm / v2 / serializers.py
1 # Copyright 2018 ZTE Corporation.
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
18 class ResourceHandleSerializer(serializers.Serializer):
19     vimConnectionId = serializers.CharField(
20         help_text="Identifier of the VIM connection to manage the resource.",
21         required=False,
22         allow_null=True,
23         allow_blank=True
24     )
25     resourceProviderId = serializers.CharField(
26         help_text="Identifier of the entity responsible for the management of the resource.",
27         required=False,
28         allow_null=True,
29         allow_blank=True
30     )
31     resourceId = serializers.CharField(
32         help_text="Identifier of the resource in the scope of the VIM or the resource provider.",
33         required=True
34     )
35     vimLevelResourceType = serializers.CharField(
36         help_text="Type of the resource in the scope of the VIM or the resource provider.",
37         required=False,
38         allow_null=True,
39         allow_blank=True
40     )
41
42
43 class ResourceDefinitionSerializer(serializers.Serializer):
44     id = serializers.CharField(
45         help_text="Identifier of this ResourceDefinition, unique at least within the scope of the GrantRequest.",
46         required=True
47     )
48     type = serializers.ChoiceField(
49         help_text="Type of the resource definition referenced.",
50         choices=["COMPUTE", "VL", "STORAGE", "LINKPORT"],
51         required=True
52     )
53     vduId = serializers.CharField(
54         help_text="Reference to the related VDU in the VNFD applicable to this resource.",
55         required=False,
56         allow_null=True,
57         allow_blank=True
58     )
59     resourceTemplateId = serializers.CharField(
60         help_text="Reference to a resource template(such as VnfVirtualLinkDesc) in the VNFD.",
61         required=False,
62         allow_null=True,
63         allow_blank=True
64     )
65     resource = ResourceHandleSerializer(
66         help_text="Resource information for an existing resource.",
67         required=False,
68         allow_null=True
69     )
70
71
72 class GrantRequestSerializer(serializers.Serializer):
73     vnfInstanceId = serializers.CharField(
74         help_text="Identifier of the VNF instance which this grant request is related to.",
75         required=True
76     )
77     vnfLcmOpOccId = serializers.CharField(
78         help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
79         required=False,
80         allow_null=True,
81         allow_blank=True
82     )
83     vnfdId = serializers.CharField(
84         help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
85         required=False,
86         allow_null=True,
87         allow_blank=True
88     )
89     flavourId = serializers.CharField(
90         help_text="Identifier of the VNF deployment flavour of the VNFD that defines the VNF for which the LCM operation is to be granted.",
91         required=False,
92         allow_null=True,
93         allow_blank=True
94     )
95     operation = serializers.ChoiceField(
96         help_text="The lifecycle management operation for which granting is requested.",
97         choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
98         required=True
99     )
100     isAutomaticInvocation = serializers.BooleanField(
101         help_text="Set to true if this VNF LCM operation occurrence has been triggered by an automated procedure inside the VNFM, set to false otherwise.",
102         required=True
103     )
104     instantiationLevelId = serializers.CharField(
105         help_text="If operation=INSTANTIATE, the identifier of the instantiation level may be provided as an alternative way to define the resources to be added.",
106         required=False,
107         allow_null=True,
108         allow_blank=True
109     )
110     addResources = ResourceDefinitionSerializer(
111         help_text="List of resource definitions in the VNFD for resources to be added by the LCM operation.",
112         many=True
113     )
114     tempResources = ResourceDefinitionSerializer(
115         help_text="List of resource definitions in the VNFD for resources to be temporarily instantiated during the runtime of the LCM operation.",
116         many=True
117     )
118     removeResources = ResourceDefinitionSerializer(
119         help_text="Provides the definitions of resources to be removed by the LCM operation.",
120         many=True
121     )
122     updateResources = ResourceDefinitionSerializer(
123         help_text="Provides the definitions of resources to be modified by the LCM operation.",
124         many=True
125     )
126
127
128 class VimConnectionInfoSerializer(serializers.Serializer):
129     id = serializers.CharField(
130         help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
131         required=True
132     )
133     vimId = serializers.CharField(
134         help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
135         required=False,
136         allow_null=True,
137         allow_blank=True
138     )
139     vimType = serializers.CharField(
140         help_text="Discriminator for the different types of the VIM information.",
141         required=False,
142         allow_null=True,
143         allow_blank=True
144     )
145     interfaceInfo = serializers.DictField(
146         help_text="Information about the interface or interfaces to the VIM.",
147         child=serializers.CharField(help_text="Interface Info", allow_blank=True),
148         required=False,
149         allow_null=True
150     )
151     accessInfo = serializers.DictField(
152         help_text="Authentication credentials for accessing the VIM.",
153         child=serializers.CharField(help_text="Access Info", allow_blank=True),
154         required=False,
155         allow_null=True
156     )
157     extra = serializers.DictField(
158         help_text="VIM type specific additional information.",
159         child=serializers.CharField(help_text="Extra", allow_blank=True),
160         required=False,
161         allow_null=True
162     )
163
164
165 class ZoneInfoSerializer(serializers.Serializer):
166     id = serializers.CharField(
167         help_text="The identifier of this ZoneInfo instance, for the purpose of referencing it from other structures in the Grant structure.",
168         required=True
169     )
170     zoneId = serializers.CharField(
171         help_text="The identifier of the resource zone, as managed by the resource management layer(typically, the VIM).",
172         required=False,
173         allow_null=True,
174         allow_blank=True
175     )
176     vimConnectionId = serializers.CharField(
177         help_text="Identifier of the connection to the VIM that manages the resource zone.",
178         required=False,
179         allow_null=True,
180         allow_blank=True
181     )
182     resourceProviderId = serializers.CharField(
183         help_text="Identifies the entity responsible for the management the resource zone.",
184         required=False,
185         allow_null=True,
186         allow_blank=True
187     )
188
189
190 class ZoneGroupInfoSerializer(serializers.Serializer):
191     zoneId = serializers.ListSerializer(
192         help_text="References of identifiers of ZoneInfo structures.",
193         child=serializers.CharField(help_text="IdentifierLocal", allow_blank=True),
194         required=False,
195         allow_null=True
196     )
197
198
199 class GrantInfoSerializer(serializers.Serializer):
200     resourceDefinitionId = serializers.CharField(
201         help_text="Identifier of the related ResourceDefinition from the related GrantRequest.",
202         required=True
203     )
204     reservationId = serializers.CharField(
205         help_text="The reservation identifier applicable to the VNFC/VirtualLink/VirtualStorage.",
206         required=False,
207         allow_null=True,
208         allow_blank=True
209     )
210     vimConnectionId = serializers.CharField(
211         help_text="Identifier of the VIM connection to be used to manage this resource.",
212         required=False,
213         allow_null=True,
214         allow_blank=True
215     )
216     resourceProviderId = serializers.CharField(
217         help_text="Identifies the entity responsible for the management of the virtualised resource.",
218         required=False,
219         allow_null=True,
220         allow_blank=True
221     )
222     zoneId = serializers.CharField(
223         help_text="Reference to the identifier of the ZoneInfo in the Grant.",
224         required=False,
225         allow_null=True,
226         allow_blank=True
227     )
228     resourceGroupId = serializers.CharField(
229         help_text="Identifier of the infrastructure resource group.",
230         required=False,
231         allow_null=True,
232         allow_blank=True
233     )
234
235
236 class VimComputeResourceFlavourSerializer(serializers.Serializer):
237     vimConnectionId = serializers.CharField(
238         help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
239         required=False,
240         allow_null=True,
241         allow_blank=True
242     )
243     resourceProviderId = serializers.CharField(
244         help_text="Identifies the entity responsible for the management of the virtualised resource.",
245         required=False,
246         allow_null=True,
247         allow_blank=True
248     )
249     vnfdVirtualComputeDescId = serializers.CharField(
250         help_text="Identifier which references the virtual compute descriptor in the VNFD that maps to this flavour.",
251         required=False,
252         allow_null=True,
253         allow_blank=True
254     )
255     vimFlavourId = serializers.CharField(
256         help_text="Identifier of the compute resource flavour in the resource management layer (i.e. VIM).",
257         required=False,
258         allow_null=True,
259         allow_blank=True
260     )
261
262
263 class VimSoftwareImageSerializer(serializers.Serializer):
264     vimConnectionId = serializers.CharField(
265         help_text="Identifier of the VIM connection to access the flavour referenced in this structure.",
266         required=False,
267         allow_null=True,
268         allow_blank=True
269     )
270     resourceProviderId = serializers.CharField(
271         help_text="Identifies the entity responsible for the management of the virtualised resource.",
272         required=False,
273         allow_null=True,
274         allow_blank=True
275     )
276     vnfdSoftwareImageId = serializers.CharField(
277         help_text="Identifier which references the software image descriptor in the VNFD.",
278         required=False,
279         allow_null=True,
280         allow_blank=True
281     )
282     vimSoftwareImageId = serializers.CharField(
283         help_text="Identifier of the software image in the resource management layer (i.e. VIM).",
284         required=False,
285         allow_null=True,
286         allow_blank=True
287     )
288
289
290 class VimAssetsSerializer(serializers.Serializer):
291     computeResourceFlavours = VimComputeResourceFlavourSerializer(
292         help_text="Mappings between virtual compute descriptors defined in the VNFD and compute resource flavours managed in the VIM.",
293         many=True
294     )
295     softwareImages = VimSoftwareImageSerializer(
296         help_text="Mappings between software images defined in the VNFD and software images managed in the VIM.",
297         many=True
298     )
299
300
301 class AddressRangeSerializer(serializers.Serializer):
302     minAddress = serializers.CharField(
303         help_text="Lowest IP address belonging to the range.",
304         required=True
305     )
306     maxAddress = serializers.CharField(
307         help_text="Highest IP address belonging to the range.",
308         required=True
309     )
310
311
312 class IpAddresseSerializer(serializers.Serializer):
313     type = serializers.ChoiceField(
314         help_text="The type of the IP addresses.",
315         choices=["IPV4", "IPV6"],
316         required=True
317     )
318     fixedAddresses = serializers.ListSerializer(
319         help_text="Fixed addresses to assign.",
320         child=serializers.CharField(help_text="IpAddress"),
321         required=False,
322         allow_null=True
323     )
324     numDynamicAddresses = serializers.IntegerField(
325         help_text="Number of dynamic addresses to assign.",
326         required=True
327     )
328     addressRange = AddressRangeSerializer(
329         help_text="An IP address range to be used, e.g. in case of egress connections.",
330         required=False,
331         allow_null=True
332     )
333     subnetId = serializers.CharField(
334         help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
335         required=False,
336         allow_null=True,
337         allow_blank=True
338     )
339
340
341 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
342     macAddress = serializers.CharField(
343         help_text="MAC address.",
344         required=False,
345         allow_null=True,
346         allow_blank=True
347     )
348     ipAddresses = IpAddresseSerializer(
349         help_text="List of IP addresses to assign to the CP instance.",
350         many=True
351     )
352
353
354 class CpProtocolDataSerializer(serializers.Serializer):
355     layerProtocol = serializers.ChoiceField(
356         help_text="Identifier of layer(s) and protocol(s).",
357         choices=["IP_OVER_ETHERNET"],
358         required=True
359     )
360     ipOverEthernet = IpOverEthernetAddressDataSerializer(
361         help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
362         required=False,
363         allow_null=True,
364     )
365
366
367 class VnfExtCpConfigSerializer(serializers.Serializer):
368     cpInstanceId = serializers.CharField(
369         help_text="Identifier of the external CP instance to which this set of configuration parameters is requested to be applied.",
370         required=False,
371         allow_null=True,
372         allow_blank=True
373     )
374     linkPortId = serializers.CharField(
375         help_text="Identifier of a pre-configured link port to which the external CP will be associated.",
376         required=False,
377         allow_null=True,
378         allow_blank=True
379     )
380     cpProtocolData = CpProtocolDataSerializer(
381         help_text="Parameters for configuring the network protocols on the link port that connects the CP to a VL.",
382         many=True
383     )
384
385
386 class VnfExtCpDataSerializer(serializers.Serializer):
387     cpdId = serializers.CharField(
388         help_text="The identifier of the CPD in the VNFD.",
389         required=True
390     )
391     cpConfig = VnfExtCpConfigSerializer(
392         help_text="List of instance data that need to be configured on the CP instances created from the respective CPD.",
393         many=True
394     )
395
396
397 class ExtLinkPortDataSerializer(serializers.Serializer):
398     id = serializers.CharField(
399         help_text="Identifier of this link port as provided by the entity that has created the link port.",
400         required=True
401     )
402     resourceHandle = serializers.CharField(
403         help_text="Reference to the virtualised resource realizing this link port.",
404         required=True
405     )
406
407
408 class ExtVirtualLinkDataSerializer(serializers.Serializer):
409     id = serializers.CharField(
410         help_text="The identifier of the external VL instance.",
411         required=True
412     )
413     vimConnectionId = serializers.CharField(
414         help_text="Identifier of the VIM connection to manage this resource.",
415         required=False,
416         allow_null=True,
417         allow_blank=True
418     )
419     resourceProviderId = serializers.CharField(
420         help_text="Identifies the entity responsible for the management of this resource.",
421         required=False,
422         allow_null=True,
423         allow_blank=True
424     )
425     resourceId = serializers.CharField(
426         help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
427         required=True
428     )
429     extCps = VnfExtCpDataSerializer(
430         help_text="External CPs of the VNF to be connected to this external VL.",
431         many=True
432     )
433     extLinkPorts = ExtLinkPortDataSerializer(
434         help_text="Externally provided link ports to be used to connect external connection points to this external VL.",
435         many=True
436     )
437
438
439 class ExtManagedVirtualLinkDataSerializer(serializers.Serializer):
440     id = serializers.CharField(
441         help_text="The identifier of the externally-managed internal VL instance.",
442         required=True
443     )
444     virtualLinkDescId = serializers.CharField(
445         help_text="The identifier of the VLD in the VNFD for this VL.",
446         required=True
447     )
448     vimConnectionId = serializers.CharField(
449         help_text="Identifier of the VIM connection to manage this resource.",
450         required=False,
451         allow_null=True,
452         allow_blank=True
453     )
454     resourceProviderId = serializers.CharField(
455         help_text="Identifies the entity responsible for the management of this resource.",
456         required=False,
457         allow_null=True,
458         allow_blank=True
459     )
460     resourceId = serializers.CharField(
461         help_text="The identifier of the resource in the scope of the VIM or the resource provider.",
462         required=True
463     )
464
465
466 class LinkSerializer(serializers.Serializer):
467     href = serializers.CharField(
468         help_text="URI of the referenced resource.",
469         required=True
470     )
471
472
473 class GrantLinksSerializer(serializers.Serializer):
474     self = LinkSerializer(
475         help_text="URI of this resource.",
476         required=True
477     )
478     vnfLcmOpOcc = LinkSerializer(
479         help_text="Related VNF lifecycle management operation occurrence.",
480         required=True
481     )
482     vnfInstance = LinkSerializer(
483         help_text="Related VNF instance.",
484         required=True
485     )
486
487
488 class GrantSerializer(serializers.Serializer):
489     id = serializers.CharField(
490         help_text="Identifier of the grant.",
491         required=True
492     )
493     vnfInstanceId = serializers.CharField(
494         required=True
495     )
496     vnfLcmOpOccId = serializers.CharField(
497         help_text="Identifier of the related VNF lifecycle management operation occurrence.",
498         required=False,
499         allow_null=True,
500         allow_blank=True
501     )
502     vimConnections = VimConnectionInfoSerializer(
503         help_text="Provides information regarding VIM connections that are approved to be used by the VNFM to allocate resources.",
504         many=True
505     )
506     zones = ZoneInfoSerializer(
507         help_text="Identifies resource zones where the resources are approved to be allocated by the VNFM.",
508         many=True
509     )
510     zoneGroups = ZoneGroupInfoSerializer(
511         help_text="Information about groups of resource zones.",
512         many=True
513     )
514     computeReservationId = serializers.CharField(
515         help_text="Information that identifies a reservation applicable to the compute resource requirements.",
516         required=False,
517         allow_null=True,
518         allow_blank=True
519     )
520     networkReservationId = serializers.CharField(
521         help_text="Information that identifies a reservation applicable to the network resource requirements.",
522         required=False,
523         allow_null=True,
524         allow_blank=True
525     )
526     storageReservationId = serializers.CharField(
527         help_text="Information that identifies a reservation applicable to the storage resource requirements.",
528         required=False,
529         allow_null=True,
530         allow_blank=True
531     )
532     addResources = GrantInfoSerializer(
533         help_text="List of resources that are approved to be added.",
534         many=True
535     )
536     tempResources = GrantInfoSerializer(
537         help_text="List of resources that are approved to be temporarily instantiated during the runtime of the lifecycle operation.",
538         many=True
539     )
540     removeResources = GrantInfoSerializer(
541         help_text="List of resources that are approved to be removed.",
542         many=True
543     )
544     updateResources = GrantInfoSerializer(
545         help_text="List of resources that are approved to be modified.",
546         many=True
547     )
548     vimAssets = VimAssetsSerializer(
549         help_text="Information about assets for the VNF that are managed by the NFVO in the VIM.",
550         required=False,
551         allow_null=True
552     )
553     extVirtualLinks = ExtVirtualLinkDataSerializer(
554         help_text="Information about external VLs to connect the VNF to.",
555         many=True
556     )
557     extManagedVirtualLinks = ExtManagedVirtualLinkDataSerializer(
558         help_text="Information about internal VLs that are managed by other entities than the VNFM.",
559         many=True
560     )
561     _links = GrantLinksSerializer(
562         help_text="Links to resources related to this resource.",
563         required=True
564     )