blob: 1a82a1a82767419249c2ea2b3f1a383152339a72 [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
garciadeblasf30e33d2025-09-15 15:42:15 +02001095cluster_creation_new_schema = {
rshri41b2db92025-06-11 11:17:42 +00001096 "$schema": "http://json-schema.org/draft-07/schema#",
rshri2d386cb2024-07-05 14:35:51 +00001097 "title": "cluster creation operation input schema",
rshri2d386cb2024-07-05 14:35:51 +00001098 "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,
rshri17b09ec2024-11-07 05:48:12 +00001108 "bootstrap": bool_schema,
rshri41b2db92025-06-11 11:17:42 +00001109 # "vim_type": string_schema,
1110 "private_subnet": { # Subnets validation
1111 "type": "array",
1112 "items": { # Each item in the array must be a string (subnet ID)
1113 "type": "string",
1114 "pattern": "^subnet-[a-f0-9]+$", # Optional: Add a regex pattern for basic subnet ID format
1115 },
1116 # "minItems": 2, # Minimum 2 subnets
1117 "uniqueItems": True, # Subnet IDs must be unique
1118 },
1119 "public_subnet": { # Subnets validation
1120 "type": "array",
1121 "items": { # Each item in the array must be a string (subnet ID)
1122 "type": "string",
1123 "pattern": "^subnet-[a-f0-9]+$", # Optional: Add a regex pattern for basic subnet ID format
1124 },
1125 # "minItems": 2, # Minimum 2 subnets
1126 "uniqueItems": True, # Subnet IDs must be unique
1127 },
yshahd23c6a52025-06-13 05:49:31 +00001128 "iam_role": {
1129 "type": "string",
1130 "pattern": "^arn:aws:iam::\\d{12}:role\\/[A-Za-z0-9]+$",
1131 },
garciadeblas9012c542026-01-13 12:15:24 +01001132 # additional cluster configuration parameters
1133 "config": object_schema,
rshri2d386cb2024-07-05 14:35:51 +00001134 },
rshri41b2db92025-06-11 11:17:42 +00001135 "required": ["vim_account", "name", "k8s_version"],
rshri2d386cb2024-07-05 14:35:51 +00001136 "additionalProperties": False,
1137}
rshri41b2db92025-06-11 11:17:42 +00001138
garciadeblasf30e33d2025-09-15 15:42:15 +02001139cluster_registration_new_schema = {
rshri17b09ec2024-11-07 05:48:12 +00001140 "title": "cluster registration input schema",
1141 "$schema": "http://json-schema.org/draft-04/schema#",
1142 "type": "object",
1143 "properties": {
1144 "schema_version": schema_version,
1145 "schema_type": schema_type,
1146 "name": name_schema,
1147 "description": description_schema,
1148 "credentials": object_schema,
1149 "vim_account": string_schema,
1150 "bootstrap": bool_schema,
garciadeblasf30e33d2025-09-15 15:42:15 +02001151 "openshift": bool_schema,
rshri17b09ec2024-11-07 05:48:12 +00001152 },
1153 "required": ["name", "credentials", "vim_account"],
1154 "additionalProperties": False,
1155}
rshri2d386cb2024-07-05 14:35:51 +00001156
yshah99122b82024-11-18 07:05:29 +00001157cluster_edit_schema = {
1158 "title": "cluster edit schema",
1159 "$schema": "http://json-schema.org/draft-04/schema#",
1160 "type": "object",
1161 "properties": {
1162 "name": name_schema,
1163 "description": string_schema,
1164 },
1165 "additionalProperties": False,
1166}
1167
1168cluster_update_schema = {
1169 "title": "cluster update schema",
1170 "$schema": "http://json-schema.org/draft-04/schema#",
1171 "type": "object",
1172 "properties": {
1173 "k8s_version": string_schema,
1174 "node_size": string_schema,
1175 "node_count": integer0_schema,
1176 },
1177 "additionalProperties": True,
1178}
1179
rshri2d386cb2024-07-05 14:35:51 +00001180infra_controller_profile_create_new_schema = {
1181 "title": "infra profile creation operation input schema",
1182 "$schema": "http://json-schema.org/draft-04/schema#",
1183 "type": "object",
1184 "properties": {
1185 "name": name_schema,
1186 "description": string_schema,
1187 },
1188 "additionalProperties": False,
1189}
1190
1191infra_controller_profile_create_edit_schema = {
1192 "title": "infra profile creation operation input schema",
1193 "$schema": "http://json-schema.org/draft-04/schema#",
1194 "type": "object",
1195 "properties": {
1196 "name": name_schema,
1197 "description": string_schema,
1198 },
1199 "additionalProperties": False,
1200}
1201
1202infra_config_profile_create_new_schema = {
1203 "title": "infra profile creation operation input schema",
1204 "$schema": "http://json-schema.org/draft-04/schema#",
1205 "type": "object",
1206 "properties": {
1207 "name": name_schema,
1208 "description": string_schema,
1209 },
1210 "additionalProperties": False,
1211}
1212
1213infra_config_profile_create_edit_schema = {
1214 "title": "infra profile creation operation input schema",
1215 "$schema": "http://json-schema.org/draft-04/schema#",
1216 "type": "object",
1217 "properties": {
1218 "name": name_schema,
1219 "description": string_schema,
1220 },
1221 "additionalProperties": False,
1222}
1223
1224app_profile_create_new_schema = {
1225 "title": "app profile creation operation input schema",
1226 "$schema": "http://json-schema.org/draft-04/schema#",
1227 "type": "object",
1228 "properties": {
1229 "name": name_schema,
1230 "description": string_schema,
1231 },
1232 "additionalProperties": False,
1233}
1234app_profile_create_edit_schema = {
1235 "title": "app profile creation operation input schema",
1236 "$schema": "http://json-schema.org/draft-04/schema#",
1237 "type": "object",
1238 "properties": {
1239 "name": name_schema,
1240 "description": string_schema,
1241 },
1242 "additionalProperties": False,
1243}
1244
1245resource_profile_create_new_schema = {
1246 "title": "resource profile creation operation input schema",
1247 "$schema": "http://json-schema.org/draft-04/schema#",
1248 "type": "object",
1249 "properties": {
1250 "name": name_schema,
1251 "description": string_schema,
1252 },
1253 "additionalProperties": False,
1254}
1255resource_profile_create_edit_schema = {
1256 "title": "resource profile creation operation input schema",
1257 "$schema": "http://json-schema.org/draft-04/schema#",
1258 "type": "object",
1259 "properties": {
1260 "name": name_schema,
1261 "description": string_schema,
1262 },
1263 "additionalProperties": False,
1264}
1265
1266attach_profile = {
1267 "type": "array",
1268 "items": {
1269 "type": "object",
1270 "properties": {"id": id_schema},
1271 "additionalProperties": False,
1272 },
1273}
1274remove_profile = {
1275 "type": "array",
1276 "items": {
1277 "type": "object",
1278 "properties": {"id": id_schema},
1279 "additionalProperties": False,
1280 },
1281}
1282attach_dettach_profile_schema = {
1283 "title": "attach/dettach profiles",
1284 "$schema": "http://json-schema.org/draft-04/schema#",
1285 "type": "object",
1286 "properties": {
1287 "add_profile": attach_profile,
1288 "remove_profile": remove_profile,
1289 },
1290 "additionalProperties": False,
1291}
yshahd23c6a52025-06-13 05:49:31 +00001292
1293node_create_new_schema = {
1294 "title": "node creation operation input schema",
1295 "$schema": "http://json-schema.org/draft-04/schema#",
1296 "type": "object",
1297 "properties": {
1298 "name": name_schema,
1299 "cluster_id": id_schema,
1300 "description": string_schema,
1301 "node_count": integer0_schema,
1302 "node_size": string_schema,
1303 "private_subnet": {
1304 "type": "array",
1305 "items": {
1306 "type": "string",
1307 "pattern": "^subnet-[a-f0-9]+$",
1308 },
1309 "uniqueItems": True,
1310 },
1311 "public_subnet": {
1312 "type": "array",
1313 "items": {
1314 "type": "string",
1315 "pattern": "^subnet-[a-f0-9]+$",
1316 },
1317 "uniqueItems": True,
1318 },
1319 "iam_role": {
1320 "type": "string",
1321 "pattern": "^arn:aws:iam::\\d{12}:role\\/[A-Za-z0-9]+$",
1322 },
1323 },
1324 "required": [
1325 "name",
1326 "cluster_id",
1327 "node_size",
1328 "node_count",
1329 ],
1330 "anyOf": [{"required": ["private_subnet"]}, {"required": ["public_subnet"]}],
1331 "additionalProperties": False,
1332}
1333
1334node_edit_schema = {
1335 "title": "node update operation input schema",
1336 "$schema": "http://json-schema.org/draft-04/schema#",
1337 "type": "object",
1338 "properties": {
1339 "name": name_schema,
1340 "cluster_id": id_schema,
1341 "description": string_schema,
1342 "node_count": integer0_schema,
1343 },
1344 "additionalProperties": False,
1345}
1346
tiernocb83c942018-09-24 17:28:13 +02001347# USERS
tiernocf042d32019-06-13 09:06:40 +00001348project_role_mappings = {
1349 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001350 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001351 "type": "array",
1352 "items": {
1353 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001354 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001355 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001356 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001357 },
garciadeblas4568a372021-03-24 09:19:48 +01001358 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001359}
rshri2d386cb2024-07-05 14:35:51 +00001360
tiernocf042d32019-06-13 09:06:40 +00001361project_role_mappings_optional = {
1362 "title": "list of projects/roles or projects only",
1363 "$schema": "http://json-schema.org/draft-04/schema#",
1364 "type": "array",
1365 "items": {
1366 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001367 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001368 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001369 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001370 },
garciadeblas4568a372021-03-24 09:19:48 +01001371 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001372}
rshri2d386cb2024-07-05 14:35:51 +00001373
tiernocd54a4a2018-09-12 16:40:35 +02001374user_new_schema = {
1375 "$schema": "http://json-schema.org/draft-04/schema#",
1376 "title": "New user schema",
1377 "type": "object",
1378 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001379 "username": string_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001380 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001381 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001382 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001383 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001384 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001385 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001386 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001387 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001388}
1389user_edit_schema = {
1390 "$schema": "http://json-schema.org/draft-04/schema#",
1391 "title": "User edit schema for administrators",
1392 "type": "object",
1393 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001394 "password": user_passwd_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001395 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001396 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001397 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001398 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001399 "project_role_mappings": project_role_mappings,
1400 "add_project_role_mappings": project_role_mappings,
1401 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001402 "system_admin_id": id_schema,
1403 "unlock": bool_schema,
1404 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001405 },
1406 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001407 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001408}
1409
1410# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001411topics_with_quota = [
1412 "vnfds",
1413 "nsds",
1414 "slice_templates",
1415 "pduds",
1416 "ns_instances",
1417 "slice_instances",
1418 "vim_accounts",
1419 "wim_accounts",
1420 "sdn_controllers",
1421 "k8sclusters",
1422 "vca",
1423 "k8srepos",
1424 "osmrepos",
1425 "ns_subscriptions",
1426]
tiernocd54a4a2018-09-12 16:40:35 +02001427project_new_schema = {
1428 "$schema": "http://json-schema.org/draft-04/schema#",
1429 "title": "New project schema for administrators",
1430 "type": "object",
1431 "properties": {
tiernofd160572019-01-21 10:41:37 +00001432 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001433 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001434 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001435 "quotas": {
1436 "type": "object",
1437 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001438 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001439 },
tiernocd54a4a2018-09-12 16:40:35 +02001440 },
1441 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001442 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001443}
1444project_edit_schema = {
1445 "$schema": "http://json-schema.org/draft-04/schema#",
1446 "title": "Project edit schema for administrators",
1447 "type": "object",
1448 "properties": {
1449 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001450 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001451 "quotas": {
1452 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001453 "properties": {
1454 topic: {"oneOf": [integer0_schema, null_schema]}
1455 for topic in topics_with_quota
1456 },
1457 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001458 },
tiernocd54a4a2018-09-12 16:40:35 +02001459 },
1460 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001461 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001462}
1463
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001464# ROLES
1465roles_new_schema = {
1466 "$schema": "http://json-schema.org/draft-04/schema#",
1467 "title": "New role schema for administrators",
1468 "type": "object",
1469 "properties": {
1470 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001471 "permissions": {
1472 "type": "object",
1473 "patternProperties": {
1474 ".": bool_schema,
1475 },
1476 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001477 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001478 },
tierno1f029d82019-06-13 22:37:04 +00001479 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001480 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001481}
1482roles_edit_schema = {
1483 "$schema": "http://json-schema.org/draft-04/schema#",
1484 "title": "Roles edit schema for administrators",
1485 "type": "object",
1486 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001487 "name": shortname_schema,
1488 "permissions": {
1489 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001490 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001491 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001492 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001493 },
tierno1f029d82019-06-13 22:37:04 +00001494 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001495 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001496}
1497
tiernocd54a4a2018-09-12 16:40:35 +02001498# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001499
1500nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001501 "users": user_new_schema,
1502 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001503 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001504 "sdns": sdn_new_schema,
1505 "ns_instantiate": ns_instantiate,
1506 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001507 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001508 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001509 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001510 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001511}
1512
1513nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001514 "users": user_edit_schema,
1515 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001516 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001517 "sdns": sdn_edit_schema,
1518 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301519 "vnf": vnf_schema,
1520 "vld": vld_schema,
1521 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001522}
1523
Felipe Vicens07f31722018-10-29 15:16:44 +01001524# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001525nsi_subnet_instantiate = deepcopy(ns_instantiate)
1526nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1527nsi_subnet_instantiate["properties"]["id"] = name_schema
1528del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001529
1530nsi_vld_instantiate = {
1531 "title": "netslice vld instantiation params input schema",
1532 "$schema": "http://json-schema.org/draft-04/schema#",
1533 "type": "object",
1534 "properties": {
1535 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001536 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1537 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001538 "ip-profile": object_schema,
1539 },
delacruzramoc061f562019-04-05 11:00:02 +02001540 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001541 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001542}
1543
Felipe Vicens07f31722018-10-29 15:16:44 +01001544nsi_instantiate = {
1545 "title": "netslice action instantiate input schema",
1546 "$schema": "http://json-schema.org/draft-04/schema#",
1547 "type": "object",
1548 "properties": {
1549 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001550 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001551 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001552 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001553 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001554 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001555 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001556 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001557 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001558 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001559 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001560 "type": "array",
1561 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001562 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001563 },
garciadeblas4568a372021-03-24 09:19:48 +01001564 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001565 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001566 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001567 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001568}
1569
garciadeblas4568a372021-03-24 09:19:48 +01001570nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001571
garciadeblas4568a372021-03-24 09:19:48 +01001572nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001573
preethika.p329b8182020-04-22 12:25:39 +05301574nsinstancesubscriptionfilter_schema = {
1575 "title": "instance identifier schema",
1576 "$schema": "http://json-schema.org/draft-07/schema#",
1577 "type": "object",
1578 "properties": {
1579 "nsdIds": {"type": "array"},
1580 "vnfdIds": {"type": "array"},
1581 "pnfdIds": {"type": "array"},
1582 "nsInstanceIds": {"type": "array"},
1583 "nsInstanceNames": {"type": "array"},
1584 },
1585}
1586
1587nslcmsub_schema = {
1588 "title": "nslcmsubscription input schema",
1589 "$schema": "http://json-schema.org/draft-07/schema#",
1590 "type": "object",
1591 "properties": {
1592 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1593 "notificationTypes": {
1594 "type": "array",
1595 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001596 "enum": [
1597 "NsLcmOperationOccurrenceNotification",
1598 "NsChangeNotification",
1599 "NsIdentifierCreationNotification",
1600 "NsIdentifierDeletionNotification",
1601 ]
1602 },
preethika.p329b8182020-04-22 12:25:39 +05301603 },
1604 "operationTypes": {
1605 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001606 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301607 },
1608 "operationStates": {
1609 "type": "array",
1610 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001611 "enum": [
1612 "PROCESSING",
1613 "COMPLETED",
1614 "PARTIALLY_COMPLETED",
1615 "FAILED",
1616 "FAILED_TEMP",
1617 "ROLLING_BACK",
1618 "ROLLED_BACK",
1619 ]
1620 },
preethika.p329b8182020-04-22 12:25:39 +05301621 },
garciadeblas4568a372021-03-24 09:19:48 +01001622 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301623 "lcmOpNameImpactingNsComponent": {
1624 "type": "array",
1625 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001626 "enum": [
1627 "VNF_INSTANTIATE",
1628 "VNF_SCALE",
1629 "VNF_SCALE_TO_LEVEL",
1630 "VNF_CHANGE_FLAVOUR",
1631 "VNF_TERMINATE",
1632 "VNF_HEAL",
1633 "VNF_OPERATE",
1634 "VNF_CHANGE_EXT_CONN",
1635 "VNF_MODIFY_INFO",
1636 "NS_INSTANTIATE",
1637 "NS_SCALE",
1638 "NS_UPDATE",
1639 "NS_TERMINATE",
1640 "NS_HEAL",
1641 ]
1642 },
preethika.p329b8182020-04-22 12:25:39 +05301643 },
1644 "lcmOpOccStatusImpactingNsComponent": {
1645 "type": "array",
1646 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001647 "enum": [
1648 "START",
1649 "COMPLETED",
1650 "PARTIALLY_COMPLETED",
1651 "FAILED",
1652 "ROLLED_BACK",
1653 ]
1654 },
preethika.p329b8182020-04-22 12:25:39 +05301655 },
1656 },
1657 "allOf": [
1658 {
1659 "if": {
1660 "properties": {
1661 "notificationTypes": {
1662 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1663 }
1664 },
1665 },
1666 "then": {
1667 "anyOf": [
1668 {"required": ["operationTypes"]},
1669 {"required": ["operationStates"]},
1670 ]
garciadeblas4568a372021-03-24 09:19:48 +01001671 },
preethika.p329b8182020-04-22 12:25:39 +05301672 },
1673 {
1674 "if": {
1675 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001676 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301677 },
1678 },
1679 "then": {
1680 "anyOf": [
1681 {"required": ["nsComponentTypes"]},
1682 {"required": ["lcmOpNameImpactingNsComponent"]},
1683 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1684 ]
garciadeblas4568a372021-03-24 09:19:48 +01001685 },
1686 },
1687 ],
preethika.p329b8182020-04-22 12:25:39 +05301688}
1689
1690authentication_schema = {
1691 "title": "authentication schema for subscription",
1692 "$schema": "http://json-schema.org/draft-07/schema#",
1693 "type": "object",
1694 "properties": {
1695 "authType": {"enum": ["basic"]},
1696 "paramsBasic": {
1697 "type": "object",
1698 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001699 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301700 "password": passwd_schema,
1701 },
1702 },
1703 },
1704}
1705
1706subscription = {
1707 "title": "subscription input schema",
1708 "$schema": "http://json-schema.org/draft-07/schema#",
1709 "type": "object",
1710 "properties": {
1711 "filter": nslcmsub_schema,
1712 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001713 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301714 },
1715 "required": ["CallbackUri"],
1716}
1717
selvi.jf1004592022-04-29 05:42:35 +00001718vnflcmsub_schema = {
1719 "title": "vnflcmsubscription input schema",
1720 "$schema": "http://json-schema.org/draft-07/schema#",
1721 "type": "object",
1722 "properties": {
1723 "VnfInstanceSubscriptionFilter": {
1724 "type": "object",
1725 "properties": {
1726 "vnfdIds": {"type": "array"},
1727 "vnfInstanceIds": {"type": "array"},
1728 },
1729 },
1730 "notificationTypes": {
1731 "type": "array",
1732 "items": {
1733 "enum": [
1734 "VnfIdentifierCreationNotification",
1735 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001736 "VnfIdentifierDeletionNotification",
1737 ]
1738 },
selvi.jf1004592022-04-29 05:42:35 +00001739 },
1740 "operationTypes": {
1741 "type": "array",
1742 "items": {
1743 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001744 "INSTANTIATE",
1745 "SCALE",
1746 "SCALE_TO_LEVEL",
1747 "CHANGE_FLAVOUR",
1748 "TERMINATE",
1749 "HEAL",
1750 "OPERATE",
1751 "CHANGE_EXT_CONN",
1752 "MODIFY_INFO",
1753 "CREATE_SNAPSHOT",
1754 "REVERT_TO_SNAPSHOT",
1755 "CHANGE_VNFPKG",
1756 ]
1757 },
selvi.jf1004592022-04-29 05:42:35 +00001758 },
1759 "operationStates": {
1760 "type": "array",
1761 "items": {
1762 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001763 "STARTING",
1764 "PROCESSING",
1765 "COMPLETED",
1766 "FAILED_TEMP",
1767 "FAILED",
1768 "ROLLING_BACK",
1769 "ROLLED_BACK",
1770 ]
1771 },
1772 },
selvi.jf1004592022-04-29 05:42:35 +00001773 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001774 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1775}
selvi.jf1004592022-04-29 05:42:35 +00001776
1777vnf_subscription = {
1778 "title": "vnf subscription input schema",
1779 "$schema": "http://json-schema.org/draft-07/schema#",
1780 "type": "object",
1781 "properties": {
1782 "filter": vnflcmsub_schema,
1783 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001784 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001785 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001786 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001787}
1788
yshah53cc9eb2024-07-05 13:06:31 +00001789oka_schema = {
1790 "title": "Create OKA package input schema",
1791 "$schema": "http://json-schema.org/draft-07/schema#",
1792 "type": "object",
1793 "properties": {
1794 "name": name_schema,
1795 "description": description_schema,
garciadeblas3fb820d2024-12-05 13:11:11 +01001796 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001797 },
1798 "additionalProperties": False,
1799}
1800
1801ksu_schema = {
1802 "title": "ksu schema",
1803 "$schema": "http://json-schema.org/draft-07/schema#",
1804 "type": "object",
1805 "properties": {
1806 "name": name_schema,
1807 "description": description_schema,
1808 "profile": {
1809 "type": "object",
1810 "properties": {
garciadeblas3fb820d2024-12-05 13:11:11 +01001811 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001812 "_id": id_schema,
1813 },
1814 "additionalProperties": False,
1815 },
1816 "oka": {
1817 "type": "array",
1818 "items": {
1819 "type": "object",
1820 "properties": {
1821 "_id": id_schema,
1822 "sw_catalog_path": string_schema,
1823 "transformation": object_schema,
1824 },
1825 "additionalProperties": False,
1826 },
1827 },
1828 },
1829 "additionalProperties": False,
1830}
1831
tierno0f98af52018-03-19 10:28:22 +01001832
garciadeblasb798f452025-08-05 18:21:26 +02001833app_instance_schema = {
1834 "title": "app instance schema",
1835 "$schema": "http://json-schema.org/draft-07/schema#",
1836 "type": "object",
1837 "properties": {
1838 "name": name_schema,
1839 "description": description_schema,
1840 "profile": id_schema,
1841 "profile_type": profile_type_schema,
1842 "oka": id_schema,
1843 "sw_catalog_path": string_schema,
1844 "model": object_schema,
1845 "params": object_schema,
1846 "secret_params": object_schema,
1847 },
1848 "additionalProperties": False,
1849 "required": ["name", "profile", "profile_type"],
1850}
1851
garciadeblased401462026-01-16 02:51:15 +01001852app_instance_edit_schema = {
1853 "title": "app instance edit schema",
1854 "$schema": "http://json-schema.org/draft-04/schema#",
1855 "type": "object",
1856 "properties": {
1857 "name": name_schema,
1858 "description": string_schema,
1859 },
1860 "additionalProperties": False,
1861}
1862
1863app_instance_update_schema = {
1864 "title": "app instance update schema",
1865 "$schema": "http://json-schema.org/draft-04/schema#",
1866 "type": "object",
1867 "properties": {
1868 "model": object_schema,
1869 "params": object_schema,
1870 "secret_params": object_schema,
1871 },
1872 "additionalProperties": True,
1873}
1874
garciadeblasb798f452025-08-05 18:21:26 +02001875
tierno0f98af52018-03-19 10:28:22 +01001876class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001877 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1878 self.http_code = http_code
1879 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001880
1881
tiernob24258a2018-10-04 18:39:49 +02001882def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001883 """
tiernocd54a4a2018-09-12 16:40:35 +02001884 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001885 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001886 :param schema_to_use: jsonschema to test
1887 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001888 """
1889 try:
tierno0f98af52018-03-19 10:28:22 +01001890 if schema_to_use:
1891 js_v(indata, schema_to_use)
1892 return None
1893 except js_e.ValidationError as e:
1894 if e.path:
tierno0da52252018-06-27 15:47:22 +02001895 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001896 else:
1897 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001898 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001899 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001900 raise ValidationError(
1901 "Bad json schema {}".format(schema_to_use),
1902 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1903 )
delacruzramoc061f562019-04-05 11:00:02 +02001904
1905
1906def is_valid_uuid(x):
1907 """
1908 Test for a valid UUID
1909 :param x: string to test
1910 :return: True if x is a valid uuid, False otherwise
1911 """
1912 try:
1913 if UUID(x):
1914 return True
tiernobdebce92019-07-01 15:36:49 +00001915 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001916 return False