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