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