osm_nbi/validation.py |
---|
1 |
|
# -*- coding: utf-8 -*- |
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 |
12 |
|
# implied. |
13 |
|
# See the License for the specific language governing permissions and |
14 |
|
# limitations under the License. |
15 |
|
|
16 |
1 |
from jsonschema import validate as js_v, exceptions as js_e |
17 |
1 |
from http import HTTPStatus |
18 |
1 |
from copy import deepcopy |
19 |
1 |
from uuid import UUID # To test for valid UUID |
20 |
|
|
21 |
1 |
__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>" |
22 |
1 |
__version__ = "0.1" |
23 |
1 |
version_date = "Mar 2018" |
24 |
|
|
25 |
1 |
""" |
26 |
|
Validator of input data using JSON schemas for those items that not contains an OSM yang information model |
27 |
|
""" |
28 |
|
|
29 |
|
# Basis schemas |
30 |
1 |
patern_name = "^[ -~]+$" |
31 |
1 |
shortname_schema = { |
32 |
|
"type": "string", |
33 |
|
"minLength": 1, |
34 |
|
"maxLength": 60, |
35 |
|
"pattern": "^[^,;()\\.\\$'\"]+$", |
36 |
|
} |
37 |
1 |
passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60} |
38 |
1 |
user_passwd_schema = { |
39 |
|
"type": "string", |
40 |
|
"pattern": "^.*(?=.{8,})((?=.*[!@#$%^&*()\\-_=+{};:,<.>]){1})(?=.*\\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$", |
41 |
|
} |
42 |
1 |
name_schema = { |
43 |
|
"type": "string", |
44 |
|
"minLength": 1, |
45 |
|
"maxLength": 255, |
46 |
|
"pattern": "^[^,;()'\"]+$", |
47 |
|
} |
48 |
1 |
string_schema = {"type": "string", "minLength": 1, "maxLength": 255} |
49 |
1 |
xml_text_schema = { |
50 |
|
"type": "string", |
51 |
|
"minLength": 1, |
52 |
|
"maxLength": 1000, |
53 |
|
"pattern": "^[^']+$", |
54 |
|
} |
55 |
1 |
description_schema = { |
56 |
|
"type": ["string", "null"], |
57 |
|
"maxLength": 255, |
58 |
|
"pattern": "^[^'\"]+$", |
59 |
|
} |
60 |
1 |
long_description_schema = { |
61 |
|
"type": ["string", "null"], |
62 |
|
"maxLength": 3000, |
63 |
|
"pattern": "^[^'\"]+$", |
64 |
|
} |
65 |
1 |
id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36} |
66 |
1 |
bool_schema = {"type": "boolean"} |
67 |
1 |
null_schema = {"type": "null"} |
68 |
|
# "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" |
69 |
1 |
id_schema = { |
70 |
|
"type": "string", |
71 |
|
"pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$", |
72 |
|
} |
73 |
1 |
time_schema = { |
74 |
|
"type": "string", |
75 |
|
"pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}", |
76 |
|
} |
77 |
1 |
pci_schema = { |
78 |
|
"type": "string", |
79 |
|
"pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$", |
80 |
|
} |
81 |
|
# allows [] for wildcards. For that reason huge length limit is set |
82 |
1 |
pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\\[\\]]{12,40}$"} |
83 |
1 |
http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"} |
84 |
1 |
bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"} |
85 |
1 |
memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"} |
86 |
1 |
integer0_schema = {"type": "integer", "minimum": 0} |
87 |
1 |
integer1_schema = {"type": "integer", "minimum": 1} |
88 |
1 |
path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"} |
89 |
1 |
vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095} |
90 |
1 |
vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095} |
91 |
1 |
mac_schema = { |
92 |
|
"type": "string", |
93 |
|
"pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$", |
94 |
|
} # must be unicast: LSB bit of MSB byte ==0 |
95 |
1 |
dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"} |
96 |
|
# mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"} |
97 |
1 |
ip_schema = { |
98 |
|
"type": "string", |
99 |
|
"pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", |
100 |
|
} |
101 |
1 |
ipv6_schema = { |
102 |
|
"type": "string", |
103 |
|
"pattern": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))", # noqa: W605 |
104 |
|
} |
105 |
1 |
ip_prefix_schema = { |
106 |
|
"type": "string", |
107 |
|
"pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" |
108 |
|
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$", |
109 |
|
} |
110 |
1 |
port_schema = {"type": "integer", "minimum": 1, "maximum": 65534} |
111 |
1 |
object_schema = {"type": "object"} |
112 |
1 |
schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2} |
113 |
|
# schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]} |
114 |
1 |
log_level_schema = { |
115 |
|
"type": "string", |
116 |
|
"enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], |
117 |
|
} |
118 |
1 |
checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"} |
119 |
1 |
size_schema = {"type": "integer", "minimum": 1, "maximum": 100} |
120 |
1 |
array_edition_schema = { |
121 |
|
"type": "object", |
122 |
|
"patternProperties": {"^\\$": {}}, |
123 |
|
"additionalProperties": False, |
124 |
|
"minProperties": 1, |
125 |
|
} |
126 |
1 |
nameshort_list_schema = { |
127 |
|
"type": "array", |
128 |
|
"minItems": 1, |
129 |
|
"items": shortname_schema, |
130 |
|
} |
131 |
|
|
132 |
1 |
description_list_schema = { |
133 |
|
"type": "array", |
134 |
|
"minItems": 1, |
135 |
|
"items": description_schema, |
136 |
|
} |
137 |
|
|
138 |
1 |
ns_instantiate_vdu = { |
139 |
|
"title": "ns action instantiate input schema for vdu", |
140 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
141 |
|
"type": "object", |
142 |
|
"properties": { |
143 |
|
"id": name_schema, |
144 |
|
"vim-flavor-id": name_schema, |
145 |
|
"instance_name": name_schema, |
146 |
|
"volume": { |
147 |
|
"type": "array", |
148 |
|
"minItems": 1, |
149 |
|
"items": { |
150 |
|
"type": "object", |
151 |
|
"properties": { |
152 |
|
"name": name_schema, |
153 |
|
"vim-volume-id": name_schema, |
154 |
|
}, |
155 |
|
"required": ["name", "vim-volume-id"], |
156 |
|
"additionalProperties": False, |
157 |
|
}, |
158 |
|
}, |
159 |
|
"interface": { |
160 |
|
"type": "array", |
161 |
|
"minItems": 1, |
162 |
|
"items": { |
163 |
|
"type": "object", |
164 |
|
"properties": { |
165 |
|
"name": name_schema, |
166 |
|
"ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
167 |
|
"mac-address": mac_schema, |
168 |
|
"floating-ip-required": bool_schema, |
169 |
|
}, |
170 |
|
"required": ["name"], |
171 |
|
"additionalProperties": False, |
172 |
|
}, |
173 |
|
}, |
174 |
|
}, |
175 |
|
"required": ["id"], |
176 |
|
"additionalProperties": False, |
177 |
|
} |
178 |
|
|
179 |
1 |
ip_profile_dns_schema = { |
180 |
|
"type": "array", |
181 |
|
"minItems": 1, |
182 |
|
"items": { |
183 |
|
"type": "object", |
184 |
|
"properties": { |
185 |
|
"address": {"oneOf": [ip_schema, ipv6_schema]}, |
186 |
|
}, |
187 |
|
"required": ["address"], |
188 |
|
"additionalProperties": False, |
189 |
|
}, |
190 |
|
} |
191 |
|
|
192 |
1 |
ip_profile_dhcp_schema = { |
193 |
|
"type": "object", |
194 |
|
"properties": { |
195 |
|
"enabled": {"type": "boolean"}, |
196 |
|
"count": integer1_schema, |
197 |
|
"start-address": ip_schema, |
198 |
|
}, |
199 |
|
"additionalProperties": False, |
200 |
|
} |
201 |
|
|
202 |
1 |
ip_profile_schema = { |
203 |
|
"title": "ip profile validation schema", |
204 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
205 |
|
"type": "object", |
206 |
|
"properties": { |
207 |
|
"ip-version": {"enum": ["ipv4", "ipv6"]}, |
208 |
|
"subnet-address": {"oneOf": [null_schema, ip_prefix_schema]}, |
209 |
|
"gateway-address": {"oneOf": [null_schema, ip_schema]}, |
210 |
|
"dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]}, |
211 |
|
"dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]}, |
212 |
|
}, |
213 |
|
"additionalProperties": False, |
214 |
|
} |
215 |
|
|
216 |
1 |
provider_network_schema = { |
217 |
|
"title": "provider network validation schema", |
218 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
219 |
|
"type": "object", |
220 |
|
"properties": { |
221 |
|
"physical-network": name_schema, |
222 |
|
"segmentation-id": name_schema, |
223 |
|
"sdn-ports": { # external ports to append to the SDN-assist network |
224 |
|
"type": "array", |
225 |
|
"items": { |
226 |
|
"type": "object", |
227 |
|
"properties": { |
228 |
|
"switch_id": shortname_schema, |
229 |
|
"switch_port": shortname_schema, |
230 |
|
"mac_address": mac_schema, |
231 |
|
"vlan": vlan_schema, |
232 |
|
}, |
233 |
|
"additionalProperties": True, |
234 |
|
}, |
235 |
|
}, |
236 |
|
"network-type": shortname_schema, |
237 |
|
}, |
238 |
|
"additionalProperties": True, |
239 |
|
} |
240 |
|
|
241 |
1 |
ns_instantiate_internal_vld = { |
242 |
|
"title": "ns action instantiate input schema for vld", |
243 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
244 |
|
"type": "object", |
245 |
|
"properties": { |
246 |
|
"name": name_schema, |
247 |
|
"vim-network-name": name_schema, |
248 |
|
"vim-network-id": name_schema, |
249 |
|
"ip-profile": ip_profile_schema, |
250 |
|
"provider-network": provider_network_schema, |
251 |
|
"internal-connection-point": { |
252 |
|
"type": "array", |
253 |
|
"minItems": 1, |
254 |
|
"items": { |
255 |
|
"type": "object", |
256 |
|
"properties": { |
257 |
|
"id-ref": name_schema, |
258 |
|
"ip-address": ip_schema, |
259 |
|
# "mac-address": mac_schema, |
260 |
|
}, |
261 |
|
"required": ["id-ref"], |
262 |
|
"minProperties": 2, |
263 |
|
"additionalProperties": False, |
264 |
|
}, |
265 |
|
}, |
266 |
|
}, |
267 |
|
"required": ["name"], |
268 |
|
"minProperties": 2, |
269 |
|
"additionalProperties": False, |
270 |
|
} |
271 |
|
|
272 |
1 |
additional_params_for_vnf = { |
273 |
|
"type": "array", |
274 |
|
"items": { |
275 |
|
"type": "object", |
276 |
|
"properties": { |
277 |
|
"member-vnf-index": name_schema, |
278 |
|
"additionalParams": object_schema, |
279 |
|
"k8s-namespace": name_schema, |
280 |
|
"config-units": integer1_schema, # number of configuration units of this vnf, by default 1 |
281 |
|
"additionalParamsForVdu": { |
282 |
|
"type": "array", |
283 |
|
"items": { |
284 |
|
"type": "object", |
285 |
|
"properties": { |
286 |
|
"vdu_id": name_schema, |
287 |
|
"additionalParams": object_schema, |
288 |
|
"config-units": integer1_schema, # number of configuration units of this vdu, by default 1 |
289 |
|
}, |
290 |
|
"required": ["vdu_id"], |
291 |
|
"minProperties": 2, |
292 |
|
"additionalProperties": False, |
293 |
|
}, |
294 |
|
}, |
295 |
|
"additionalParamsForKdu": { |
296 |
|
"type": "array", |
297 |
|
"items": { |
298 |
|
"type": "object", |
299 |
|
"properties": { |
300 |
|
"kdu_name": name_schema, |
301 |
|
"additionalParams": object_schema, |
302 |
|
"kdu_model": name_schema, |
303 |
|
"k8s-namespace": name_schema, |
304 |
|
"config-units": integer1_schema, # number of configuration units of this knf, by default 1 |
305 |
|
"kdu-deployment-name": name_schema, |
306 |
|
}, |
307 |
|
"required": ["kdu_name"], |
308 |
|
"minProperties": 2, |
309 |
|
"additionalProperties": False, |
310 |
|
}, |
311 |
|
}, |
312 |
|
"affinity-or-anti-affinity-group": { |
313 |
|
"type": "array", |
314 |
|
"items": { |
315 |
|
"type": "object", |
316 |
|
"properties": { |
317 |
|
"id": name_schema, |
318 |
|
"vim-affinity-group-id": name_schema, |
319 |
|
}, |
320 |
|
"required": ["id"], |
321 |
|
"minProperties": 2, |
322 |
|
"additionalProperties": False, |
323 |
|
}, |
324 |
|
}, |
325 |
|
}, |
326 |
|
"required": ["member-vnf-index"], |
327 |
|
"minProperties": 2, |
328 |
|
"additionalProperties": False, |
329 |
|
}, |
330 |
|
} |
331 |
|
|
332 |
1 |
vnf_schema = { |
333 |
|
"type": "array", |
334 |
|
"minItems": 1, |
335 |
|
"items": { |
336 |
|
"type": "object", |
337 |
|
"properties": { |
338 |
|
"member-vnf-index": name_schema, |
339 |
|
"vimAccountId": id_schema, |
340 |
|
"vdu": { |
341 |
|
"type": "array", |
342 |
|
"minItems": 1, |
343 |
|
"items": ns_instantiate_vdu, |
344 |
|
}, |
345 |
|
"internal-vld": { |
346 |
|
"type": "array", |
347 |
|
"minItems": 1, |
348 |
|
"items": ns_instantiate_internal_vld, |
349 |
|
}, |
350 |
|
}, |
351 |
|
"required": ["member-vnf-index"], |
352 |
|
"minProperties": 2, |
353 |
|
"additionalProperties": False, |
354 |
|
}, |
355 |
|
} |
356 |
|
|
357 |
1 |
vld_schema = { |
358 |
|
"type": "array", |
359 |
|
"minItems": 1, |
360 |
|
"items": { |
361 |
|
"type": "object", |
362 |
|
"properties": { |
363 |
|
"name": string_schema, |
364 |
|
"vim-network-name": {"oneOf": [string_schema, object_schema]}, |
365 |
|
"vim-network-id": {"oneOf": [string_schema, object_schema]}, |
366 |
|
"ns-net": object_schema, |
367 |
|
"wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
368 |
|
"ip-profile": ip_profile_schema, |
369 |
|
"provider-network": provider_network_schema, |
370 |
|
"vnfd-connection-point-ref": { |
371 |
|
"type": "array", |
372 |
|
"minItems": 1, |
373 |
|
"items": { |
374 |
|
"type": "object", |
375 |
|
"properties": { |
376 |
|
"member-vnf-index-ref": name_schema, |
377 |
|
"vnfd-connection-point-ref": name_schema, |
378 |
|
"ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
379 |
|
# "mac-address": mac_schema, |
380 |
|
}, |
381 |
|
"required": [ |
382 |
|
"member-vnf-index-ref", |
383 |
|
"vnfd-connection-point-ref", |
384 |
|
], |
385 |
|
"minProperties": 3, |
386 |
|
"additionalProperties": False, |
387 |
|
}, |
388 |
|
}, |
389 |
|
}, |
390 |
|
"required": ["name"], |
391 |
|
"additionalProperties": False, |
392 |
|
}, |
393 |
|
} |
394 |
|
|
395 |
1 |
ns_config_template = { |
396 |
|
"title": " ns config template input schema", |
397 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
398 |
|
"type": "object", |
399 |
|
"properties": { |
400 |
|
"name": string_schema, |
401 |
|
"nsdId": id_schema, |
402 |
|
"config": object_schema, |
403 |
|
}, |
404 |
|
"required": ["name", "nsdId", "config"], |
405 |
|
"additionalProperties": False, |
406 |
|
} |
407 |
|
|
408 |
1 |
ns_instantiate = { |
409 |
|
"title": "ns action instantiate input schema", |
410 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
411 |
|
"type": "object", |
412 |
|
"properties": { |
413 |
|
"lcmOperationType": string_schema, |
414 |
|
"nsInstanceId": id_schema, |
415 |
|
"netsliceInstanceId": id_schema, |
416 |
|
"nsName": name_schema, |
417 |
|
"nsDescription": {"oneOf": [description_schema, null_schema]}, |
418 |
|
"nsdId": id_schema, |
419 |
|
"vimAccountId": id_schema, |
420 |
|
"nsConfigTemplateId": id_schema, |
421 |
|
"wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
422 |
|
"placement-engine": string_schema, |
423 |
|
"placement-constraints": object_schema, |
424 |
|
"additionalParamsForNs": object_schema, |
425 |
|
"additionalParamsForVnf": additional_params_for_vnf, |
426 |
|
"config-units": integer1_schema, # number of configuration units of this ns, by default 1 |
427 |
|
"k8s-namespace": name_schema, |
428 |
|
"ssh_keys": {"type": "array", "items": {"type": "string"}}, |
429 |
|
"timeout_ns_deploy": integer1_schema, |
430 |
|
"nsr_id": id_schema, |
431 |
|
"vduImage": name_schema, |
432 |
|
"vnf": vnf_schema, |
433 |
|
"vld": vld_schema, |
434 |
|
}, |
435 |
|
"required": ["nsName", "nsdId", "vimAccountId"], |
436 |
|
"additionalProperties": False, |
437 |
|
} |
438 |
|
|
439 |
1 |
ns_terminate = { |
440 |
|
"title": "ns terminate input schema", |
441 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
442 |
|
"type": "object", |
443 |
|
"properties": { |
444 |
|
"lcmOperationType": string_schema, |
445 |
|
"nsInstanceId": id_schema, |
446 |
|
"autoremove": bool_schema, |
447 |
|
"timeout_ns_terminate": integer1_schema, |
448 |
|
"skip_terminate_primitives": bool_schema, |
449 |
|
"netsliceInstanceId": id_schema, |
450 |
|
}, |
451 |
|
"additionalProperties": False, |
452 |
|
} |
453 |
|
|
454 |
1 |
ns_update = { |
455 |
|
"title": "ns update input schema", |
456 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
457 |
|
"type": "object", |
458 |
|
"properties": { |
459 |
|
"lcmOperationType": string_schema, |
460 |
|
"nsInstanceId": id_schema, |
461 |
|
"timeout_ns_update": integer1_schema, |
462 |
|
"updateType": { |
463 |
|
"enum": [ |
464 |
|
"CHANGE_VNFPKG", |
465 |
|
"REMOVE_VNF", |
466 |
|
"MODIFY_VNF_INFORMATION", |
467 |
|
"OPERATE_VNF", |
468 |
|
] |
469 |
|
}, |
470 |
|
"modifyVnfInfoData": { |
471 |
|
"type": "object", |
472 |
|
"properties": { |
473 |
|
"vnfInstanceId": id_schema, |
474 |
|
"vnfdId": id_schema, |
475 |
|
}, |
476 |
|
"required": ["vnfInstanceId", "vnfdId"], |
477 |
|
}, |
478 |
|
"removeVnfInstanceId": id_schema, |
479 |
|
"changeVnfPackageData": { |
480 |
|
"type": "object", |
481 |
|
"properties": { |
482 |
|
"vnfInstanceId": id_schema, |
483 |
|
"vnfdId": id_schema, |
484 |
|
}, |
485 |
|
"required": ["vnfInstanceId", "vnfdId"], |
486 |
|
}, |
487 |
|
"operateVnfData": { |
488 |
|
"type": "object", |
489 |
|
"properties": { |
490 |
|
"vnfInstanceId": id_schema, |
491 |
|
"changeStateTo": name_schema, |
492 |
|
"additionalParam": { |
493 |
|
"type": "object", |
494 |
|
"properties": { |
495 |
|
"run-day1": bool_schema, |
496 |
|
"vdu_id": name_schema, |
497 |
|
"count-index": integer0_schema, |
498 |
|
}, |
499 |
|
"required": ["vdu_id", "count-index"], |
500 |
|
"additionalProperties": False, |
501 |
|
}, |
502 |
|
}, |
503 |
|
"required": ["vnfInstanceId", "changeStateTo"], |
504 |
|
}, |
505 |
|
}, |
506 |
|
"required": ["updateType"], |
507 |
|
"additionalProperties": False, |
508 |
|
} |
509 |
|
|
510 |
1 |
ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution |
511 |
|
"title": "ns action input schema", |
512 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
513 |
|
"type": "object", |
514 |
|
"properties": { |
515 |
|
"lcmOperationType": string_schema, |
516 |
|
"nsInstanceId": id_schema, |
517 |
|
"member_vnf_index": name_schema, |
518 |
|
"vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future |
519 |
|
"vdu_id": name_schema, |
520 |
|
"vdu_count_index": integer0_schema, |
521 |
|
"kdu_name": name_schema, |
522 |
|
"primitive": name_schema, |
523 |
|
"timeout_ns_action": integer1_schema, |
524 |
|
"primitive_params": {"type": "object"}, |
525 |
|
}, |
526 |
|
"required": ["primitive", "primitive_params"], # TODO add member_vnf_index |
527 |
|
"additionalProperties": False, |
528 |
|
} |
529 |
|
|
530 |
1 |
ns_scale = { # TODO for the moment it is only VDU-scaling |
531 |
|
"title": "ns scale input schema", |
532 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
533 |
|
"type": "object", |
534 |
|
"properties": { |
535 |
|
"lcmOperationType": string_schema, |
536 |
|
"nsInstanceId": id_schema, |
537 |
|
"scaleType": {"enum": ["SCALE_VNF"]}, |
538 |
|
"timeout_ns_scale": integer1_schema, |
539 |
|
"scaleVnfData": { |
540 |
|
"type": "object", |
541 |
|
"properties": { |
542 |
|
"vnfInstanceId": name_schema, |
543 |
|
"scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]}, |
544 |
|
"scaleByStepData": { |
545 |
|
"type": "object", |
546 |
|
"properties": { |
547 |
|
"scaling-group-descriptor": name_schema, |
548 |
|
"member-vnf-index": name_schema, |
549 |
|
"scaling-policy": name_schema, |
550 |
|
}, |
551 |
|
"required": ["scaling-group-descriptor", "member-vnf-index"], |
552 |
|
"additionalProperties": False, |
553 |
|
}, |
554 |
|
}, |
555 |
|
"required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId |
556 |
|
"additionalProperties": False, |
557 |
|
}, |
558 |
|
"scaleTime": time_schema, |
559 |
|
}, |
560 |
|
"required": ["scaleType", "scaleVnfData"], |
561 |
|
"additionalProperties": False, |
562 |
|
} |
563 |
|
|
564 |
1 |
ns_migrate = { |
565 |
|
"title": "ns migrate input schema", |
566 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
567 |
|
"type": "object", |
568 |
|
"properties": { |
569 |
|
"lcmOperationType": string_schema, |
570 |
|
"nsInstanceId": id_schema, |
571 |
|
"vnfInstanceId": id_schema, |
572 |
|
"migrateToHost": string_schema, |
573 |
|
"vdu": { |
574 |
|
"type": "object", |
575 |
|
"properties": { |
576 |
|
"vduId": name_schema, |
577 |
|
"vduCountIndex": integer0_schema, |
578 |
|
}, |
579 |
|
"required": ["vduId"], |
580 |
|
"additionalProperties": False, |
581 |
|
}, |
582 |
|
}, |
583 |
|
"required": ["vnfInstanceId"], |
584 |
|
"additionalProperties": False, |
585 |
|
} |
586 |
|
|
587 |
1 |
ns_heal = { |
588 |
|
"title": "ns heal input schema", |
589 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
590 |
|
"type": "object", |
591 |
|
"properties": { |
592 |
|
"lcmOperationType": string_schema, |
593 |
|
"nsInstanceId": id_schema, |
594 |
|
"timeout_ns_heal": integer1_schema, |
595 |
|
"healVnfData": { |
596 |
|
"type": "array", |
597 |
|
"items": { |
598 |
|
"type": "object", |
599 |
|
"properties": { |
600 |
|
"vnfInstanceId": id_schema, |
601 |
|
"cause": description_schema, |
602 |
|
"additionalParams": { |
603 |
|
"type": "object", |
604 |
|
"properties": { |
605 |
|
"run-day1": bool_schema, |
606 |
|
"vdu": { |
607 |
|
"type": "array", |
608 |
|
"items": { |
609 |
|
"type": "object", |
610 |
|
"properties": { |
611 |
|
"run-day1": bool_schema, |
612 |
|
"vdu-id": name_schema, |
613 |
|
"count-index": integer0_schema, |
614 |
|
}, |
615 |
|
"required": ["vdu-id"], |
616 |
|
"additionalProperties": False, |
617 |
|
}, |
618 |
|
}, |
619 |
|
}, |
620 |
|
"additionalProperties": False, |
621 |
|
}, |
622 |
|
}, |
623 |
|
"required": ["vnfInstanceId"], |
624 |
|
"additionalProperties": False, |
625 |
|
}, |
626 |
|
}, |
627 |
|
}, |
628 |
|
"required": ["healVnfData"], |
629 |
|
"additionalProperties": False, |
630 |
|
} |
631 |
|
|
632 |
1 |
ns_verticalscale = { |
633 |
|
"title": "vertial scale input schema", |
634 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
635 |
|
"type": "object", |
636 |
|
"properties": { |
637 |
|
"lcmOperationType": string_schema, |
638 |
|
"verticalScale": string_schema, |
639 |
|
"nsInstanceId": id_schema, |
640 |
|
"changeVnfFlavorData": { |
641 |
|
"type": "object", |
642 |
|
"properties": { |
643 |
|
"vnfInstanceId": id_schema, |
644 |
|
"additionalParams": { |
645 |
|
"type": "object", |
646 |
|
"properties": { |
647 |
|
"vduid": string_schema, |
648 |
|
"vduCountIndex": integer0_schema, |
649 |
|
"virtualMemory": integer1_schema, |
650 |
|
"sizeOfStorage": integer0_schema, |
651 |
|
"numVirtualCpu": integer1_schema, |
652 |
|
}, |
653 |
|
}, |
654 |
|
}, |
655 |
|
"required": ["vnfInstanceId", "additionalParams"], |
656 |
|
"additionalProperties": False, |
657 |
|
}, |
658 |
|
}, |
659 |
|
"required": ["lcmOperationType", "verticalScale", "nsInstanceId"], |
660 |
|
"additionalProperties": False, |
661 |
|
} |
662 |
|
|
663 |
1 |
nslcmop_cancel = { |
664 |
|
"title": "Cancel nslcmop input schema", |
665 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
666 |
|
"type": "object", |
667 |
|
"properties": { |
668 |
|
"nsLcmOpOccId": id_schema, |
669 |
|
"cancelMode": { |
670 |
|
"enum": [ |
671 |
|
"GRACEFUL", |
672 |
|
"FORCEFUL", |
673 |
|
] |
674 |
|
}, |
675 |
|
}, |
676 |
|
"required": ["cancelMode"], |
677 |
|
"additionalProperties": False, |
678 |
|
} |
679 |
|
|
680 |
1 |
schema_version = {"type": "string", "enum": ["1.0"]} |
681 |
1 |
schema_type = {"type": "string"} |
682 |
1 |
vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} |
683 |
|
|
684 |
1 |
vim_account_edit_schema = { |
685 |
|
"title": "vim_account edit input schema", |
686 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
687 |
|
"type": "object", |
688 |
|
"properties": { |
689 |
|
"name": name_schema, |
690 |
|
"description": description_schema, |
691 |
|
"vim": name_schema, |
692 |
|
"datacenter": name_schema, |
693 |
|
"vim_type": vim_type, |
694 |
|
"vim_url": description_schema, |
695 |
|
# "vim_url_admin": description_schema, |
696 |
|
# "vim_tenant": name_schema, |
697 |
|
"vim_tenant_name": name_schema, |
698 |
|
"vim_user": string_schema, |
699 |
|
"vim_password": passwd_schema, |
700 |
|
"vca": id_schema, |
701 |
|
"config": {"type": "object"}, |
702 |
|
"prometheus-config": {"type": "object"}, |
703 |
|
}, |
704 |
|
"additionalProperties": False, |
705 |
|
} |
706 |
|
|
707 |
1 |
vim_account_new_schema = { |
708 |
|
"title": "vim_account creation input schema", |
709 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
710 |
|
"type": "object", |
711 |
|
"properties": { |
712 |
|
"schema_version": schema_version, |
713 |
|
"schema_type": schema_type, |
714 |
|
"name": name_schema, |
715 |
|
"description": description_schema, |
716 |
|
"vim": name_schema, |
717 |
|
"datacenter": name_schema, |
718 |
|
"vim_type": vim_type, |
719 |
|
"vim_url": description_schema, |
720 |
|
# "vim_url_admin": description_schema, |
721 |
|
# "vim_tenant": name_schema, |
722 |
|
"vim_tenant_name": name_schema, |
723 |
|
"vim_user": string_schema, |
724 |
|
"vim_password": passwd_schema, |
725 |
|
"vca": id_schema, |
726 |
|
"config": {"type": "object"}, |
727 |
|
"prometheus-config": {"type": "object"}, |
728 |
|
}, |
729 |
|
"required": [ |
730 |
|
"name", |
731 |
|
"vim_url", |
732 |
|
"vim_type", |
733 |
|
"vim_user", |
734 |
|
"vim_password", |
735 |
|
"vim_tenant_name", |
736 |
|
], |
737 |
|
"additionalProperties": False, |
738 |
|
} |
739 |
|
|
740 |
1 |
wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]} |
741 |
|
|
742 |
1 |
wim_account_edit_schema = { |
743 |
|
"title": "wim_account edit input schema", |
744 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
745 |
|
"type": "object", |
746 |
|
"properties": { |
747 |
|
"name": name_schema, |
748 |
|
"description": description_schema, |
749 |
|
"wim": name_schema, |
750 |
|
"wim_type": wim_type, |
751 |
|
"wim_url": description_schema, |
752 |
|
"user": string_schema, |
753 |
|
"password": passwd_schema, |
754 |
|
"config": {"type": "object"}, |
755 |
|
}, |
756 |
|
"additionalProperties": False, |
757 |
|
} |
758 |
|
|
759 |
1 |
wim_account_new_schema = { |
760 |
|
"title": "wim_account creation input schema", |
761 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
762 |
|
"type": "object", |
763 |
|
"properties": { |
764 |
|
"schema_version": schema_version, |
765 |
|
"schema_type": schema_type, |
766 |
|
"name": name_schema, |
767 |
|
"description": description_schema, |
768 |
|
"wim": name_schema, |
769 |
|
"wim_type": wim_type, |
770 |
|
"wim_url": description_schema, |
771 |
|
"user": string_schema, |
772 |
|
"password": passwd_schema, |
773 |
|
"config": { |
774 |
|
"type": "object", |
775 |
|
"patternProperties": {".": {"not": {"type": "null"}}}, |
776 |
|
}, |
777 |
|
}, |
778 |
|
"required": ["name", "wim_url", "wim_type"], |
779 |
|
"additionalProperties": False, |
780 |
|
} |
781 |
|
|
782 |
1 |
sdn_properties = { |
783 |
|
"name": name_schema, |
784 |
|
"type": {"type": "string"}, |
785 |
|
"url": {"type": "string"}, |
786 |
|
"user": string_schema, |
787 |
|
"password": passwd_schema, |
788 |
|
"config": {"type": "object"}, |
789 |
|
"description": description_schema, |
790 |
|
# The folowing are deprecated. Maintanied for backward compatibility |
791 |
|
"dpid": dpid_Schema, |
792 |
|
"ip": ip_schema, |
793 |
|
"port": port_schema, |
794 |
|
"version": {"type": "string", "minLength": 1, "maxLength": 12}, |
795 |
|
} |
796 |
1 |
sdn_new_schema = { |
797 |
|
"title": "sdn controller information schema", |
798 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
799 |
|
"type": "object", |
800 |
|
"properties": sdn_properties, |
801 |
|
"required": ["name", "type"], |
802 |
|
"additionalProperties": False, |
803 |
|
} |
804 |
1 |
sdn_edit_schema = { |
805 |
|
"title": "sdn controller update information schema", |
806 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
807 |
|
"type": "object", |
808 |
|
"properties": sdn_properties, |
809 |
|
# "required": ["name", "port", 'ip', 'dpid', 'type'], |
810 |
|
"additionalProperties": False, |
811 |
|
} |
812 |
1 |
sdn_port_mapping_schema = { |
813 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
814 |
|
"title": "sdn port mapping information schema", |
815 |
|
"type": "array", |
816 |
|
"items": { |
817 |
|
"type": "object", |
818 |
|
"properties": { |
819 |
|
"compute_node": shortname_schema, |
820 |
|
"ports": { |
821 |
|
"type": "array", |
822 |
|
"items": { |
823 |
|
"type": "object", |
824 |
|
"properties": { |
825 |
|
"pci": pci_extended_schema, |
826 |
|
"switch_port": shortname_schema, |
827 |
|
"switch_mac": mac_schema, |
828 |
|
}, |
829 |
|
"required": ["pci"], |
830 |
|
}, |
831 |
|
}, |
832 |
|
}, |
833 |
|
"required": ["compute_node", "ports"], |
834 |
|
}, |
835 |
|
} |
836 |
1 |
sdn_external_port_schema = { |
837 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
838 |
|
"title": "External port information", |
839 |
|
"type": "object", |
840 |
|
"properties": { |
841 |
|
"port": {"type": "string", "minLength": 1, "maxLength": 60}, |
842 |
|
"vlan": vlan_schema, |
843 |
|
"mac": mac_schema, |
844 |
|
}, |
845 |
|
"required": ["port"], |
846 |
|
} |
847 |
|
|
848 |
|
# K8s Clusters |
849 |
1 |
k8scluster_deploy_method_schema = { |
850 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
851 |
|
"title": "Deployment methods for K8s cluster", |
852 |
|
"type": "object", |
853 |
|
"properties": { |
854 |
|
"juju-bundle": {"type": "boolean"}, |
855 |
|
"helm-chart-v3": {"type": "boolean"}, |
856 |
|
}, |
857 |
|
"additionalProperties": False, |
858 |
|
"minProperties": 2, |
859 |
|
} |
860 |
1 |
k8scluster_nets_schema = { |
861 |
|
"title": "k8scluster nets input schema", |
862 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
863 |
|
"type": "object", |
864 |
|
"patternProperties": {".": {"oneOf": [name_schema, null_schema]}}, |
865 |
|
"minProperties": 1, |
866 |
|
"additionalProperties": False, |
867 |
|
} |
868 |
1 |
k8scluster_new_schema = { |
869 |
|
"title": "k8scluster creation input schema", |
870 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
871 |
|
"type": "object", |
872 |
|
"properties": { |
873 |
|
"schema_version": schema_version, |
874 |
|
"schema_type": schema_type, |
875 |
|
"name": name_schema, |
876 |
|
"description": description_schema, |
877 |
|
"credentials": object_schema, |
878 |
|
"vim_account": id_schema, |
879 |
|
"vca_id": id_schema, |
880 |
|
"k8s_version": string_schema, |
881 |
|
"nets": k8scluster_nets_schema, |
882 |
|
"deployment_methods": k8scluster_deploy_method_schema, |
883 |
|
"namespace": name_schema, |
884 |
|
"cni": nameshort_list_schema, |
885 |
|
}, |
886 |
|
"required": ["name", "credentials", "vim_account", "k8s_version", "nets"], |
887 |
|
"additionalProperties": False, |
888 |
|
} |
889 |
1 |
k8scluster_edit_schema = { |
890 |
|
"title": "vim_account edit input schema", |
891 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
892 |
|
"type": "object", |
893 |
|
"properties": { |
894 |
|
"name": name_schema, |
895 |
|
"description": description_schema, |
896 |
|
"credentials": object_schema, |
897 |
|
"vim_account": id_schema, |
898 |
|
"vca_id": id_schema, |
899 |
|
"k8s_version": string_schema, |
900 |
|
"nets": k8scluster_nets_schema, |
901 |
|
"namespace": name_schema, |
902 |
|
"cni": nameshort_list_schema, |
903 |
|
}, |
904 |
|
"additionalProperties": False, |
905 |
|
} |
906 |
|
|
907 |
|
# VCA |
908 |
1 |
vca_new_schema = { |
909 |
|
"title": "vca creation input schema", |
910 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
911 |
|
"type": "object", |
912 |
|
"properties": { |
913 |
|
"schema_version": schema_version, |
914 |
|
"schema_type": schema_type, |
915 |
|
"name": name_schema, |
916 |
|
"description": description_schema, |
917 |
|
"endpoints": description_list_schema, |
918 |
|
"user": string_schema, |
919 |
|
"secret": passwd_schema, |
920 |
|
"cacert": long_description_schema, |
921 |
|
"lxd-cloud": shortname_schema, |
922 |
|
"lxd-credentials": shortname_schema, |
923 |
|
"k8s-cloud": shortname_schema, |
924 |
|
"k8s-credentials": shortname_schema, |
925 |
|
"model-config": object_schema, |
926 |
|
}, |
927 |
|
"required": [ |
928 |
|
"name", |
929 |
|
"endpoints", |
930 |
|
"user", |
931 |
|
"secret", |
932 |
|
"cacert", |
933 |
|
"lxd-cloud", |
934 |
|
"lxd-credentials", |
935 |
|
"k8s-cloud", |
936 |
|
"k8s-credentials", |
937 |
|
], |
938 |
|
"additionalProperties": False, |
939 |
|
} |
940 |
1 |
vca_edit_schema = { |
941 |
|
"title": "vca creation input schema", |
942 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
943 |
|
"type": "object", |
944 |
|
"properties": { |
945 |
|
"name": name_schema, |
946 |
|
"description": description_schema, |
947 |
|
"endpoints": description_list_schema, |
948 |
|
"port": integer1_schema, |
949 |
|
"user": string_schema, |
950 |
|
"secret": passwd_schema, |
951 |
|
"cacert": long_description_schema, |
952 |
|
"lxd-cloud": shortname_schema, |
953 |
|
"lxd-credentials": shortname_schema, |
954 |
|
"k8s-cloud": shortname_schema, |
955 |
|
"k8s-credentials": shortname_schema, |
956 |
|
"model-config": object_schema, |
957 |
|
}, |
958 |
|
"additionalProperties": False, |
959 |
|
} |
960 |
|
|
961 |
|
# K8s Repos |
962 |
1 |
k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]} |
963 |
1 |
k8srepo_properties = { |
964 |
|
"name": name_schema, |
965 |
|
"description": description_schema, |
966 |
|
"type": k8srepo_types, |
967 |
|
"url": description_schema, |
968 |
|
"cacert": long_description_schema, |
969 |
|
"user": string_schema, |
970 |
|
"password": passwd_schema, |
971 |
|
"oci": bool_schema, |
972 |
|
} |
973 |
1 |
k8srepo_new_schema = { |
974 |
|
"title": "k8scluster creation input schema", |
975 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
976 |
|
"type": "object", |
977 |
|
"properties": k8srepo_properties, |
978 |
|
"required": ["name", "type", "url"], |
979 |
|
"additionalProperties": False, |
980 |
|
} |
981 |
1 |
k8srepo_edit_schema = { |
982 |
|
"title": "vim_account edit input schema", |
983 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
984 |
|
"type": "object", |
985 |
|
"properties": k8srepo_properties, |
986 |
|
"additionalProperties": False, |
987 |
|
} |
988 |
|
|
989 |
|
# OSM Repos |
990 |
1 |
osmrepo_types = {"enum": ["osm"]} |
991 |
1 |
osmrepo_properties = { |
992 |
|
"name": name_schema, |
993 |
|
"description": description_schema, |
994 |
|
"type": osmrepo_types, |
995 |
|
"url": description_schema |
996 |
|
# "user": string_schema, |
997 |
|
# "password": passwd_schema |
998 |
|
} |
999 |
1 |
osmrepo_new_schema = { |
1000 |
|
"title": "osm repo creation input schema", |
1001 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1002 |
|
"type": "object", |
1003 |
|
"properties": osmrepo_properties, |
1004 |
|
"required": ["name", "type", "url"], |
1005 |
|
"additionalProperties": False, |
1006 |
|
} |
1007 |
1 |
osmrepo_edit_schema = { |
1008 |
|
"title": "osm repo edit input schema", |
1009 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1010 |
|
"type": "object", |
1011 |
|
"properties": osmrepo_properties, |
1012 |
|
"additionalProperties": False, |
1013 |
|
} |
1014 |
|
|
1015 |
|
# PDUs |
1016 |
1 |
pdu_interface = { |
1017 |
|
"type": "object", |
1018 |
|
"properties": { |
1019 |
|
"name": shortname_schema, |
1020 |
|
"mgmt": bool_schema, |
1021 |
|
"type": {"enum": ["overlay", "underlay"]}, |
1022 |
|
"ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
1023 |
|
# TODO, add user, password, ssh-key |
1024 |
|
"mac-address": mac_schema, |
1025 |
|
"vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port |
1026 |
|
"vim-network-id": shortname_schema, |
1027 |
|
# # provide this in case SDN assist must deal with this interface |
1028 |
|
# "switch-dpid": dpid_Schema, |
1029 |
|
# "switch-port": shortname_schema, |
1030 |
|
# "switch-mac": shortname_schema, |
1031 |
|
# "switch-vlan": vlan_schema, |
1032 |
|
}, |
1033 |
|
"required": ["name", "mgmt", "ip-address"], |
1034 |
|
"additionalProperties": False, |
1035 |
|
} |
1036 |
1 |
pdu_new_schema = { |
1037 |
|
"title": "pdu creation input schema", |
1038 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1039 |
|
"type": "object", |
1040 |
|
"properties": { |
1041 |
|
"name": shortname_schema, |
1042 |
|
"type": shortname_schema, |
1043 |
|
"description": description_schema, |
1044 |
|
"shared": bool_schema, |
1045 |
|
"vims": nameshort_list_schema, |
1046 |
|
"vim_accounts": nameshort_list_schema, |
1047 |
|
"interfaces": {"type": "array", "items": pdu_interface, "minItems": 1}, |
1048 |
|
}, |
1049 |
|
"required": ["name", "type", "interfaces"], |
1050 |
|
"additionalProperties": False, |
1051 |
|
} |
1052 |
1 |
pdu_edit_schema = { |
1053 |
|
"title": "pdu edit input schema", |
1054 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1055 |
|
"type": "object", |
1056 |
|
"properties": { |
1057 |
|
"name": shortname_schema, |
1058 |
|
"type": shortname_schema, |
1059 |
|
"description": description_schema, |
1060 |
|
"shared": bool_schema, |
1061 |
|
"vims": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
1062 |
|
"vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
1063 |
|
"interfaces": { |
1064 |
|
"oneOf": [ |
1065 |
|
array_edition_schema, |
1066 |
|
{"type": "array", "items": pdu_interface, "minItems": 1}, |
1067 |
|
] |
1068 |
|
}, |
1069 |
|
}, |
1070 |
|
"additionalProperties": False, |
1071 |
|
"minProperties": 1, |
1072 |
|
} |
1073 |
|
|
1074 |
|
# VNF PKG OPERATIONS |
1075 |
1 |
vnfpkgop_new_schema = { |
1076 |
|
"title": "VNF PKG operation creation input schema", |
1077 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1078 |
|
"type": "object", |
1079 |
|
"properties": { |
1080 |
|
"lcmOperationType": string_schema, |
1081 |
|
"vnfPkgId": id_schema, |
1082 |
|
"kdu_name": name_schema, |
1083 |
|
"primitive": name_schema, |
1084 |
|
"primitive_params": {"type": "object"}, |
1085 |
|
}, |
1086 |
|
"required": [ |
1087 |
|
"lcmOperationType", |
1088 |
|
"vnfPkgId", |
1089 |
|
"kdu_name", |
1090 |
|
"primitive", |
1091 |
|
"primitive_params", |
1092 |
|
], |
1093 |
|
"additionalProperties": False, |
1094 |
|
} |
1095 |
|
|
1096 |
|
# USERS |
1097 |
1 |
project_role_mappings = { |
1098 |
|
"title": "list pf projects/roles", |
1099 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1100 |
|
"type": "array", |
1101 |
|
"items": { |
1102 |
|
"type": "object", |
1103 |
|
"properties": {"project": shortname_schema, "role": shortname_schema}, |
1104 |
|
"required": ["project", "role"], |
1105 |
|
"additionalProperties": False, |
1106 |
|
}, |
1107 |
|
"minItems": 1, |
1108 |
|
} |
1109 |
1 |
project_role_mappings_optional = { |
1110 |
|
"title": "list of projects/roles or projects only", |
1111 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1112 |
|
"type": "array", |
1113 |
|
"items": { |
1114 |
|
"type": "object", |
1115 |
|
"properties": {"project": shortname_schema, "role": shortname_schema}, |
1116 |
|
"required": ["project"], |
1117 |
|
"additionalProperties": False, |
1118 |
|
}, |
1119 |
|
"minItems": 1, |
1120 |
|
} |
1121 |
1 |
user_new_schema = { |
1122 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1123 |
|
"title": "New user schema", |
1124 |
|
"type": "object", |
1125 |
|
"properties": { |
1126 |
|
"username": string_schema, |
1127 |
|
"domain_name": shortname_schema, |
1128 |
|
"password": user_passwd_schema, |
1129 |
|
"projects": nameshort_list_schema, |
1130 |
|
"project_role_mappings": project_role_mappings, |
1131 |
|
}, |
1132 |
|
"required": ["username", "password"], |
1133 |
|
"additionalProperties": False, |
1134 |
|
} |
1135 |
1 |
user_edit_schema = { |
1136 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1137 |
|
"title": "User edit schema for administrators", |
1138 |
|
"type": "object", |
1139 |
|
"properties": { |
1140 |
|
"password": user_passwd_schema, |
1141 |
|
"old_password": passwd_schema, |
1142 |
|
"username": string_schema, # To allow User Name modification |
1143 |
|
"projects": {"oneOf": [nameshort_list_schema, array_edition_schema]}, |
1144 |
|
"project_role_mappings": project_role_mappings, |
1145 |
|
"add_project_role_mappings": project_role_mappings, |
1146 |
|
"remove_project_role_mappings": project_role_mappings_optional, |
1147 |
|
"system_admin_id": id_schema, |
1148 |
|
"unlock": bool_schema, |
1149 |
|
"renew": bool_schema, |
1150 |
|
}, |
1151 |
|
"minProperties": 1, |
1152 |
|
"additionalProperties": False, |
1153 |
|
} |
1154 |
|
|
1155 |
|
# PROJECTS |
1156 |
1 |
topics_with_quota = [ |
1157 |
|
"vnfds", |
1158 |
|
"nsds", |
1159 |
|
"slice_templates", |
1160 |
|
"pduds", |
1161 |
|
"ns_instances", |
1162 |
|
"slice_instances", |
1163 |
|
"vim_accounts", |
1164 |
|
"wim_accounts", |
1165 |
|
"sdn_controllers", |
1166 |
|
"k8sclusters", |
1167 |
|
"vca", |
1168 |
|
"k8srepos", |
1169 |
|
"osmrepos", |
1170 |
|
"ns_subscriptions", |
1171 |
|
] |
1172 |
1 |
project_new_schema = { |
1173 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1174 |
|
"title": "New project schema for administrators", |
1175 |
|
"type": "object", |
1176 |
|
"properties": { |
1177 |
|
"name": shortname_schema, |
1178 |
|
"admin": bool_schema, |
1179 |
|
"domain_name": shortname_schema, |
1180 |
|
"quotas": { |
1181 |
|
"type": "object", |
1182 |
|
"properties": {topic: integer0_schema for topic in topics_with_quota}, |
1183 |
|
"additionalProperties": False, |
1184 |
|
}, |
1185 |
|
}, |
1186 |
|
"required": ["name"], |
1187 |
|
"additionalProperties": False, |
1188 |
|
} |
1189 |
1 |
project_edit_schema = { |
1190 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1191 |
|
"title": "Project edit schema for administrators", |
1192 |
|
"type": "object", |
1193 |
|
"properties": { |
1194 |
|
"admin": bool_schema, |
1195 |
|
"name": shortname_schema, # To allow Project Name modification |
1196 |
|
"quotas": { |
1197 |
|
"type": "object", |
1198 |
|
"properties": { |
1199 |
|
topic: {"oneOf": [integer0_schema, null_schema]} |
1200 |
|
for topic in topics_with_quota |
1201 |
|
}, |
1202 |
|
"additionalProperties": False, |
1203 |
|
}, |
1204 |
|
}, |
1205 |
|
"additionalProperties": False, |
1206 |
|
"minProperties": 1, |
1207 |
|
} |
1208 |
|
|
1209 |
|
# ROLES |
1210 |
1 |
roles_new_schema = { |
1211 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1212 |
|
"title": "New role schema for administrators", |
1213 |
|
"type": "object", |
1214 |
|
"properties": { |
1215 |
|
"name": shortname_schema, |
1216 |
|
"permissions": { |
1217 |
|
"type": "object", |
1218 |
|
"patternProperties": { |
1219 |
|
".": bool_schema, |
1220 |
|
}, |
1221 |
|
# "minProperties": 1, |
1222 |
|
}, |
1223 |
|
}, |
1224 |
|
"required": ["name"], |
1225 |
|
"additionalProperties": False, |
1226 |
|
} |
1227 |
1 |
roles_edit_schema = { |
1228 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1229 |
|
"title": "Roles edit schema for administrators", |
1230 |
|
"type": "object", |
1231 |
|
"properties": { |
1232 |
|
"name": shortname_schema, |
1233 |
|
"permissions": { |
1234 |
|
"type": "object", |
1235 |
|
"patternProperties": {".": {"oneOf": [bool_schema, null_schema]}}, |
1236 |
|
# "minProperties": 1, |
1237 |
|
}, |
1238 |
|
}, |
1239 |
|
"additionalProperties": False, |
1240 |
|
"minProperties": 1, |
1241 |
|
} |
1242 |
|
|
1243 |
|
# GLOBAL SCHEMAS |
1244 |
|
|
1245 |
1 |
nbi_new_input_schemas = { |
1246 |
|
"users": user_new_schema, |
1247 |
|
"projects": project_new_schema, |
1248 |
|
"vim_accounts": vim_account_new_schema, |
1249 |
|
"sdns": sdn_new_schema, |
1250 |
|
"ns_instantiate": ns_instantiate, |
1251 |
|
"ns_action": ns_action, |
1252 |
|
"ns_scale": ns_scale, |
1253 |
|
"ns_update": ns_update, |
1254 |
|
"ns_heal": ns_heal, |
1255 |
|
"pdus": pdu_new_schema, |
1256 |
|
} |
1257 |
|
|
1258 |
1 |
nbi_edit_input_schemas = { |
1259 |
|
"users": user_edit_schema, |
1260 |
|
"projects": project_edit_schema, |
1261 |
|
"vim_accounts": vim_account_edit_schema, |
1262 |
|
"sdns": sdn_edit_schema, |
1263 |
|
"pdus": pdu_edit_schema, |
1264 |
|
"vnf": vnf_schema, |
1265 |
|
"vld": vld_schema, |
1266 |
|
"additionalParamsForVnf": additional_params_for_vnf, |
1267 |
|
} |
1268 |
|
|
1269 |
|
# NETSLICE SCHEMAS |
1270 |
1 |
nsi_subnet_instantiate = deepcopy(ns_instantiate) |
1271 |
1 |
nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema" |
1272 |
1 |
nsi_subnet_instantiate["properties"]["id"] = name_schema |
1273 |
1 |
del nsi_subnet_instantiate["required"] |
1274 |
|
|
1275 |
1 |
nsi_vld_instantiate = { |
1276 |
|
"title": "netslice vld instantiation params input schema", |
1277 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1278 |
|
"type": "object", |
1279 |
|
"properties": { |
1280 |
|
"name": string_schema, |
1281 |
|
"vim-network-name": {"oneOf": [string_schema, object_schema]}, |
1282 |
|
"vim-network-id": {"oneOf": [string_schema, object_schema]}, |
1283 |
|
"ip-profile": object_schema, |
1284 |
|
}, |
1285 |
|
"required": ["name"], |
1286 |
|
"additionalProperties": False, |
1287 |
|
} |
1288 |
|
|
1289 |
1 |
nsi_instantiate = { |
1290 |
|
"title": "netslice action instantiate input schema", |
1291 |
|
"$schema": "http://json-schema.org/draft-04/schema#", |
1292 |
|
"type": "object", |
1293 |
|
"properties": { |
1294 |
|
"lcmOperationType": string_schema, |
1295 |
|
"netsliceInstanceId": id_schema, |
1296 |
|
"nsiName": name_schema, |
1297 |
|
"nsiDescription": {"oneOf": [description_schema, null_schema]}, |
1298 |
|
"nstId": string_schema, |
1299 |
|
"vimAccountId": id_schema, |
1300 |
|
"timeout_nsi_deploy": integer1_schema, |
1301 |
|
"ssh_keys": {"type": "array", "items": {"type": "string"}}, |
1302 |
|
"nsi_id": id_schema, |
1303 |
|
"additionalParamsForNsi": object_schema, |
1304 |
|
"netslice-subnet": { |
1305 |
|
"type": "array", |
1306 |
|
"minItems": 1, |
1307 |
|
"items": nsi_subnet_instantiate, |
1308 |
|
}, |
1309 |
|
"netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate}, |
1310 |
|
}, |
1311 |
|
"required": ["nsiName", "nstId", "vimAccountId"], |
1312 |
|
"additionalProperties": False, |
1313 |
|
} |
1314 |
|
|
1315 |
1 |
nsi_action = {} |
1316 |
|
|
1317 |
1 |
nsi_terminate = {} |
1318 |
|
|
1319 |
1 |
nsinstancesubscriptionfilter_schema = { |
1320 |
|
"title": "instance identifier schema", |
1321 |
|
"$schema": "http://json-schema.org/draft-07/schema#", |
1322 |
|
"type": "object", |
1323 |
|
"properties": { |
1324 |
|
"nsdIds": {"type": "array"}, |
1325 |
|
"vnfdIds": {"type": "array"}, |
1326 |
|
"pnfdIds": {"type": "array"}, |
1327 |
|
"nsInstanceIds": {"type": "array"}, |
1328 |
|
"nsInstanceNames": {"type": "array"}, |
1329 |
|
}, |
1330 |
|
} |
1331 |
|
|
1332 |
1 |
nslcmsub_schema = { |
1333 |
|
"title": "nslcmsubscription input schema", |
1334 |
|
"$schema": "http://json-schema.org/draft-07/schema#", |
1335 |
|
"type": "object", |
1336 |
|
"properties": { |
1337 |
|
"nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema, |
1338 |
|
"notificationTypes": { |
1339 |
|
"type": "array", |
1340 |
|
"items": { |
1341 |
|
"enum": [ |
1342 |
|
"NsLcmOperationOccurrenceNotification", |
1343 |
|
"NsChangeNotification", |
1344 |
|
"NsIdentifierCreationNotification", |
1345 |
|
"NsIdentifierDeletionNotification", |
1346 |
|
] |
1347 |
|
}, |
1348 |
|
}, |
1349 |
|
"operationTypes": { |
1350 |
|
"type": "array", |
1351 |
|
"items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]}, |
1352 |
|
}, |
1353 |
|
"operationStates": { |
1354 |
|
"type": "array", |
1355 |
|
"items": { |
1356 |
|
"enum": [ |
1357 |
|
"PROCESSING", |
1358 |
|
"COMPLETED", |
1359 |
|
"PARTIALLY_COMPLETED", |
1360 |
|
"FAILED", |
1361 |
|
"FAILED_TEMP", |
1362 |
|
"ROLLING_BACK", |
1363 |
|
"ROLLED_BACK", |
1364 |
|
] |
1365 |
|
}, |
1366 |
|
}, |
1367 |
|
"nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}}, |
1368 |
|
"lcmOpNameImpactingNsComponent": { |
1369 |
|
"type": "array", |
1370 |
|
"items": { |
1371 |
|
"enum": [ |
1372 |
|
"VNF_INSTANTIATE", |
1373 |
|
"VNF_SCALE", |
1374 |
|
"VNF_SCALE_TO_LEVEL", |
1375 |
|
"VNF_CHANGE_FLAVOUR", |
1376 |
|
"VNF_TERMINATE", |
1377 |
|
"VNF_HEAL", |
1378 |
|
"VNF_OPERATE", |
1379 |
|
"VNF_CHANGE_EXT_CONN", |
1380 |
|
"VNF_MODIFY_INFO", |
1381 |
|
"NS_INSTANTIATE", |
1382 |
|
"NS_SCALE", |
1383 |
|
"NS_UPDATE", |
1384 |
|
"NS_TERMINATE", |
1385 |
|
"NS_HEAL", |
1386 |
|
] |
1387 |
|
}, |
1388 |
|
}, |
1389 |
|
"lcmOpOccStatusImpactingNsComponent": { |
1390 |
|
"type": "array", |
1391 |
|
"items": { |
1392 |
|
"enum": [ |
1393 |
|
"START", |
1394 |
|
"COMPLETED", |
1395 |
|
"PARTIALLY_COMPLETED", |
1396 |
|
"FAILED", |
1397 |
|
"ROLLED_BACK", |
1398 |
|
] |
1399 |
|
}, |
1400 |
|
}, |
1401 |
|
}, |
1402 |
|
"allOf": [ |
1403 |
|
{ |
1404 |
|
"if": { |
1405 |
|
"properties": { |
1406 |
|
"notificationTypes": { |
1407 |
|
"contains": {"const": "NsLcmOperationOccurrenceNotification"} |
1408 |
|
} |
1409 |
|
}, |
1410 |
|
}, |
1411 |
|
"then": { |
1412 |
|
"anyOf": [ |
1413 |
|
{"required": ["operationTypes"]}, |
1414 |
|
{"required": ["operationStates"]}, |
1415 |
|
] |
1416 |
|
}, |
1417 |
|
}, |
1418 |
|
{ |
1419 |
|
"if": { |
1420 |
|
"properties": { |
1421 |
|
"notificationTypes": {"contains": {"const": "NsChangeNotification"}} |
1422 |
|
}, |
1423 |
|
}, |
1424 |
|
"then": { |
1425 |
|
"anyOf": [ |
1426 |
|
{"required": ["nsComponentTypes"]}, |
1427 |
|
{"required": ["lcmOpNameImpactingNsComponent"]}, |
1428 |
|
{"required": ["lcmOpOccStatusImpactingNsComponent"]}, |
1429 |
|
] |
1430 |
|
}, |
1431 |
|
}, |
1432 |
|
], |
1433 |
|
} |
1434 |
|
|
1435 |
1 |
authentication_schema = { |
1436 |
|
"title": "authentication schema for subscription", |
1437 |
|
"$schema": "http://json-schema.org/draft-07/schema#", |
1438 |
|
"type": "object", |
1439 |
|
"properties": { |
1440 |
|
"authType": {"enum": ["basic"]}, |
1441 |
|
"paramsBasic": { |
1442 |
|
"type": "object", |
1443 |
|
"properties": { |
1444 |
|
"userName": string_schema, |
1445 |
|
"password": passwd_schema, |
1446 |
|
}, |
1447 |
|
}, |
1448 |
|
}, |
1449 |
|
} |
1450 |
|
|
1451 |
1 |
subscription = { |
1452 |
|
"title": "subscription input schema", |
1453 |
|
"$schema": "http://json-schema.org/draft-07/schema#", |
1454 |
|
"type": "object", |
1455 |
|
"properties": { |
1456 |
|
"filter": nslcmsub_schema, |
1457 |
|
"CallbackUri": description_schema, |
1458 |
|
"authentication": authentication_schema, |
1459 |
|
}, |
1460 |
|
"required": ["CallbackUri"], |
1461 |
|
} |
1462 |
|
|
1463 |
1 |
vnflcmsub_schema = { |
1464 |
|
"title": "vnflcmsubscription input schema", |
1465 |
|
"$schema": "http://json-schema.org/draft-07/schema#", |
1466 |
|
"type": "object", |
1467 |
|
"properties": { |
1468 |
|
"VnfInstanceSubscriptionFilter": { |
1469 |
|
"type": "object", |
1470 |
|
"properties": { |
1471 |
|
"vnfdIds": {"type": "array"}, |
1472 |
|
"vnfInstanceIds": {"type": "array"}, |
1473 |
|
}, |
1474 |
|
}, |
1475 |
|
"notificationTypes": { |
1476 |
|
"type": "array", |
1477 |
|
"items": { |
1478 |
|
"enum": [ |
1479 |
|
"VnfIdentifierCreationNotification", |
1480 |
|
"VnfLcmOperationOccurrenceNotification", |
1481 |
|
"VnfIdentifierDeletionNotification", |
1482 |
|
] |
1483 |
|
}, |
1484 |
|
}, |
1485 |
|
"operationTypes": { |
1486 |
|
"type": "array", |
1487 |
|
"items": { |
1488 |
|
"enum": [ |
1489 |
|
"INSTANTIATE", |
1490 |
|
"SCALE", |
1491 |
|
"SCALE_TO_LEVEL", |
1492 |
|
"CHANGE_FLAVOUR", |
1493 |
|
"TERMINATE", |
1494 |
|
"HEAL", |
1495 |
|
"OPERATE", |
1496 |
|
"CHANGE_EXT_CONN", |
1497 |
|
"MODIFY_INFO", |
1498 |
|
"CREATE_SNAPSHOT", |
1499 |
|
"REVERT_TO_SNAPSHOT", |
1500 |
|
"CHANGE_VNFPKG", |
1501 |
|
] |
1502 |
|
}, |
1503 |
|
}, |
1504 |
|
"operationStates": { |
1505 |
|
"type": "array", |
1506 |
|
"items": { |
1507 |
|
"enum": [ |
1508 |
|
"STARTING", |
1509 |
|
"PROCESSING", |
1510 |
|
"COMPLETED", |
1511 |
|
"FAILED_TEMP", |
1512 |
|
"FAILED", |
1513 |
|
"ROLLING_BACK", |
1514 |
|
"ROLLED_BACK", |
1515 |
|
] |
1516 |
|
}, |
1517 |
|
}, |
1518 |
|
}, |
1519 |
|
"required": ["VnfInstanceSubscriptionFilter", "notificationTypes"], |
1520 |
|
} |
1521 |
|
|
1522 |
1 |
vnf_subscription = { |
1523 |
|
"title": "vnf subscription input schema", |
1524 |
|
"$schema": "http://json-schema.org/draft-07/schema#", |
1525 |
|
"type": "object", |
1526 |
|
"properties": { |
1527 |
|
"filter": vnflcmsub_schema, |
1528 |
|
"CallbackUri": description_schema, |
1529 |
|
"authentication": authentication_schema, |
1530 |
|
}, |
1531 |
|
"required": ["filter", "CallbackUri"], |
1532 |
|
} |
1533 |
|
|
1534 |
|
|
1535 |
1 |
class ValidationError(Exception): |
1536 |
1 |
def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY): |
1537 |
1 |
self.http_code = http_code |
1538 |
1 |
Exception.__init__(self, message) |
1539 |
|
|
1540 |
|
|
1541 |
1 |
def validate_input(indata, schema_to_use): |
1542 |
|
""" |
1543 |
|
Validates input data against json schema |
1544 |
|
:param indata: user input data. Should be a dictionary |
1545 |
|
:param schema_to_use: jsonschema to test |
1546 |
|
:return: None if ok, raises ValidationError exception on error |
1547 |
|
""" |
1548 |
1 |
try: |
1549 |
1 |
if schema_to_use: |
1550 |
1 |
js_v(indata, schema_to_use) |
1551 |
1 |
return None |
1552 |
1 |
except js_e.ValidationError as e: |
1553 |
1 |
if e.path: |
1554 |
1 |
error_pos = "at '" + ":".join(map(str, e.path)) + "'" |
1555 |
|
else: |
1556 |
1 |
error_pos = "" |
1557 |
1 |
raise ValidationError("Format error {} '{}' ".format(error_pos, e.message)) |
1558 |
0 |
except js_e.SchemaError: |
1559 |
0 |
raise ValidationError( |
1560 |
|
"Bad json schema {}".format(schema_to_use), |
1561 |
|
http_code=HTTPStatus.INTERNAL_SERVER_ERROR, |
1562 |
|
) |
1563 |
|
|
1564 |
|
|
1565 |
1 |
def is_valid_uuid(x): |
1566 |
|
""" |
1567 |
|
Test for a valid UUID |
1568 |
|
:param x: string to test |
1569 |
|
:return: True if x is a valid uuid, False otherwise |
1570 |
|
""" |
1571 |
1 |
try: |
1572 |
1 |
if UUID(x): |
1573 |
1 |
return True |
1574 |
1 |
except (TypeError, ValueError, AttributeError): |
1575 |
1 |
return False |