blob: 95556ffbfa46e5befecb6bbbeb1d0365406f7b05 [file] [log] [blame]
tierno0f98af52018-03-19 10:28:22 +01001# -*- coding: utf-8 -*-
2
tiernod125caf2018-11-22 16:05:54 +00003# 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
tierno0f98af52018-03-19 10:28:22 +010016from jsonschema import validate as js_v, exceptions as js_e
tierno36ec8602018-11-02 17:27:11 +010017from http import HTTPStatus
garciadeblasdaf8cc52018-11-30 14:17:20 +010018from copy import deepcopy
garciadeblas4568a372021-03-24 09:19:48 +010019from uuid import UUID # To test for valid UUID
tierno0f98af52018-03-19 10:28:22 +010020
21__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
22__version__ = "0.1"
23version_date = "Mar 2018"
24
25"""
26Validator of input data using JSON schemas for those items that not contains an OSM yang information model
27"""
28
29# Basis schemas
30patern_name = "^[ -~]+$"
garciadeblas4568a372021-03-24 09:19:48 +010031shortname_schema = {
32 "type": "string",
33 "minLength": 1,
34 "maxLength": 60,
35 "pattern": "^[^,;()\\.\\$'\"]+$",
36}
tierno0f98af52018-03-19 10:28:22 +010037passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60}
garciadeblas6d83f8f2023-06-19 22:34:49 +020038user_passwd_schema = {
39 "type": "string",
40 "pattern": "^.*(?=.{8,})((?=.*[!@#$%^&*()\\-_=+{};:,<.>]){1})(?=.*\\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$",
41}
garciadeblas4568a372021-03-24 09:19:48 +010042name_schema = {
43 "type": "string",
44 "minLength": 1,
45 "maxLength": 255,
46 "pattern": "^[^,;()'\"]+$",
47}
tierno0da52252018-06-27 15:47:22 +020048string_schema = {"type": "string", "minLength": 1, "maxLength": 255}
jeganbe1a3df2024-06-04 12:05:19 +000049email_schema = {
50 "type": "string",
51 "minLength": 1,
52 "maxLength": 320,
53 "pattern": "^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$",
54}
garciadeblas4568a372021-03-24 09:19:48 +010055xml_text_schema = {
56 "type": "string",
57 "minLength": 1,
58 "maxLength": 1000,
59 "pattern": "^[^']+$",
60}
61description_schema = {
62 "type": ["string", "null"],
63 "maxLength": 255,
64 "pattern": "^[^'\"]+$",
65}
66long_description_schema = {
67 "type": ["string", "null"],
68 "maxLength": 3000,
69 "pattern": "^[^'\"]+$",
70}
tierno441dbbf2018-07-10 12:52:48 +020071id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36}
72bool_schema = {"type": "boolean"}
73null_schema = {"type": "null"}
tierno2236d202018-05-16 19:05:16 +020074# "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}$"
garciadeblas4568a372021-03-24 09:19:48 +010075id_schema = {
76 "type": "string",
77 "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$",
78}
79time_schema = {
80 "type": "string",
81 "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}",
82}
83pci_schema = {
84 "type": "string",
85 "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$",
86}
tierno42fce592018-11-02 09:23:43 +010087# allows [] for wildcards. For that reason huge length limit is set
88pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\\[\\]]{12,40}$"}
K Sai Kiran990ac462020-05-20 12:25:12 +053089http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"}
tierno0f98af52018-03-19 10:28:22 +010090bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"}
91memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"}
92integer0_schema = {"type": "integer", "minimum": 0}
93integer1_schema = {"type": "integer", "minimum": 1}
tierno87006042018-10-24 12:50:20 +020094path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"}
tierno0f98af52018-03-19 10:28:22 +010095vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095}
96vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095}
garciadeblas4568a372021-03-24 09:19:48 +010097mac_schema = {
98 "type": "string",
99 "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$",
100} # must be unicast: LSB bit of MSB byte ==0
tiernocb83c942018-09-24 17:28:13 +0200101dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"}
tierno0f98af52018-03-19 10:28:22 +0100102# mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
garciadeblas4568a372021-03-24 09:19:48 +0100103ip_schema = {
104 "type": "string",
105 "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]?)$",
106}
garciadeblas1a01e1f2021-10-26 17:27:35 +0200107ipv6_schema = {
108 "type": "string",
garciadeblasf2af4a12023-01-24 16:56:54 +0100109 "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
garciadeblas1a01e1f2021-10-26 17:27:35 +0200110}
garciadeblas4568a372021-03-24 09:19:48 +0100111ip_prefix_schema = {
112 "type": "string",
113 "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
114 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$",
115}
tierno0f98af52018-03-19 10:28:22 +0100116port_schema = {"type": "integer", "minimum": 1, "maximum": 65534}
117object_schema = {"type": "object"}
118schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2}
119# schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
garciadeblas4568a372021-03-24 09:19:48 +0100120log_level_schema = {
121 "type": "string",
122 "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
123}
tierno0f98af52018-03-19 10:28:22 +0100124checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"}
125size_schema = {"type": "integer", "minimum": 1, "maximum": 100}
tiernocd54a4a2018-09-12 16:40:35 +0200126array_edition_schema = {
127 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100128 "patternProperties": {"^\\$": {}},
tiernocd54a4a2018-09-12 16:40:35 +0200129 "additionalProperties": False,
130 "minProperties": 1,
131}
tiernocb83c942018-09-24 17:28:13 +0200132nameshort_list_schema = {
133 "type": "array",
134 "minItems": 1,
tiernofd160572019-01-21 10:41:37 +0000135 "items": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +0200136}
tiernocd54a4a2018-09-12 16:40:35 +0200137
David Garciaecb41322021-03-31 19:10:46 +0200138description_list_schema = {
139 "type": "array",
140 "minItems": 1,
141 "items": description_schema,
142}
tierno0f98af52018-03-19 10:28:22 +0100143
garciadeblas3fb820d2024-12-05 13:11:11 +0100144profile_type_schema = {
145 "type": "string",
146 "enum": [
147 "infra_controller_profiles",
148 "infra_config_profiles",
149 "app_profiles",
150 "resource_profiles",
151 ],
152}
153
tierno441dbbf2018-07-10 12:52:48 +0200154ns_instantiate_vdu = {
155 "title": "ns action instantiate input schema for vdu",
156 "$schema": "http://json-schema.org/draft-04/schema#",
157 "type": "object",
158 "properties": {
159 "id": name_schema,
Gabriel Cubae88401b2023-04-05 15:24:52 -0500160 "vim-flavor-id": name_schema,
kayal20016a3bce72024-06-27 11:14:59 +0530161 "instance_name": name_schema,
kayal2001b16cf252024-11-28 10:47:32 +0530162 "vim-flavor-name": name_schema,
kayal200170615ab2024-11-28 11:29:36 +0530163 "security-group-name": name_schema,
tierno441dbbf2018-07-10 12:52:48 +0200164 "volume": {
165 "type": "array",
166 "minItems": 1,
167 "items": {
168 "type": "object",
169 "properties": {
170 "name": name_schema,
171 "vim-volume-id": name_schema,
172 },
173 "required": ["name", "vim-volume-id"],
garciadeblas4568a372021-03-24 09:19:48 +0100174 "additionalProperties": False,
175 },
tierno441dbbf2018-07-10 12:52:48 +0200176 },
177 "interface": {
178 "type": "array",
179 "minItems": 1,
180 "items": {
181 "type": "object",
182 "properties": {
183 "name": name_schema,
garciadeblas9fb32712022-04-04 16:33:59 +0200184 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200185 "mac-address": mac_schema,
186 "floating-ip-required": bool_schema,
187 },
188 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +0100189 "additionalProperties": False,
190 },
191 },
tierno441dbbf2018-07-10 12:52:48 +0200192 },
193 "required": ["id"],
garciadeblas4568a372021-03-24 09:19:48 +0100194 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200195}
196
197ip_profile_dns_schema = {
198 "type": "array",
199 "minItems": 1,
200 "items": {
201 "type": "object",
202 "properties": {
garciadeblas9fb32712022-04-04 16:33:59 +0200203 "address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200204 },
205 "required": ["address"],
garciadeblas4568a372021-03-24 09:19:48 +0100206 "additionalProperties": False,
207 },
tierno441dbbf2018-07-10 12:52:48 +0200208}
209
210ip_profile_dhcp_schema = {
211 "type": "object",
212 "properties": {
213 "enabled": {"type": "boolean"},
214 "count": integer1_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100215 "start-address": ip_schema,
tierno441dbbf2018-07-10 12:52:48 +0200216 },
217 "additionalProperties": False,
218}
219
220ip_profile_schema = {
tierno2a929042020-03-10 16:34:25 +0000221 "title": "ip profile validation schema",
tierno441dbbf2018-07-10 12:52:48 +0200222 "$schema": "http://json-schema.org/draft-04/schema#",
223 "type": "object",
224 "properties": {
225 "ip-version": {"enum": ["ipv4", "ipv6"]},
tierno441dbbf2018-07-10 12:52:48 +0200226 "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]},
227 "gateway-address": {"oneOf": [null_schema, ip_schema]},
228 "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200229 "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]},
230 },
garciadeblas4568a372021-03-24 09:19:48 +0100231 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200232}
233
kbsub21f03f52019-10-17 16:26:56 +0000234provider_network_schema = {
tierno2a929042020-03-10 16:34:25 +0000235 "title": "provider network validation schema",
kbsub21f03f52019-10-17 16:26:56 +0000236 "$schema": "http://json-schema.org/draft-04/schema#",
237 "type": "object",
238 "properties": {
239 "physical-network": name_schema,
240 "segmentation-id": name_schema,
tierno2a929042020-03-10 16:34:25 +0000241 "sdn-ports": { # external ports to append to the SDN-assist network
242 "type": "array",
243 "items": {
244 "type": "object",
245 "properties": {
246 "switch_id": shortname_schema,
247 "switch_port": shortname_schema,
248 "mac_address": mac_schema,
249 "vlan": vlan_schema,
250 },
garciadeblas4568a372021-03-24 09:19:48 +0100251 "additionalProperties": True,
252 },
tierno2a929042020-03-10 16:34:25 +0000253 },
254 "network-type": shortname_schema,
kbsub21f03f52019-10-17 16:26:56 +0000255 },
garciadeblas4568a372021-03-24 09:19:48 +0100256 "additionalProperties": True,
kbsub21f03f52019-10-17 16:26:56 +0000257}
258
tierno441dbbf2018-07-10 12:52:48 +0200259ns_instantiate_internal_vld = {
garciadeblas9fb32712022-04-04 16:33:59 +0200260 "title": "ns action instantiate input schema for vld",
tierno441dbbf2018-07-10 12:52:48 +0200261 "$schema": "http://json-schema.org/draft-04/schema#",
262 "type": "object",
263 "properties": {
264 "name": name_schema,
265 "vim-network-name": name_schema,
gcalvino17d5b732018-12-17 16:26:21 +0100266 "vim-network-id": name_schema,
garciadeblas120105b2023-02-22 16:52:24 +0100267 "ip-profile": ip_profile_schema,
kbsub21f03f52019-10-17 16:26:56 +0000268 "provider-network": provider_network_schema,
tierno441dbbf2018-07-10 12:52:48 +0200269 "internal-connection-point": {
270 "type": "array",
271 "minItems": 1,
272 "items": {
273 "type": "object",
274 "properties": {
275 "id-ref": name_schema,
276 "ip-address": ip_schema,
tiernob7c6f2a2018-09-03 14:32:10 +0200277 # "mac-address": mac_schema,
tierno441dbbf2018-07-10 12:52:48 +0200278 },
tiernob7c6f2a2018-09-03 14:32:10 +0200279 "required": ["id-ref"],
280 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100281 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200282 },
garciadeblas4568a372021-03-24 09:19:48 +0100283 },
tierno441dbbf2018-07-10 12:52:48 +0200284 },
285 "required": ["name"],
286 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100287 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200288}
tierno65acb4d2018-04-06 16:42:40 +0200289
tiernofd160572019-01-21 10:41:37 +0000290additional_params_for_vnf = {
291 "type": "array",
292 "items": {
293 "type": "object",
294 "properties": {
295 "member-vnf-index": name_schema,
296 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000297 "k8s-namespace": name_schema,
tiernof62ac6a2020-04-29 13:46:13 +0000298 "config-units": integer1_schema, # number of configuration units of this vnf, by default 1
tierno714954e2019-11-29 13:43:26 +0000299 "additionalParamsForVdu": {
300 "type": "array",
301 "items": {
302 "type": "object",
303 "properties": {
304 "vdu_id": name_schema,
305 "additionalParams": object_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100306 "config-units": integer1_schema, # number of configuration units of this vdu, by default 1
tierno714954e2019-11-29 13:43:26 +0000307 },
tiernof62ac6a2020-04-29 13:46:13 +0000308 "required": ["vdu_id"],
309 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000310 "additionalProperties": False,
311 },
312 },
313 "additionalParamsForKdu": {
314 "type": "array",
315 "items": {
316 "type": "object",
317 "properties": {
318 "kdu_name": name_schema,
319 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000320 "kdu_model": name_schema,
321 "k8s-namespace": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100322 "config-units": integer1_schema, # number of configuration units of this knf, by default 1
romeromonserbfebfc02021-05-28 10:51:35 +0200323 "kdu-deployment-name": name_schema,
tierno714954e2019-11-29 13:43:26 +0000324 },
tierno54db2e42020-04-06 15:29:42 +0000325 "required": ["kdu_name"],
326 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000327 "additionalProperties": False,
328 },
329 },
Alexis Romeroee31f532022-04-26 19:10:21 +0200330 "affinity-or-anti-affinity-group": {
331 "type": "array",
332 "items": {
333 "type": "object",
334 "properties": {
335 "id": name_schema,
336 "vim-affinity-group-id": name_schema,
337 },
338 "required": ["id"],
339 "minProperties": 2,
340 "additionalProperties": False,
341 },
342 },
tiernofd160572019-01-21 10:41:37 +0000343 },
tierno714954e2019-11-29 13:43:26 +0000344 "required": ["member-vnf-index"],
345 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100346 "additionalProperties": False,
347 },
tiernofd160572019-01-21 10:41:37 +0000348}
349
kayal2001f71c2e82024-06-25 15:26:24 +0530350vnf_schema = {
351 "type": "array",
352 "minItems": 1,
353 "items": {
354 "type": "object",
355 "properties": {
356 "member-vnf-index": name_schema,
357 "vimAccountId": id_schema,
358 "vdu": {
359 "type": "array",
360 "minItems": 1,
361 "items": ns_instantiate_vdu,
362 },
363 "internal-vld": {
364 "type": "array",
365 "minItems": 1,
366 "items": ns_instantiate_internal_vld,
367 },
368 },
369 "required": ["member-vnf-index"],
370 "minProperties": 2,
371 "additionalProperties": False,
372 },
373}
374
375vld_schema = {
376 "type": "array",
377 "minItems": 1,
378 "items": {
379 "type": "object",
380 "properties": {
381 "name": string_schema,
382 "vim-network-name": {"oneOf": [string_schema, object_schema]},
383 "vim-network-id": {"oneOf": [string_schema, object_schema]},
384 "ns-net": object_schema,
385 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
386 "ip-profile": ip_profile_schema,
387 "provider-network": provider_network_schema,
388 "vnfd-connection-point-ref": {
389 "type": "array",
390 "minItems": 1,
391 "items": {
392 "type": "object",
393 "properties": {
394 "member-vnf-index-ref": name_schema,
395 "vnfd-connection-point-ref": name_schema,
396 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
397 # "mac-address": mac_schema,
398 },
399 "required": [
400 "member-vnf-index-ref",
401 "vnfd-connection-point-ref",
402 ],
403 "minProperties": 3,
404 "additionalProperties": False,
405 },
406 },
407 },
408 "required": ["name"],
409 "additionalProperties": False,
410 },
411}
412
413ns_config_template = {
414 "title": " ns config template input schema",
415 "$schema": "http://json-schema.org/draft-04/schema#",
416 "type": "object",
417 "properties": {
418 "name": string_schema,
419 "nsdId": id_schema,
420 "config": object_schema,
421 },
422 "required": ["name", "nsdId", "config"],
423 "additionalProperties": False,
424}
425
tierno65acb4d2018-04-06 16:42:40 +0200426ns_instantiate = {
427 "title": "ns action instantiate input schema",
428 "$schema": "http://json-schema.org/draft-04/schema#",
429 "type": "object",
tierno0da52252018-06-27 15:47:22 +0200430 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200431 "lcmOperationType": string_schema,
432 "nsInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +0100433 "netsliceInstanceId": id_schema,
tierno0da52252018-06-27 15:47:22 +0200434 "nsName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +0000435 "nsDescription": {"oneOf": [description_schema, null_schema]},
tierno0da52252018-06-27 15:47:22 +0200436 "nsdId": id_schema,
437 "vimAccountId": id_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530438 "nsConfigTemplateId": id_schema,
tierno195a36c2020-09-18 14:18:55 +0000439 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
magnussonlf318b302020-01-20 18:38:18 +0100440 "placement-engine": string_schema,
441 "placement-constraints": object_schema,
tiernobee085c2018-12-12 17:03:04 +0000442 "additionalParamsForNs": object_schema,
tiernofd160572019-01-21 10:41:37 +0000443 "additionalParamsForVnf": additional_params_for_vnf,
garciadeblas4568a372021-03-24 09:19:48 +0100444 "config-units": integer1_schema, # number of configuration units of this ns, by default 1
tierno54db2e42020-04-06 15:29:42 +0000445 "k8s-namespace": name_schema,
tiernofc5089c2018-10-31 09:28:11 +0100446 "ssh_keys": {"type": "array", "items": {"type": "string"}},
tiernoa8186a52020-01-14 15:54:48 +0000447 "timeout_ns_deploy": integer1_schema,
tierno441dbbf2018-07-10 12:52:48 +0200448 "nsr_id": id_schema,
tiernocc103432018-10-19 14:10:35 +0200449 "vduImage": name_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530450 "vnf": vnf_schema,
451 "vld": vld_schema,
tierno0da52252018-06-27 15:47:22 +0200452 },
tierno441dbbf2018-07-10 12:52:48 +0200453 "required": ["nsName", "nsdId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +0100454 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200455}
tierno0da52252018-06-27 15:47:22 +0200456
tierno1c38f2f2020-03-24 11:51:39 +0000457ns_terminate = {
458 "title": "ns terminate input schema",
459 "$schema": "http://json-schema.org/draft-04/schema#",
460 "type": "object",
461 "properties": {
462 "lcmOperationType": string_schema,
463 "nsInstanceId": id_schema,
464 "autoremove": bool_schema,
465 "timeout_ns_terminate": integer1_schema,
466 "skip_terminate_primitives": bool_schema,
tierno0b8752f2020-05-12 09:42:02 +0000467 "netsliceInstanceId": id_schema,
tierno1c38f2f2020-03-24 11:51:39 +0000468 },
garciadeblas4568a372021-03-24 09:19:48 +0100469 "additionalProperties": False,
tierno1c38f2f2020-03-24 11:51:39 +0000470}
471
aticig544a2ae2022-04-05 09:00:17 +0300472ns_update = {
473 "title": "ns update input schema",
474 "$schema": "http://json-schema.org/draft-04/schema#",
475 "type": "object",
476 "properties": {
477 "lcmOperationType": string_schema,
478 "nsInstanceId": id_schema,
garciadeblaseab15072022-05-19 10:31:52 +0200479 "timeout_ns_update": integer1_schema,
aticig544a2ae2022-04-05 09:00:17 +0300480 "updateType": {
garciadeblasf2af4a12023-01-24 16:56:54 +0100481 "enum": [
482 "CHANGE_VNFPKG",
483 "REMOVE_VNF",
484 "MODIFY_VNF_INFORMATION",
485 "OPERATE_VNF",
Rahul Kumara30391b2024-05-24 14:40:23 +0530486 "VERTICAL_SCALE",
garciadeblasf2af4a12023-01-24 16:56:54 +0100487 ]
aticig544a2ae2022-04-05 09:00:17 +0300488 },
489 "modifyVnfInfoData": {
490 "type": "object",
491 "properties": {
492 "vnfInstanceId": id_schema,
493 "vnfdId": id_schema,
494 },
495 "required": ["vnfInstanceId", "vnfdId"],
496 },
497 "removeVnfInstanceId": id_schema,
498 "changeVnfPackageData": {
499 "type": "object",
500 "properties": {
501 "vnfInstanceId": id_schema,
502 "vnfdId": id_schema,
503 },
504 "required": ["vnfInstanceId", "vnfdId"],
505 },
k4.rahule3dca382022-04-29 12:30:36 +0000506 "operateVnfData": {
507 "type": "object",
508 "properties": {
509 "vnfInstanceId": id_schema,
510 "changeStateTo": name_schema,
511 "additionalParam": {
512 "type": "object",
513 "properties": {
514 "run-day1": bool_schema,
515 "vdu_id": name_schema,
516 "count-index": integer0_schema,
517 },
518 "required": ["vdu_id", "count-index"],
519 "additionalProperties": False,
garciadeblasf2af4a12023-01-24 16:56:54 +0100520 },
k4.rahule3dca382022-04-29 12:30:36 +0000521 },
522 "required": ["vnfInstanceId", "changeStateTo"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100523 },
Rahul Kumara30391b2024-05-24 14:40:23 +0530524 "verticalScaleVnf": {
525 "type": "object",
526 "properties": {
527 "vnfInstanceId": id_schema,
528 "vnfdId": id_schema,
529 "vduId": name_schema,
530 "countIndex": integer0_schema,
531 },
532 "required": ["vnfInstanceId", "vnfdId", "vduId"],
533 },
aticig544a2ae2022-04-05 09:00:17 +0300534 },
535 "required": ["updateType"],
536 "additionalProperties": False,
537}
538
garciadeblas4568a372021-03-24 09:19:48 +0100539ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
tiernof759d822018-06-11 18:54:54 +0200540 "title": "ns action input schema",
tierno65acb4d2018-04-06 16:42:40 +0200541 "$schema": "http://json-schema.org/draft-04/schema#",
542 "type": "object",
543 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200544 "lcmOperationType": string_schema,
545 "nsInstanceId": id_schema,
tiernof5298be2018-05-16 14:43:57 +0200546 "member_vnf_index": name_schema,
547 "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future
tierno7ce1db92018-07-25 12:50:52 +0200548 "vdu_id": name_schema,
tiernof0637052019-03-07 16:26:47 +0000549 "vdu_count_index": integer0_schema,
tierno9cb7d672019-10-30 12:13:48 +0000550 "kdu_name": name_schema,
tierno65acb4d2018-04-06 16:42:40 +0200551 "primitive": name_schema,
tierno50c8e6e2020-04-02 15:40:12 +0000552 "timeout_ns_action": integer1_schema,
tierno65acb4d2018-04-06 16:42:40 +0200553 "primitive_params": {"type": "object"},
554 },
garciadeblas4568a372021-03-24 09:19:48 +0100555 "required": ["primitive", "primitive_params"], # TODO add member_vnf_index
556 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200557}
garciadeblas0964edf2022-02-11 00:43:44 +0100558
garciadeblas4568a372021-03-24 09:19:48 +0100559ns_scale = { # TODO for the moment it is only VDU-scaling
tiernof759d822018-06-11 18:54:54 +0200560 "title": "ns scale input schema",
561 "$schema": "http://json-schema.org/draft-04/schema#",
562 "type": "object",
563 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200564 "lcmOperationType": string_schema,
565 "nsInstanceId": id_schema,
tiernof759d822018-06-11 18:54:54 +0200566 "scaleType": {"enum": ["SCALE_VNF"]},
tierno50c8e6e2020-04-02 15:40:12 +0000567 "timeout_ns_scale": integer1_schema,
tiernof759d822018-06-11 18:54:54 +0200568 "scaleVnfData": {
569 "type": "object",
570 "properties": {
571 "vnfInstanceId": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100572 "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]},
tiernof759d822018-06-11 18:54:54 +0200573 "scaleByStepData": {
574 "type": "object",
575 "properties": {
576 "scaling-group-descriptor": name_schema,
577 "member-vnf-index": name_schema,
578 "scaling-policy": name_schema,
579 },
580 "required": ["scaling-group-descriptor", "member-vnf-index"],
garciadeblas4568a372021-03-24 09:19:48 +0100581 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200582 },
583 },
584 "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId
garciadeblas4568a372021-03-24 09:19:48 +0100585 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200586 },
587 "scaleTime": time_schema,
588 },
589 "required": ["scaleType", "scaleVnfData"],
garciadeblas4568a372021-03-24 09:19:48 +0100590 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200591}
tierno65acb4d2018-04-06 16:42:40 +0200592
elumalai8e3806c2022-04-28 17:26:24 +0530593ns_migrate = {
594 "title": "ns migrate input schema",
595 "$schema": "http://json-schema.org/draft-04/schema#",
596 "type": "object",
597 "properties": {
598 "lcmOperationType": string_schema,
599 "nsInstanceId": id_schema,
600 "vnfInstanceId": id_schema,
601 "migrateToHost": string_schema,
Pedro Pereira5f4809d2024-08-23 10:40:28 +0100602 "targetHostK8sLabels": object_schema,
elumalai8e3806c2022-04-28 17:26:24 +0530603 "vdu": {
604 "type": "object",
garciadeblasf2af4a12023-01-24 16:56:54 +0100605 "properties": {
606 "vduId": name_schema,
607 "vduCountIndex": integer0_schema,
608 },
609 "required": ["vduId"],
610 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530611 },
612 },
613 "required": ["vnfInstanceId"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100614 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530615}
tierno65acb4d2018-04-06 16:42:40 +0200616
garciadeblas0964edf2022-02-11 00:43:44 +0100617ns_heal = {
618 "title": "ns heal input schema",
619 "$schema": "http://json-schema.org/draft-04/schema#",
620 "type": "object",
621 "properties": {
622 "lcmOperationType": string_schema,
623 "nsInstanceId": id_schema,
624 "timeout_ns_heal": integer1_schema,
625 "healVnfData": {
626 "type": "array",
627 "items": {
628 "type": "object",
629 "properties": {
630 "vnfInstanceId": id_schema,
631 "cause": description_schema,
632 "additionalParams": {
633 "type": "object",
634 "properties": {
635 "run-day1": bool_schema,
636 "vdu": {
637 "type": "array",
638 "items": {
639 "type": "object",
640 "properties": {
641 "run-day1": bool_schema,
642 "vdu-id": name_schema,
643 "count-index": integer0_schema,
644 },
645 "required": ["vdu-id"],
646 "additionalProperties": False,
647 },
648 },
649 },
650 "additionalProperties": False,
651 },
652 },
653 "required": ["vnfInstanceId"],
654 "additionalProperties": False,
655 },
656 },
657 },
658 "required": ["healVnfData"],
659 "additionalProperties": False,
660}
661
Gabriel Cuba84a60df2023-10-30 14:01:54 -0500662nslcmop_cancel = {
663 "title": "Cancel nslcmop input schema",
664 "$schema": "http://json-schema.org/draft-04/schema#",
665 "type": "object",
666 "properties": {
667 "nsLcmOpOccId": id_schema,
668 "cancelMode": {
669 "enum": [
670 "GRACEFUL",
671 "FORCEFUL",
672 ]
673 },
674 },
675 "required": ["cancelMode"],
676 "additionalProperties": False,
677}
678
tierno0f98af52018-03-19 10:28:22 +0100679schema_version = {"type": "string", "enum": ["1.0"]}
tierno55ba2e62018-12-11 17:22:22 +0000680schema_type = {"type": "string"}
tiernob3d0a0e2019-11-13 15:57:51 +0000681vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200682
tierno09c073e2018-04-26 13:36:48 +0200683vim_account_edit_schema = {
684 "title": "vim_account edit input schema",
685 "$schema": "http://json-schema.org/draft-04/schema#",
686 "type": "object",
687 "properties": {
688 "name": name_schema,
689 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200690 "vim": name_schema,
691 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200692 "vim_type": vim_type,
tierno09c073e2018-04-26 13:36:48 +0200693 "vim_url": description_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200694 # "vim_url_admin": description_schema,
695 # "vim_tenant": name_schema,
tierno09c073e2018-04-26 13:36:48 +0200696 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200697 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200698 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200699 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100700 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000701 "prometheus-config": {"type": "object"},
tierno09c073e2018-04-26 13:36:48 +0200702 },
garciadeblas4568a372021-03-24 09:19:48 +0100703 "additionalProperties": False,
tierno09c073e2018-04-26 13:36:48 +0200704}
tierno0f98af52018-03-19 10:28:22 +0100705
tierno09c073e2018-04-26 13:36:48 +0200706vim_account_new_schema = {
707 "title": "vim_account creation input schema",
tierno0f98af52018-03-19 10:28:22 +0100708 "$schema": "http://json-schema.org/draft-04/schema#",
709 "type": "object",
710 "properties": {
711 "schema_version": schema_version,
712 "schema_type": schema_type,
713 "name": name_schema,
714 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200715 "vim": name_schema,
716 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200717 "vim_type": vim_type,
tierno0f98af52018-03-19 10:28:22 +0100718 "vim_url": description_schema,
719 # "vim_url_admin": description_schema,
720 # "vim_tenant": name_schema,
721 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200722 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200723 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200724 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100725 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000726 "prometheus-config": {"type": "object"},
tierno0f98af52018-03-19 10:28:22 +0100727 },
garciadeblas4568a372021-03-24 09:19:48 +0100728 "required": [
729 "name",
730 "vim_url",
731 "vim_type",
732 "vim_user",
733 "vim_password",
734 "vim_tenant_name",
735 ],
736 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100737}
tierno0f98af52018-03-19 10:28:22 +0100738
tierno85807722019-12-20 14:11:35 +0000739wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200740
tierno55ba2e62018-12-11 17:22:22 +0000741wim_account_edit_schema = {
742 "title": "wim_account edit input schema",
743 "$schema": "http://json-schema.org/draft-04/schema#",
744 "type": "object",
745 "properties": {
746 "name": name_schema,
747 "description": description_schema,
tierno55ba2e62018-12-11 17:22:22 +0000748 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200749 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000750 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100751 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000752 "password": passwd_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100753 "config": {"type": "object"},
tierno55ba2e62018-12-11 17:22:22 +0000754 },
garciadeblas4568a372021-03-24 09:19:48 +0100755 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000756}
757
758wim_account_new_schema = {
759 "title": "wim_account creation input schema",
760 "$schema": "http://json-schema.org/draft-04/schema#",
761 "type": "object",
762 "properties": {
763 "schema_version": schema_version,
764 "schema_type": schema_type,
765 "name": name_schema,
766 "description": description_schema,
767 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200768 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000769 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100770 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000771 "password": passwd_schema,
tiernof0637052019-03-07 16:26:47 +0000772 "config": {
773 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100774 "patternProperties": {".": {"not": {"type": "null"}}},
775 },
tierno55ba2e62018-12-11 17:22:22 +0000776 },
777 "required": ["name", "wim_url", "wim_type"],
garciadeblas4568a372021-03-24 09:19:48 +0100778 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000779}
tierno0f98af52018-03-19 10:28:22 +0100780
781sdn_properties = {
782 "name": name_schema,
tierno7adaeb02019-12-17 16:46:12 +0000783 "type": {"type": "string"},
784 "url": {"type": "string"},
sousaedu80b6fed2021-10-07 15:17:32 +0100785 "user": string_schema,
tierno7adaeb02019-12-17 16:46:12 +0000786 "password": passwd_schema,
787 "config": {"type": "object"},
tiernocfb07c62018-05-10 18:30:51 +0200788 "description": description_schema,
tierno7adaeb02019-12-17 16:46:12 +0000789 # The folowing are deprecated. Maintanied for backward compatibility
tiernocb83c942018-09-24 17:28:13 +0200790 "dpid": dpid_Schema,
tierno0f98af52018-03-19 10:28:22 +0100791 "ip": ip_schema,
792 "port": port_schema,
tierno0f98af52018-03-19 10:28:22 +0100793 "version": {"type": "string", "minLength": 1, "maxLength": 12},
tierno0f98af52018-03-19 10:28:22 +0100794}
795sdn_new_schema = {
796 "title": "sdn controller information schema",
797 "$schema": "http://json-schema.org/draft-04/schema#",
798 "type": "object",
799 "properties": sdn_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100800 "required": ["name", "type"],
801 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100802}
803sdn_edit_schema = {
804 "title": "sdn controller update information schema",
805 "$schema": "http://json-schema.org/draft-04/schema#",
806 "type": "object",
807 "properties": sdn_properties,
tiernocfb07c62018-05-10 18:30:51 +0200808 # "required": ["name", "port", 'ip', 'dpid', 'type'],
garciadeblas4568a372021-03-24 09:19:48 +0100809 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100810}
811sdn_port_mapping_schema = {
812 "$schema": "http://json-schema.org/draft-04/schema#",
813 "title": "sdn port mapping information schema",
814 "type": "array",
815 "items": {
816 "type": "object",
817 "properties": {
tiernofd160572019-01-21 10:41:37 +0000818 "compute_node": shortname_schema,
tierno0f98af52018-03-19 10:28:22 +0100819 "ports": {
820 "type": "array",
821 "items": {
822 "type": "object",
823 "properties": {
tierno42fce592018-11-02 09:23:43 +0100824 "pci": pci_extended_schema,
tiernofd160572019-01-21 10:41:37 +0000825 "switch_port": shortname_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100826 "switch_mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100827 },
garciadeblas4568a372021-03-24 09:19:48 +0100828 "required": ["pci"],
829 },
830 },
tierno0f98af52018-03-19 10:28:22 +0100831 },
garciadeblas4568a372021-03-24 09:19:48 +0100832 "required": ["compute_node", "ports"],
833 },
tierno0f98af52018-03-19 10:28:22 +0100834}
835sdn_external_port_schema = {
836 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocd54a4a2018-09-12 16:40:35 +0200837 "title": "External port information",
tierno0f98af52018-03-19 10:28:22 +0100838 "type": "object",
839 "properties": {
840 "port": {"type": "string", "minLength": 1, "maxLength": 60},
841 "vlan": vlan_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100842 "mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100843 },
garciadeblas4568a372021-03-24 09:19:48 +0100844 "required": ["port"],
tierno0f98af52018-03-19 10:28:22 +0100845}
846
delacruzramofe598fe2019-10-23 18:25:11 +0200847# K8s Clusters
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500848k8scluster_deploy_method_schema = {
849 "$schema": "http://json-schema.org/draft-04/schema#",
850 "title": "Deployment methods for K8s cluster",
851 "type": "object",
852 "properties": {
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500853 "juju-bundle": {"type": "boolean"},
854 "helm-chart-v3": {"type": "boolean"},
855 },
856 "additionalProperties": False,
Luis Vega0a1efed2023-11-28 16:44:30 +0000857 "minProperties": 2,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500858}
delacruzramofe598fe2019-10-23 18:25:11 +0200859k8scluster_nets_schema = {
860 "title": "k8scluster nets input schema",
861 "$schema": "http://json-schema.org/draft-04/schema#",
862 "type": "object",
tierno8c81ab02020-02-07 10:18:30 +0000863 "patternProperties": {".": {"oneOf": [name_schema, null_schema]}},
delacruzramofe598fe2019-10-23 18:25:11 +0200864 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100865 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200866}
867k8scluster_new_schema = {
868 "title": "k8scluster creation input schema",
869 "$schema": "http://json-schema.org/draft-04/schema#",
870 "type": "object",
871 "properties": {
872 "schema_version": schema_version,
873 "schema_type": schema_type,
874 "name": name_schema,
875 "description": description_schema,
876 "credentials": object_schema,
877 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200878 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200879 "k8s_version": string_schema,
880 "nets": k8scluster_nets_schema,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500881 "deployment_methods": k8scluster_deploy_method_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200882 "namespace": name_schema,
883 "cni": nameshort_list_schema,
884 },
885 "required": ["name", "credentials", "vim_account", "k8s_version", "nets"],
garciadeblas4568a372021-03-24 09:19:48 +0100886 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200887}
888k8scluster_edit_schema = {
889 "title": "vim_account edit input schema",
890 "$schema": "http://json-schema.org/draft-04/schema#",
891 "type": "object",
892 "properties": {
893 "name": name_schema,
894 "description": description_schema,
895 "credentials": object_schema,
896 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200897 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200898 "k8s_version": string_schema,
899 "nets": k8scluster_nets_schema,
900 "namespace": name_schema,
901 "cni": nameshort_list_schema,
902 },
garciadeblas4568a372021-03-24 09:19:48 +0100903 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200904}
905
David Garciaecb41322021-03-31 19:10:46 +0200906# VCA
907vca_new_schema = {
908 "title": "vca creation input schema",
909 "$schema": "http://json-schema.org/draft-04/schema#",
910 "type": "object",
911 "properties": {
912 "schema_version": schema_version,
913 "schema_type": schema_type,
914 "name": name_schema,
915 "description": description_schema,
916 "endpoints": description_list_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100917 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200918 "secret": passwd_schema,
919 "cacert": long_description_schema,
920 "lxd-cloud": shortname_schema,
921 "lxd-credentials": shortname_schema,
922 "k8s-cloud": shortname_schema,
923 "k8s-credentials": shortname_schema,
924 "model-config": object_schema,
925 },
926 "required": [
927 "name",
928 "endpoints",
929 "user",
930 "secret",
931 "cacert",
932 "lxd-cloud",
933 "lxd-credentials",
934 "k8s-cloud",
935 "k8s-credentials",
936 ],
937 "additionalProperties": False,
938}
939vca_edit_schema = {
940 "title": "vca creation input schema",
941 "$schema": "http://json-schema.org/draft-04/schema#",
942 "type": "object",
943 "properties": {
944 "name": name_schema,
945 "description": description_schema,
946 "endpoints": description_list_schema,
947 "port": integer1_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100948 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200949 "secret": passwd_schema,
950 "cacert": long_description_schema,
951 "lxd-cloud": shortname_schema,
952 "lxd-credentials": shortname_schema,
953 "k8s-cloud": shortname_schema,
954 "k8s-credentials": shortname_schema,
955 "model-config": object_schema,
956 },
957 "additionalProperties": False,
958}
959
delacruzramofe598fe2019-10-23 18:25:11 +0200960# K8s Repos
tierno332e0802019-12-03 23:50:49 +0000961k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]}
delacruzramofe598fe2019-10-23 18:25:11 +0200962k8srepo_properties = {
963 "name": name_schema,
964 "description": description_schema,
965 "type": k8srepo_types,
966 "url": description_schema,
Luis Vegaf6574e32023-07-11 18:47:22 +0000967 "cacert": long_description_schema,
968 "user": string_schema,
969 "password": passwd_schema,
garciadeblasf3543892023-10-20 11:53:51 +0200970 "oci": bool_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200971}
972k8srepo_new_schema = {
973 "title": "k8scluster creation input schema",
974 "$schema": "http://json-schema.org/draft-04/schema#",
975 "type": "object",
976 "properties": k8srepo_properties,
977 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100978 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200979}
980k8srepo_edit_schema = {
981 "title": "vim_account edit input schema",
982 "$schema": "http://json-schema.org/draft-04/schema#",
983 "type": "object",
984 "properties": k8srepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100985 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200986}
987
Felipe Vicensb66b0412020-05-06 10:11:00 +0200988# OSM Repos
989osmrepo_types = {"enum": ["osm"]}
990osmrepo_properties = {
991 "name": name_schema,
992 "description": description_schema,
993 "type": osmrepo_types,
rshri2d386cb2024-07-05 14:35:51 +0000994 "url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100995 # "user": string_schema,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200996 # "password": passwd_schema
997}
998osmrepo_new_schema = {
999 "title": "osm repo creation input schema",
1000 "$schema": "http://json-schema.org/draft-04/schema#",
1001 "type": "object",
1002 "properties": osmrepo_properties,
1003 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +01001004 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001005}
1006osmrepo_edit_schema = {
1007 "title": "osm repo edit input schema",
1008 "$schema": "http://json-schema.org/draft-04/schema#",
1009 "type": "object",
1010 "properties": osmrepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +01001011 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001012}
1013
tiernocb83c942018-09-24 17:28:13 +02001014# PDUs
1015pdu_interface = {
1016 "type": "object",
1017 "properties": {
tiernofd160572019-01-21 10:41:37 +00001018 "name": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001019 "mgmt": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001020 "type": {"enum": ["overlay", "underlay"]},
garciadeblas1a01e1f2021-10-26 17:27:35 +02001021 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernocb83c942018-09-24 17:28:13 +02001022 # TODO, add user, password, ssh-key
tierno36ec8602018-11-02 17:27:11 +01001023 "mac-address": mac_schema,
tiernofd160572019-01-21 10:41:37 +00001024 "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
1025 "vim-network-id": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001026 # # provide this in case SDN assist must deal with this interface
1027 # "switch-dpid": dpid_Schema,
tiernofd160572019-01-21 10:41:37 +00001028 # "switch-port": shortname_schema,
1029 # "switch-mac": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001030 # "switch-vlan": vlan_schema,
tiernocb83c942018-09-24 17:28:13 +02001031 },
tierno36ec8602018-11-02 17:27:11 +01001032 "required": ["name", "mgmt", "ip-address"],
garciadeblas4568a372021-03-24 09:19:48 +01001033 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001034}
tiernocb83c942018-09-24 17:28:13 +02001035pdu_new_schema = {
1036 "title": "pdu creation input schema",
1037 "$schema": "http://json-schema.org/draft-04/schema#",
1038 "type": "object",
1039 "properties": {
tiernofd160572019-01-21 10:41:37 +00001040 "name": shortname_schema,
1041 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001042 "description": description_schema,
1043 "shared": bool_schema,
1044 "vims": nameshort_list_schema,
1045 "vim_accounts": nameshort_list_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001046 "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1},
tiernocb83c942018-09-24 17:28:13 +02001047 },
1048 "required": ["name", "type", "interfaces"],
garciadeblas4568a372021-03-24 09:19:48 +01001049 "additionalProperties": False,
tiernocb83c942018-09-24 17:28:13 +02001050}
tiernocb83c942018-09-24 17:28:13 +02001051pdu_edit_schema = {
1052 "title": "pdu edit input schema",
1053 "$schema": "http://json-schema.org/draft-04/schema#",
1054 "type": "object",
1055 "properties": {
tiernofd160572019-01-21 10:41:37 +00001056 "name": shortname_schema,
1057 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001058 "description": description_schema,
1059 "shared": bool_schema,
garciadeblas84bdd552018-11-30 22:59:45 +01001060 "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
1061 "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
garciadeblas4568a372021-03-24 09:19:48 +01001062 "interfaces": {
1063 "oneOf": [
1064 array_edition_schema,
1065 {"type": "array", "items": pdu_interface, "minItems": 1},
1066 ]
1067 },
tiernocb83c942018-09-24 17:28:13 +02001068 },
1069 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001070 "minProperties": 1,
tiernocb83c942018-09-24 17:28:13 +02001071}
1072
delacruzramo271d2002019-12-02 21:00:37 +01001073# VNF PKG OPERATIONS
1074vnfpkgop_new_schema = {
1075 "title": "VNF PKG operation creation input schema",
1076 "$schema": "http://json-schema.org/draft-04/schema#",
1077 "type": "object",
1078 "properties": {
1079 "lcmOperationType": string_schema,
1080 "vnfPkgId": id_schema,
1081 "kdu_name": name_schema,
1082 "primitive": name_schema,
1083 "primitive_params": {"type": "object"},
1084 },
garciadeblas4568a372021-03-24 09:19:48 +01001085 "required": [
1086 "lcmOperationType",
1087 "vnfPkgId",
1088 "kdu_name",
1089 "primitive",
1090 "primitive_params",
1091 ],
1092 "additionalProperties": False,
delacruzramo271d2002019-12-02 21:00:37 +01001093}
1094
rshri2d386cb2024-07-05 14:35:51 +00001095clustercreation_new_schema = {
1096 "title": "cluster creation operation input schema",
1097 "$schema": "http://json-schema.org/draft-04/schema#",
1098 "type": "object",
1099 "properties": {
1100 "name": name_schema,
1101 "vim_account": string_schema,
1102 "k8s_version": string_schema,
1103 "node_size": string_schema,
1104 "node_count": integer0_schema,
rshri17b09ec2024-11-07 05:48:12 +00001105 "description": description_schema,
rshri2d386cb2024-07-05 14:35:51 +00001106 "region_name": string_schema,
1107 "resource_group": string_schema,
1108 "infra_controller_profiles": shortname_schema,
1109 "infra_config_profiles": shortname_schema,
1110 "resource_profiles": shortname_schema,
1111 "app_profiles": shortname_schema,
rshri17b09ec2024-11-07 05:48:12 +00001112 "created": string_schema,
1113 "state": string_schema,
1114 "operatingState": string_schema,
1115 "git_name": string_schema,
1116 "resourceState": string_schema,
1117 "bootstrap": bool_schema,
rshri2d386cb2024-07-05 14:35:51 +00001118 },
1119 "required": [
1120 "name",
1121 "vim_account",
1122 "k8s_version",
1123 "node_size",
1124 "node_count",
rshri2d386cb2024-07-05 14:35:51 +00001125 ],
1126 "additionalProperties": False,
1127}
rshri17b09ec2024-11-07 05:48:12 +00001128clusterregistration_new_schema = {
1129 "title": "cluster registration input schema",
1130 "$schema": "http://json-schema.org/draft-04/schema#",
1131 "type": "object",
1132 "properties": {
1133 "schema_version": schema_version,
1134 "schema_type": schema_type,
1135 "name": name_schema,
1136 "description": description_schema,
1137 "credentials": object_schema,
1138 "vim_account": string_schema,
1139 "bootstrap": bool_schema,
1140 },
1141 "required": ["name", "credentials", "vim_account"],
1142 "additionalProperties": False,
1143}
rshri2d386cb2024-07-05 14:35:51 +00001144
yshah99122b82024-11-18 07:05:29 +00001145cluster_edit_schema = {
1146 "title": "cluster edit schema",
1147 "$schema": "http://json-schema.org/draft-04/schema#",
1148 "type": "object",
1149 "properties": {
1150 "name": name_schema,
1151 "description": string_schema,
1152 },
1153 "additionalProperties": False,
1154}
1155
1156cluster_update_schema = {
1157 "title": "cluster update schema",
1158 "$schema": "http://json-schema.org/draft-04/schema#",
1159 "type": "object",
1160 "properties": {
1161 "k8s_version": string_schema,
1162 "node_size": string_schema,
1163 "node_count": integer0_schema,
1164 },
1165 "additionalProperties": True,
1166}
1167
rshri2d386cb2024-07-05 14:35:51 +00001168infra_controller_profile_create_new_schema = {
1169 "title": "infra profile creation operation input schema",
1170 "$schema": "http://json-schema.org/draft-04/schema#",
1171 "type": "object",
1172 "properties": {
1173 "name": name_schema,
1174 "description": string_schema,
1175 },
1176 "additionalProperties": False,
1177}
1178
1179infra_controller_profile_create_edit_schema = {
1180 "title": "infra profile creation operation input schema",
1181 "$schema": "http://json-schema.org/draft-04/schema#",
1182 "type": "object",
1183 "properties": {
1184 "name": name_schema,
1185 "description": string_schema,
1186 },
1187 "additionalProperties": False,
1188}
1189
1190infra_config_profile_create_new_schema = {
1191 "title": "infra profile creation operation input schema",
1192 "$schema": "http://json-schema.org/draft-04/schema#",
1193 "type": "object",
1194 "properties": {
1195 "name": name_schema,
1196 "description": string_schema,
1197 },
1198 "additionalProperties": False,
1199}
1200
1201infra_config_profile_create_edit_schema = {
1202 "title": "infra profile creation operation input schema",
1203 "$schema": "http://json-schema.org/draft-04/schema#",
1204 "type": "object",
1205 "properties": {
1206 "name": name_schema,
1207 "description": string_schema,
1208 },
1209 "additionalProperties": False,
1210}
1211
1212app_profile_create_new_schema = {
1213 "title": "app profile creation operation input schema",
1214 "$schema": "http://json-schema.org/draft-04/schema#",
1215 "type": "object",
1216 "properties": {
1217 "name": name_schema,
1218 "description": string_schema,
1219 },
1220 "additionalProperties": False,
1221}
1222app_profile_create_edit_schema = {
1223 "title": "app profile creation operation input schema",
1224 "$schema": "http://json-schema.org/draft-04/schema#",
1225 "type": "object",
1226 "properties": {
1227 "name": name_schema,
1228 "description": string_schema,
1229 },
1230 "additionalProperties": False,
1231}
1232
1233resource_profile_create_new_schema = {
1234 "title": "resource profile creation operation input schema",
1235 "$schema": "http://json-schema.org/draft-04/schema#",
1236 "type": "object",
1237 "properties": {
1238 "name": name_schema,
1239 "description": string_schema,
1240 },
1241 "additionalProperties": False,
1242}
1243resource_profile_create_edit_schema = {
1244 "title": "resource profile creation operation input schema",
1245 "$schema": "http://json-schema.org/draft-04/schema#",
1246 "type": "object",
1247 "properties": {
1248 "name": name_schema,
1249 "description": string_schema,
1250 },
1251 "additionalProperties": False,
1252}
1253
1254attach_profile = {
1255 "type": "array",
1256 "items": {
1257 "type": "object",
1258 "properties": {"id": id_schema},
1259 "additionalProperties": False,
1260 },
1261}
1262remove_profile = {
1263 "type": "array",
1264 "items": {
1265 "type": "object",
1266 "properties": {"id": id_schema},
1267 "additionalProperties": False,
1268 },
1269}
1270attach_dettach_profile_schema = {
1271 "title": "attach/dettach profiles",
1272 "$schema": "http://json-schema.org/draft-04/schema#",
1273 "type": "object",
1274 "properties": {
1275 "add_profile": attach_profile,
1276 "remove_profile": remove_profile,
1277 },
1278 "additionalProperties": False,
1279}
tiernocb83c942018-09-24 17:28:13 +02001280# USERS
tiernocf042d32019-06-13 09:06:40 +00001281project_role_mappings = {
1282 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001283 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001284 "type": "array",
1285 "items": {
1286 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001287 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001288 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001289 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001290 },
garciadeblas4568a372021-03-24 09:19:48 +01001291 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001292}
rshri2d386cb2024-07-05 14:35:51 +00001293
tiernocf042d32019-06-13 09:06:40 +00001294project_role_mappings_optional = {
1295 "title": "list of projects/roles or projects only",
1296 "$schema": "http://json-schema.org/draft-04/schema#",
1297 "type": "array",
1298 "items": {
1299 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001300 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001301 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001302 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001303 },
garciadeblas4568a372021-03-24 09:19:48 +01001304 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001305}
rshri2d386cb2024-07-05 14:35:51 +00001306
tiernocd54a4a2018-09-12 16:40:35 +02001307user_new_schema = {
1308 "$schema": "http://json-schema.org/draft-04/schema#",
1309 "title": "New user schema",
1310 "type": "object",
1311 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001312 "username": string_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001313 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001314 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001315 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001316 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001317 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001318 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001319 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001320 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001321}
1322user_edit_schema = {
1323 "$schema": "http://json-schema.org/draft-04/schema#",
1324 "title": "User edit schema for administrators",
1325 "type": "object",
1326 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001327 "password": user_passwd_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001328 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001329 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001330 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001331 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001332 "project_role_mappings": project_role_mappings,
1333 "add_project_role_mappings": project_role_mappings,
1334 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001335 "system_admin_id": id_schema,
1336 "unlock": bool_schema,
1337 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001338 },
1339 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001340 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001341}
1342
1343# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001344topics_with_quota = [
1345 "vnfds",
1346 "nsds",
1347 "slice_templates",
1348 "pduds",
1349 "ns_instances",
1350 "slice_instances",
1351 "vim_accounts",
1352 "wim_accounts",
1353 "sdn_controllers",
1354 "k8sclusters",
1355 "vca",
1356 "k8srepos",
1357 "osmrepos",
1358 "ns_subscriptions",
1359]
tiernocd54a4a2018-09-12 16:40:35 +02001360project_new_schema = {
1361 "$schema": "http://json-schema.org/draft-04/schema#",
1362 "title": "New project schema for administrators",
1363 "type": "object",
1364 "properties": {
tiernofd160572019-01-21 10:41:37 +00001365 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001366 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001367 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001368 "quotas": {
1369 "type": "object",
1370 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001371 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001372 },
tiernocd54a4a2018-09-12 16:40:35 +02001373 },
1374 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001375 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001376}
1377project_edit_schema = {
1378 "$schema": "http://json-schema.org/draft-04/schema#",
1379 "title": "Project edit schema for administrators",
1380 "type": "object",
1381 "properties": {
1382 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001383 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001384 "quotas": {
1385 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001386 "properties": {
1387 topic: {"oneOf": [integer0_schema, null_schema]}
1388 for topic in topics_with_quota
1389 },
1390 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001391 },
tiernocd54a4a2018-09-12 16:40:35 +02001392 },
1393 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001394 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001395}
1396
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001397# ROLES
1398roles_new_schema = {
1399 "$schema": "http://json-schema.org/draft-04/schema#",
1400 "title": "New role schema for administrators",
1401 "type": "object",
1402 "properties": {
1403 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001404 "permissions": {
1405 "type": "object",
1406 "patternProperties": {
1407 ".": bool_schema,
1408 },
1409 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001410 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001411 },
tierno1f029d82019-06-13 22:37:04 +00001412 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001413 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001414}
1415roles_edit_schema = {
1416 "$schema": "http://json-schema.org/draft-04/schema#",
1417 "title": "Roles edit schema for administrators",
1418 "type": "object",
1419 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001420 "name": shortname_schema,
1421 "permissions": {
1422 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001423 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001424 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001425 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001426 },
tierno1f029d82019-06-13 22:37:04 +00001427 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001428 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001429}
1430
tiernocd54a4a2018-09-12 16:40:35 +02001431# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001432
1433nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001434 "users": user_new_schema,
1435 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001436 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001437 "sdns": sdn_new_schema,
1438 "ns_instantiate": ns_instantiate,
1439 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001440 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001441 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001442 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001443 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001444}
1445
1446nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001447 "users": user_edit_schema,
1448 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001449 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001450 "sdns": sdn_edit_schema,
1451 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301452 "vnf": vnf_schema,
1453 "vld": vld_schema,
1454 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001455}
1456
Felipe Vicens07f31722018-10-29 15:16:44 +01001457# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001458nsi_subnet_instantiate = deepcopy(ns_instantiate)
1459nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1460nsi_subnet_instantiate["properties"]["id"] = name_schema
1461del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001462
1463nsi_vld_instantiate = {
1464 "title": "netslice vld instantiation params input schema",
1465 "$schema": "http://json-schema.org/draft-04/schema#",
1466 "type": "object",
1467 "properties": {
1468 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001469 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1470 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001471 "ip-profile": object_schema,
1472 },
delacruzramoc061f562019-04-05 11:00:02 +02001473 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001474 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001475}
1476
Felipe Vicens07f31722018-10-29 15:16:44 +01001477nsi_instantiate = {
1478 "title": "netslice action instantiate input schema",
1479 "$schema": "http://json-schema.org/draft-04/schema#",
1480 "type": "object",
1481 "properties": {
1482 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001483 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001484 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001485 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001486 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001487 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001488 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001489 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001490 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001491 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001492 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001493 "type": "array",
1494 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001495 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001496 },
garciadeblas4568a372021-03-24 09:19:48 +01001497 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001498 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001499 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001500 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001501}
1502
garciadeblas4568a372021-03-24 09:19:48 +01001503nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001504
garciadeblas4568a372021-03-24 09:19:48 +01001505nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001506
preethika.p329b8182020-04-22 12:25:39 +05301507nsinstancesubscriptionfilter_schema = {
1508 "title": "instance identifier schema",
1509 "$schema": "http://json-schema.org/draft-07/schema#",
1510 "type": "object",
1511 "properties": {
1512 "nsdIds": {"type": "array"},
1513 "vnfdIds": {"type": "array"},
1514 "pnfdIds": {"type": "array"},
1515 "nsInstanceIds": {"type": "array"},
1516 "nsInstanceNames": {"type": "array"},
1517 },
1518}
1519
1520nslcmsub_schema = {
1521 "title": "nslcmsubscription input schema",
1522 "$schema": "http://json-schema.org/draft-07/schema#",
1523 "type": "object",
1524 "properties": {
1525 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1526 "notificationTypes": {
1527 "type": "array",
1528 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001529 "enum": [
1530 "NsLcmOperationOccurrenceNotification",
1531 "NsChangeNotification",
1532 "NsIdentifierCreationNotification",
1533 "NsIdentifierDeletionNotification",
1534 ]
1535 },
preethika.p329b8182020-04-22 12:25:39 +05301536 },
1537 "operationTypes": {
1538 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001539 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301540 },
1541 "operationStates": {
1542 "type": "array",
1543 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001544 "enum": [
1545 "PROCESSING",
1546 "COMPLETED",
1547 "PARTIALLY_COMPLETED",
1548 "FAILED",
1549 "FAILED_TEMP",
1550 "ROLLING_BACK",
1551 "ROLLED_BACK",
1552 ]
1553 },
preethika.p329b8182020-04-22 12:25:39 +05301554 },
garciadeblas4568a372021-03-24 09:19:48 +01001555 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301556 "lcmOpNameImpactingNsComponent": {
1557 "type": "array",
1558 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001559 "enum": [
1560 "VNF_INSTANTIATE",
1561 "VNF_SCALE",
1562 "VNF_SCALE_TO_LEVEL",
1563 "VNF_CHANGE_FLAVOUR",
1564 "VNF_TERMINATE",
1565 "VNF_HEAL",
1566 "VNF_OPERATE",
1567 "VNF_CHANGE_EXT_CONN",
1568 "VNF_MODIFY_INFO",
1569 "NS_INSTANTIATE",
1570 "NS_SCALE",
1571 "NS_UPDATE",
1572 "NS_TERMINATE",
1573 "NS_HEAL",
1574 ]
1575 },
preethika.p329b8182020-04-22 12:25:39 +05301576 },
1577 "lcmOpOccStatusImpactingNsComponent": {
1578 "type": "array",
1579 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001580 "enum": [
1581 "START",
1582 "COMPLETED",
1583 "PARTIALLY_COMPLETED",
1584 "FAILED",
1585 "ROLLED_BACK",
1586 ]
1587 },
preethika.p329b8182020-04-22 12:25:39 +05301588 },
1589 },
1590 "allOf": [
1591 {
1592 "if": {
1593 "properties": {
1594 "notificationTypes": {
1595 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1596 }
1597 },
1598 },
1599 "then": {
1600 "anyOf": [
1601 {"required": ["operationTypes"]},
1602 {"required": ["operationStates"]},
1603 ]
garciadeblas4568a372021-03-24 09:19:48 +01001604 },
preethika.p329b8182020-04-22 12:25:39 +05301605 },
1606 {
1607 "if": {
1608 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001609 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301610 },
1611 },
1612 "then": {
1613 "anyOf": [
1614 {"required": ["nsComponentTypes"]},
1615 {"required": ["lcmOpNameImpactingNsComponent"]},
1616 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1617 ]
garciadeblas4568a372021-03-24 09:19:48 +01001618 },
1619 },
1620 ],
preethika.p329b8182020-04-22 12:25:39 +05301621}
1622
1623authentication_schema = {
1624 "title": "authentication schema for subscription",
1625 "$schema": "http://json-schema.org/draft-07/schema#",
1626 "type": "object",
1627 "properties": {
1628 "authType": {"enum": ["basic"]},
1629 "paramsBasic": {
1630 "type": "object",
1631 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001632 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301633 "password": passwd_schema,
1634 },
1635 },
1636 },
1637}
1638
1639subscription = {
1640 "title": "subscription input schema",
1641 "$schema": "http://json-schema.org/draft-07/schema#",
1642 "type": "object",
1643 "properties": {
1644 "filter": nslcmsub_schema,
1645 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001646 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301647 },
1648 "required": ["CallbackUri"],
1649}
1650
selvi.jf1004592022-04-29 05:42:35 +00001651vnflcmsub_schema = {
1652 "title": "vnflcmsubscription input schema",
1653 "$schema": "http://json-schema.org/draft-07/schema#",
1654 "type": "object",
1655 "properties": {
1656 "VnfInstanceSubscriptionFilter": {
1657 "type": "object",
1658 "properties": {
1659 "vnfdIds": {"type": "array"},
1660 "vnfInstanceIds": {"type": "array"},
1661 },
1662 },
1663 "notificationTypes": {
1664 "type": "array",
1665 "items": {
1666 "enum": [
1667 "VnfIdentifierCreationNotification",
1668 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001669 "VnfIdentifierDeletionNotification",
1670 ]
1671 },
selvi.jf1004592022-04-29 05:42:35 +00001672 },
1673 "operationTypes": {
1674 "type": "array",
1675 "items": {
1676 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001677 "INSTANTIATE",
1678 "SCALE",
1679 "SCALE_TO_LEVEL",
1680 "CHANGE_FLAVOUR",
1681 "TERMINATE",
1682 "HEAL",
1683 "OPERATE",
1684 "CHANGE_EXT_CONN",
1685 "MODIFY_INFO",
1686 "CREATE_SNAPSHOT",
1687 "REVERT_TO_SNAPSHOT",
1688 "CHANGE_VNFPKG",
1689 ]
1690 },
selvi.jf1004592022-04-29 05:42:35 +00001691 },
1692 "operationStates": {
1693 "type": "array",
1694 "items": {
1695 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001696 "STARTING",
1697 "PROCESSING",
1698 "COMPLETED",
1699 "FAILED_TEMP",
1700 "FAILED",
1701 "ROLLING_BACK",
1702 "ROLLED_BACK",
1703 ]
1704 },
1705 },
selvi.jf1004592022-04-29 05:42:35 +00001706 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001707 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1708}
selvi.jf1004592022-04-29 05:42:35 +00001709
1710vnf_subscription = {
1711 "title": "vnf subscription input schema",
1712 "$schema": "http://json-schema.org/draft-07/schema#",
1713 "type": "object",
1714 "properties": {
1715 "filter": vnflcmsub_schema,
1716 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001717 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001718 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001719 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001720}
1721
yshah53cc9eb2024-07-05 13:06:31 +00001722oka_schema = {
1723 "title": "Create OKA package input schema",
1724 "$schema": "http://json-schema.org/draft-07/schema#",
1725 "type": "object",
1726 "properties": {
1727 "name": name_schema,
1728 "description": description_schema,
garciadeblas3fb820d2024-12-05 13:11:11 +01001729 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001730 },
1731 "additionalProperties": False,
1732}
1733
1734ksu_schema = {
1735 "title": "ksu schema",
1736 "$schema": "http://json-schema.org/draft-07/schema#",
1737 "type": "object",
1738 "properties": {
1739 "name": name_schema,
1740 "description": description_schema,
1741 "profile": {
1742 "type": "object",
1743 "properties": {
garciadeblas3fb820d2024-12-05 13:11:11 +01001744 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001745 "_id": id_schema,
1746 },
1747 "additionalProperties": False,
1748 },
1749 "oka": {
1750 "type": "array",
1751 "items": {
1752 "type": "object",
1753 "properties": {
1754 "_id": id_schema,
1755 "sw_catalog_path": string_schema,
1756 "transformation": object_schema,
1757 },
1758 "additionalProperties": False,
1759 },
1760 },
1761 },
1762 "additionalProperties": False,
1763}
1764
tierno0f98af52018-03-19 10:28:22 +01001765
1766class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001767 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1768 self.http_code = http_code
1769 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001770
1771
tiernob24258a2018-10-04 18:39:49 +02001772def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001773 """
tiernocd54a4a2018-09-12 16:40:35 +02001774 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001775 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001776 :param schema_to_use: jsonschema to test
1777 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001778 """
1779 try:
tierno0f98af52018-03-19 10:28:22 +01001780 if schema_to_use:
1781 js_v(indata, schema_to_use)
1782 return None
1783 except js_e.ValidationError as e:
1784 if e.path:
tierno0da52252018-06-27 15:47:22 +02001785 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001786 else:
1787 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001788 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001789 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001790 raise ValidationError(
1791 "Bad json schema {}".format(schema_to_use),
1792 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1793 )
delacruzramoc061f562019-04-05 11:00:02 +02001794
1795
1796def is_valid_uuid(x):
1797 """
1798 Test for a valid UUID
1799 :param x: string to test
1800 :return: True if x is a valid uuid, False otherwise
1801 """
1802 try:
1803 if UUID(x):
1804 return True
tiernobdebce92019-07-01 15:36:49 +00001805 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001806 return False