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