blob: e27cfb09b71b6db0b5fa6e12970c6c42906070fe [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,
tierno441dbbf2018-07-10 12:52:48 +0200162 "volume": {
163 "type": "array",
164 "minItems": 1,
165 "items": {
166 "type": "object",
167 "properties": {
168 "name": name_schema,
169 "vim-volume-id": name_schema,
170 },
171 "required": ["name", "vim-volume-id"],
garciadeblas4568a372021-03-24 09:19:48 +0100172 "additionalProperties": False,
173 },
tierno441dbbf2018-07-10 12:52:48 +0200174 },
175 "interface": {
176 "type": "array",
177 "minItems": 1,
178 "items": {
179 "type": "object",
180 "properties": {
181 "name": name_schema,
garciadeblas9fb32712022-04-04 16:33:59 +0200182 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200183 "mac-address": mac_schema,
184 "floating-ip-required": bool_schema,
185 },
186 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +0100187 "additionalProperties": False,
188 },
189 },
tierno441dbbf2018-07-10 12:52:48 +0200190 },
191 "required": ["id"],
garciadeblas4568a372021-03-24 09:19:48 +0100192 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200193}
194
195ip_profile_dns_schema = {
196 "type": "array",
197 "minItems": 1,
198 "items": {
199 "type": "object",
200 "properties": {
garciadeblas9fb32712022-04-04 16:33:59 +0200201 "address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200202 },
203 "required": ["address"],
garciadeblas4568a372021-03-24 09:19:48 +0100204 "additionalProperties": False,
205 },
tierno441dbbf2018-07-10 12:52:48 +0200206}
207
208ip_profile_dhcp_schema = {
209 "type": "object",
210 "properties": {
211 "enabled": {"type": "boolean"},
212 "count": integer1_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100213 "start-address": ip_schema,
tierno441dbbf2018-07-10 12:52:48 +0200214 },
215 "additionalProperties": False,
216}
217
218ip_profile_schema = {
tierno2a929042020-03-10 16:34:25 +0000219 "title": "ip profile validation schema",
tierno441dbbf2018-07-10 12:52:48 +0200220 "$schema": "http://json-schema.org/draft-04/schema#",
221 "type": "object",
222 "properties": {
223 "ip-version": {"enum": ["ipv4", "ipv6"]},
tierno441dbbf2018-07-10 12:52:48 +0200224 "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]},
225 "gateway-address": {"oneOf": [null_schema, ip_schema]},
226 "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200227 "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]},
228 },
garciadeblas4568a372021-03-24 09:19:48 +0100229 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200230}
231
kbsub21f03f52019-10-17 16:26:56 +0000232provider_network_schema = {
tierno2a929042020-03-10 16:34:25 +0000233 "title": "provider network validation schema",
kbsub21f03f52019-10-17 16:26:56 +0000234 "$schema": "http://json-schema.org/draft-04/schema#",
235 "type": "object",
236 "properties": {
237 "physical-network": name_schema,
238 "segmentation-id": name_schema,
tierno2a929042020-03-10 16:34:25 +0000239 "sdn-ports": { # external ports to append to the SDN-assist network
240 "type": "array",
241 "items": {
242 "type": "object",
243 "properties": {
244 "switch_id": shortname_schema,
245 "switch_port": shortname_schema,
246 "mac_address": mac_schema,
247 "vlan": vlan_schema,
248 },
garciadeblas4568a372021-03-24 09:19:48 +0100249 "additionalProperties": True,
250 },
tierno2a929042020-03-10 16:34:25 +0000251 },
252 "network-type": shortname_schema,
kbsub21f03f52019-10-17 16:26:56 +0000253 },
garciadeblas4568a372021-03-24 09:19:48 +0100254 "additionalProperties": True,
kbsub21f03f52019-10-17 16:26:56 +0000255}
256
tierno441dbbf2018-07-10 12:52:48 +0200257ns_instantiate_internal_vld = {
garciadeblas9fb32712022-04-04 16:33:59 +0200258 "title": "ns action instantiate input schema for vld",
tierno441dbbf2018-07-10 12:52:48 +0200259 "$schema": "http://json-schema.org/draft-04/schema#",
260 "type": "object",
261 "properties": {
262 "name": name_schema,
263 "vim-network-name": name_schema,
gcalvino17d5b732018-12-17 16:26:21 +0100264 "vim-network-id": name_schema,
garciadeblas120105b2023-02-22 16:52:24 +0100265 "ip-profile": ip_profile_schema,
kbsub21f03f52019-10-17 16:26:56 +0000266 "provider-network": provider_network_schema,
tierno441dbbf2018-07-10 12:52:48 +0200267 "internal-connection-point": {
268 "type": "array",
269 "minItems": 1,
270 "items": {
271 "type": "object",
272 "properties": {
273 "id-ref": name_schema,
274 "ip-address": ip_schema,
tiernob7c6f2a2018-09-03 14:32:10 +0200275 # "mac-address": mac_schema,
tierno441dbbf2018-07-10 12:52:48 +0200276 },
tiernob7c6f2a2018-09-03 14:32:10 +0200277 "required": ["id-ref"],
278 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100279 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200280 },
garciadeblas4568a372021-03-24 09:19:48 +0100281 },
tierno441dbbf2018-07-10 12:52:48 +0200282 },
283 "required": ["name"],
284 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100285 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200286}
tierno65acb4d2018-04-06 16:42:40 +0200287
tiernofd160572019-01-21 10:41:37 +0000288additional_params_for_vnf = {
289 "type": "array",
290 "items": {
291 "type": "object",
292 "properties": {
293 "member-vnf-index": name_schema,
294 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000295 "k8s-namespace": name_schema,
tiernof62ac6a2020-04-29 13:46:13 +0000296 "config-units": integer1_schema, # number of configuration units of this vnf, by default 1
tierno714954e2019-11-29 13:43:26 +0000297 "additionalParamsForVdu": {
298 "type": "array",
299 "items": {
300 "type": "object",
301 "properties": {
302 "vdu_id": name_schema,
303 "additionalParams": object_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100304 "config-units": integer1_schema, # number of configuration units of this vdu, by default 1
tierno714954e2019-11-29 13:43:26 +0000305 },
tiernof62ac6a2020-04-29 13:46:13 +0000306 "required": ["vdu_id"],
307 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000308 "additionalProperties": False,
309 },
310 },
311 "additionalParamsForKdu": {
312 "type": "array",
313 "items": {
314 "type": "object",
315 "properties": {
316 "kdu_name": name_schema,
317 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000318 "kdu_model": name_schema,
319 "k8s-namespace": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100320 "config-units": integer1_schema, # number of configuration units of this knf, by default 1
romeromonserbfebfc02021-05-28 10:51:35 +0200321 "kdu-deployment-name": name_schema,
tierno714954e2019-11-29 13:43:26 +0000322 },
tierno54db2e42020-04-06 15:29:42 +0000323 "required": ["kdu_name"],
324 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000325 "additionalProperties": False,
326 },
327 },
Alexis Romeroee31f532022-04-26 19:10:21 +0200328 "affinity-or-anti-affinity-group": {
329 "type": "array",
330 "items": {
331 "type": "object",
332 "properties": {
333 "id": name_schema,
334 "vim-affinity-group-id": name_schema,
335 },
336 "required": ["id"],
337 "minProperties": 2,
338 "additionalProperties": False,
339 },
340 },
tiernofd160572019-01-21 10:41:37 +0000341 },
tierno714954e2019-11-29 13:43:26 +0000342 "required": ["member-vnf-index"],
343 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100344 "additionalProperties": False,
345 },
tiernofd160572019-01-21 10:41:37 +0000346}
347
kayal2001f71c2e82024-06-25 15:26:24 +0530348vnf_schema = {
349 "type": "array",
350 "minItems": 1,
351 "items": {
352 "type": "object",
353 "properties": {
354 "member-vnf-index": name_schema,
355 "vimAccountId": id_schema,
356 "vdu": {
357 "type": "array",
358 "minItems": 1,
359 "items": ns_instantiate_vdu,
360 },
361 "internal-vld": {
362 "type": "array",
363 "minItems": 1,
364 "items": ns_instantiate_internal_vld,
365 },
366 },
367 "required": ["member-vnf-index"],
368 "minProperties": 2,
369 "additionalProperties": False,
370 },
371}
372
373vld_schema = {
374 "type": "array",
375 "minItems": 1,
376 "items": {
377 "type": "object",
378 "properties": {
379 "name": string_schema,
380 "vim-network-name": {"oneOf": [string_schema, object_schema]},
381 "vim-network-id": {"oneOf": [string_schema, object_schema]},
382 "ns-net": object_schema,
383 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
384 "ip-profile": ip_profile_schema,
385 "provider-network": provider_network_schema,
386 "vnfd-connection-point-ref": {
387 "type": "array",
388 "minItems": 1,
389 "items": {
390 "type": "object",
391 "properties": {
392 "member-vnf-index-ref": name_schema,
393 "vnfd-connection-point-ref": name_schema,
394 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
395 # "mac-address": mac_schema,
396 },
397 "required": [
398 "member-vnf-index-ref",
399 "vnfd-connection-point-ref",
400 ],
401 "minProperties": 3,
402 "additionalProperties": False,
403 },
404 },
405 },
406 "required": ["name"],
407 "additionalProperties": False,
408 },
409}
410
411ns_config_template = {
412 "title": " ns config template input schema",
413 "$schema": "http://json-schema.org/draft-04/schema#",
414 "type": "object",
415 "properties": {
416 "name": string_schema,
417 "nsdId": id_schema,
418 "config": object_schema,
419 },
420 "required": ["name", "nsdId", "config"],
421 "additionalProperties": False,
422}
423
tierno65acb4d2018-04-06 16:42:40 +0200424ns_instantiate = {
425 "title": "ns action instantiate input schema",
426 "$schema": "http://json-schema.org/draft-04/schema#",
427 "type": "object",
tierno0da52252018-06-27 15:47:22 +0200428 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200429 "lcmOperationType": string_schema,
430 "nsInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +0100431 "netsliceInstanceId": id_schema,
tierno0da52252018-06-27 15:47:22 +0200432 "nsName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +0000433 "nsDescription": {"oneOf": [description_schema, null_schema]},
tierno0da52252018-06-27 15:47:22 +0200434 "nsdId": id_schema,
435 "vimAccountId": id_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530436 "nsConfigTemplateId": id_schema,
tierno195a36c2020-09-18 14:18:55 +0000437 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
magnussonlf318b302020-01-20 18:38:18 +0100438 "placement-engine": string_schema,
439 "placement-constraints": object_schema,
tiernobee085c2018-12-12 17:03:04 +0000440 "additionalParamsForNs": object_schema,
tiernofd160572019-01-21 10:41:37 +0000441 "additionalParamsForVnf": additional_params_for_vnf,
garciadeblas4568a372021-03-24 09:19:48 +0100442 "config-units": integer1_schema, # number of configuration units of this ns, by default 1
tierno54db2e42020-04-06 15:29:42 +0000443 "k8s-namespace": name_schema,
tiernofc5089c2018-10-31 09:28:11 +0100444 "ssh_keys": {"type": "array", "items": {"type": "string"}},
tiernoa8186a52020-01-14 15:54:48 +0000445 "timeout_ns_deploy": integer1_schema,
tierno441dbbf2018-07-10 12:52:48 +0200446 "nsr_id": id_schema,
tiernocc103432018-10-19 14:10:35 +0200447 "vduImage": name_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530448 "vnf": vnf_schema,
449 "vld": vld_schema,
tierno0da52252018-06-27 15:47:22 +0200450 },
tierno441dbbf2018-07-10 12:52:48 +0200451 "required": ["nsName", "nsdId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +0100452 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200453}
tierno0da52252018-06-27 15:47:22 +0200454
tierno1c38f2f2020-03-24 11:51:39 +0000455ns_terminate = {
456 "title": "ns terminate input schema",
457 "$schema": "http://json-schema.org/draft-04/schema#",
458 "type": "object",
459 "properties": {
460 "lcmOperationType": string_schema,
461 "nsInstanceId": id_schema,
462 "autoremove": bool_schema,
463 "timeout_ns_terminate": integer1_schema,
464 "skip_terminate_primitives": bool_schema,
tierno0b8752f2020-05-12 09:42:02 +0000465 "netsliceInstanceId": id_schema,
tierno1c38f2f2020-03-24 11:51:39 +0000466 },
garciadeblas4568a372021-03-24 09:19:48 +0100467 "additionalProperties": False,
tierno1c38f2f2020-03-24 11:51:39 +0000468}
469
aticig544a2ae2022-04-05 09:00:17 +0300470ns_update = {
471 "title": "ns update input schema",
472 "$schema": "http://json-schema.org/draft-04/schema#",
473 "type": "object",
474 "properties": {
475 "lcmOperationType": string_schema,
476 "nsInstanceId": id_schema,
garciadeblaseab15072022-05-19 10:31:52 +0200477 "timeout_ns_update": integer1_schema,
aticig544a2ae2022-04-05 09:00:17 +0300478 "updateType": {
garciadeblasf2af4a12023-01-24 16:56:54 +0100479 "enum": [
480 "CHANGE_VNFPKG",
481 "REMOVE_VNF",
482 "MODIFY_VNF_INFORMATION",
483 "OPERATE_VNF",
Rahul Kumara30391b2024-05-24 14:40:23 +0530484 "VERTICAL_SCALE",
garciadeblasf2af4a12023-01-24 16:56:54 +0100485 ]
aticig544a2ae2022-04-05 09:00:17 +0300486 },
487 "modifyVnfInfoData": {
488 "type": "object",
489 "properties": {
490 "vnfInstanceId": id_schema,
491 "vnfdId": id_schema,
492 },
493 "required": ["vnfInstanceId", "vnfdId"],
494 },
495 "removeVnfInstanceId": id_schema,
496 "changeVnfPackageData": {
497 "type": "object",
498 "properties": {
499 "vnfInstanceId": id_schema,
500 "vnfdId": id_schema,
501 },
502 "required": ["vnfInstanceId", "vnfdId"],
503 },
k4.rahule3dca382022-04-29 12:30:36 +0000504 "operateVnfData": {
505 "type": "object",
506 "properties": {
507 "vnfInstanceId": id_schema,
508 "changeStateTo": name_schema,
509 "additionalParam": {
510 "type": "object",
511 "properties": {
512 "run-day1": bool_schema,
513 "vdu_id": name_schema,
514 "count-index": integer0_schema,
515 },
516 "required": ["vdu_id", "count-index"],
517 "additionalProperties": False,
garciadeblasf2af4a12023-01-24 16:56:54 +0100518 },
k4.rahule3dca382022-04-29 12:30:36 +0000519 },
520 "required": ["vnfInstanceId", "changeStateTo"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100521 },
Rahul Kumara30391b2024-05-24 14:40:23 +0530522 "verticalScaleVnf": {
523 "type": "object",
524 "properties": {
525 "vnfInstanceId": id_schema,
526 "vnfdId": id_schema,
527 "vduId": name_schema,
528 "countIndex": integer0_schema,
529 },
530 "required": ["vnfInstanceId", "vnfdId", "vduId"],
531 },
aticig544a2ae2022-04-05 09:00:17 +0300532 },
533 "required": ["updateType"],
534 "additionalProperties": False,
535}
536
garciadeblas4568a372021-03-24 09:19:48 +0100537ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
tiernof759d822018-06-11 18:54:54 +0200538 "title": "ns action input schema",
tierno65acb4d2018-04-06 16:42:40 +0200539 "$schema": "http://json-schema.org/draft-04/schema#",
540 "type": "object",
541 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200542 "lcmOperationType": string_schema,
543 "nsInstanceId": id_schema,
tiernof5298be2018-05-16 14:43:57 +0200544 "member_vnf_index": name_schema,
545 "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future
tierno7ce1db92018-07-25 12:50:52 +0200546 "vdu_id": name_schema,
tiernof0637052019-03-07 16:26:47 +0000547 "vdu_count_index": integer0_schema,
tierno9cb7d672019-10-30 12:13:48 +0000548 "kdu_name": name_schema,
tierno65acb4d2018-04-06 16:42:40 +0200549 "primitive": name_schema,
tierno50c8e6e2020-04-02 15:40:12 +0000550 "timeout_ns_action": integer1_schema,
tierno65acb4d2018-04-06 16:42:40 +0200551 "primitive_params": {"type": "object"},
552 },
garciadeblas4568a372021-03-24 09:19:48 +0100553 "required": ["primitive", "primitive_params"], # TODO add member_vnf_index
554 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200555}
garciadeblas0964edf2022-02-11 00:43:44 +0100556
garciadeblas4568a372021-03-24 09:19:48 +0100557ns_scale = { # TODO for the moment it is only VDU-scaling
tiernof759d822018-06-11 18:54:54 +0200558 "title": "ns scale input schema",
559 "$schema": "http://json-schema.org/draft-04/schema#",
560 "type": "object",
561 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200562 "lcmOperationType": string_schema,
563 "nsInstanceId": id_schema,
tiernof759d822018-06-11 18:54:54 +0200564 "scaleType": {"enum": ["SCALE_VNF"]},
tierno50c8e6e2020-04-02 15:40:12 +0000565 "timeout_ns_scale": integer1_schema,
tiernof759d822018-06-11 18:54:54 +0200566 "scaleVnfData": {
567 "type": "object",
568 "properties": {
569 "vnfInstanceId": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100570 "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]},
tiernof759d822018-06-11 18:54:54 +0200571 "scaleByStepData": {
572 "type": "object",
573 "properties": {
574 "scaling-group-descriptor": name_schema,
575 "member-vnf-index": name_schema,
576 "scaling-policy": name_schema,
577 },
578 "required": ["scaling-group-descriptor", "member-vnf-index"],
garciadeblas4568a372021-03-24 09:19:48 +0100579 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200580 },
581 },
582 "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId
garciadeblas4568a372021-03-24 09:19:48 +0100583 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200584 },
585 "scaleTime": time_schema,
586 },
587 "required": ["scaleType", "scaleVnfData"],
garciadeblas4568a372021-03-24 09:19:48 +0100588 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200589}
tierno65acb4d2018-04-06 16:42:40 +0200590
elumalai8e3806c2022-04-28 17:26:24 +0530591ns_migrate = {
592 "title": "ns migrate input schema",
593 "$schema": "http://json-schema.org/draft-04/schema#",
594 "type": "object",
595 "properties": {
596 "lcmOperationType": string_schema,
597 "nsInstanceId": id_schema,
598 "vnfInstanceId": id_schema,
599 "migrateToHost": string_schema,
600 "vdu": {
601 "type": "object",
garciadeblasf2af4a12023-01-24 16:56:54 +0100602 "properties": {
603 "vduId": name_schema,
604 "vduCountIndex": integer0_schema,
605 },
606 "required": ["vduId"],
607 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530608 },
609 },
610 "required": ["vnfInstanceId"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100611 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530612}
tierno65acb4d2018-04-06 16:42:40 +0200613
garciadeblas0964edf2022-02-11 00:43:44 +0100614ns_heal = {
615 "title": "ns heal input schema",
616 "$schema": "http://json-schema.org/draft-04/schema#",
617 "type": "object",
618 "properties": {
619 "lcmOperationType": string_schema,
620 "nsInstanceId": id_schema,
621 "timeout_ns_heal": integer1_schema,
622 "healVnfData": {
623 "type": "array",
624 "items": {
625 "type": "object",
626 "properties": {
627 "vnfInstanceId": id_schema,
628 "cause": description_schema,
629 "additionalParams": {
630 "type": "object",
631 "properties": {
632 "run-day1": bool_schema,
633 "vdu": {
634 "type": "array",
635 "items": {
636 "type": "object",
637 "properties": {
638 "run-day1": bool_schema,
639 "vdu-id": name_schema,
640 "count-index": integer0_schema,
641 },
642 "required": ["vdu-id"],
643 "additionalProperties": False,
644 },
645 },
646 },
647 "additionalProperties": False,
648 },
649 },
650 "required": ["vnfInstanceId"],
651 "additionalProperties": False,
652 },
653 },
654 },
655 "required": ["healVnfData"],
656 "additionalProperties": False,
657}
658
Gabriel Cuba84a60df2023-10-30 14:01:54 -0500659nslcmop_cancel = {
660 "title": "Cancel nslcmop input schema",
661 "$schema": "http://json-schema.org/draft-04/schema#",
662 "type": "object",
663 "properties": {
664 "nsLcmOpOccId": id_schema,
665 "cancelMode": {
666 "enum": [
667 "GRACEFUL",
668 "FORCEFUL",
669 ]
670 },
671 },
672 "required": ["cancelMode"],
673 "additionalProperties": False,
674}
675
tierno0f98af52018-03-19 10:28:22 +0100676schema_version = {"type": "string", "enum": ["1.0"]}
tierno55ba2e62018-12-11 17:22:22 +0000677schema_type = {"type": "string"}
tiernob3d0a0e2019-11-13 15:57:51 +0000678vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200679
tierno09c073e2018-04-26 13:36:48 +0200680vim_account_edit_schema = {
681 "title": "vim_account edit input schema",
682 "$schema": "http://json-schema.org/draft-04/schema#",
683 "type": "object",
684 "properties": {
685 "name": name_schema,
686 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200687 "vim": name_schema,
688 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200689 "vim_type": vim_type,
tierno09c073e2018-04-26 13:36:48 +0200690 "vim_url": description_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200691 # "vim_url_admin": description_schema,
692 # "vim_tenant": name_schema,
tierno09c073e2018-04-26 13:36:48 +0200693 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200694 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200695 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200696 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100697 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000698 "prometheus-config": {"type": "object"},
tierno09c073e2018-04-26 13:36:48 +0200699 },
garciadeblas4568a372021-03-24 09:19:48 +0100700 "additionalProperties": False,
tierno09c073e2018-04-26 13:36:48 +0200701}
tierno0f98af52018-03-19 10:28:22 +0100702
tierno09c073e2018-04-26 13:36:48 +0200703vim_account_new_schema = {
704 "title": "vim_account creation input schema",
tierno0f98af52018-03-19 10:28:22 +0100705 "$schema": "http://json-schema.org/draft-04/schema#",
706 "type": "object",
707 "properties": {
708 "schema_version": schema_version,
709 "schema_type": schema_type,
710 "name": name_schema,
711 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200712 "vim": name_schema,
713 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200714 "vim_type": vim_type,
tierno0f98af52018-03-19 10:28:22 +0100715 "vim_url": description_schema,
716 # "vim_url_admin": description_schema,
717 # "vim_tenant": name_schema,
718 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200719 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200720 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200721 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100722 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000723 "prometheus-config": {"type": "object"},
tierno0f98af52018-03-19 10:28:22 +0100724 },
garciadeblas4568a372021-03-24 09:19:48 +0100725 "required": [
726 "name",
727 "vim_url",
728 "vim_type",
729 "vim_user",
730 "vim_password",
731 "vim_tenant_name",
732 ],
733 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100734}
tierno0f98af52018-03-19 10:28:22 +0100735
tierno85807722019-12-20 14:11:35 +0000736wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200737
tierno55ba2e62018-12-11 17:22:22 +0000738wim_account_edit_schema = {
739 "title": "wim_account edit input schema",
740 "$schema": "http://json-schema.org/draft-04/schema#",
741 "type": "object",
742 "properties": {
743 "name": name_schema,
744 "description": description_schema,
tierno55ba2e62018-12-11 17:22:22 +0000745 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200746 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000747 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100748 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000749 "password": passwd_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100750 "config": {"type": "object"},
tierno55ba2e62018-12-11 17:22:22 +0000751 },
garciadeblas4568a372021-03-24 09:19:48 +0100752 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000753}
754
755wim_account_new_schema = {
756 "title": "wim_account creation input schema",
757 "$schema": "http://json-schema.org/draft-04/schema#",
758 "type": "object",
759 "properties": {
760 "schema_version": schema_version,
761 "schema_type": schema_type,
762 "name": name_schema,
763 "description": description_schema,
764 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200765 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000766 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100767 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000768 "password": passwd_schema,
tiernof0637052019-03-07 16:26:47 +0000769 "config": {
770 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100771 "patternProperties": {".": {"not": {"type": "null"}}},
772 },
tierno55ba2e62018-12-11 17:22:22 +0000773 },
774 "required": ["name", "wim_url", "wim_type"],
garciadeblas4568a372021-03-24 09:19:48 +0100775 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000776}
tierno0f98af52018-03-19 10:28:22 +0100777
778sdn_properties = {
779 "name": name_schema,
tierno7adaeb02019-12-17 16:46:12 +0000780 "type": {"type": "string"},
781 "url": {"type": "string"},
sousaedu80b6fed2021-10-07 15:17:32 +0100782 "user": string_schema,
tierno7adaeb02019-12-17 16:46:12 +0000783 "password": passwd_schema,
784 "config": {"type": "object"},
tiernocfb07c62018-05-10 18:30:51 +0200785 "description": description_schema,
tierno7adaeb02019-12-17 16:46:12 +0000786 # The folowing are deprecated. Maintanied for backward compatibility
tiernocb83c942018-09-24 17:28:13 +0200787 "dpid": dpid_Schema,
tierno0f98af52018-03-19 10:28:22 +0100788 "ip": ip_schema,
789 "port": port_schema,
tierno0f98af52018-03-19 10:28:22 +0100790 "version": {"type": "string", "minLength": 1, "maxLength": 12},
tierno0f98af52018-03-19 10:28:22 +0100791}
792sdn_new_schema = {
793 "title": "sdn controller information schema",
794 "$schema": "http://json-schema.org/draft-04/schema#",
795 "type": "object",
796 "properties": sdn_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100797 "required": ["name", "type"],
798 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100799}
800sdn_edit_schema = {
801 "title": "sdn controller update information schema",
802 "$schema": "http://json-schema.org/draft-04/schema#",
803 "type": "object",
804 "properties": sdn_properties,
tiernocfb07c62018-05-10 18:30:51 +0200805 # "required": ["name", "port", 'ip', 'dpid', 'type'],
garciadeblas4568a372021-03-24 09:19:48 +0100806 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100807}
808sdn_port_mapping_schema = {
809 "$schema": "http://json-schema.org/draft-04/schema#",
810 "title": "sdn port mapping information schema",
811 "type": "array",
812 "items": {
813 "type": "object",
814 "properties": {
tiernofd160572019-01-21 10:41:37 +0000815 "compute_node": shortname_schema,
tierno0f98af52018-03-19 10:28:22 +0100816 "ports": {
817 "type": "array",
818 "items": {
819 "type": "object",
820 "properties": {
tierno42fce592018-11-02 09:23:43 +0100821 "pci": pci_extended_schema,
tiernofd160572019-01-21 10:41:37 +0000822 "switch_port": shortname_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100823 "switch_mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100824 },
garciadeblas4568a372021-03-24 09:19:48 +0100825 "required": ["pci"],
826 },
827 },
tierno0f98af52018-03-19 10:28:22 +0100828 },
garciadeblas4568a372021-03-24 09:19:48 +0100829 "required": ["compute_node", "ports"],
830 },
tierno0f98af52018-03-19 10:28:22 +0100831}
832sdn_external_port_schema = {
833 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocd54a4a2018-09-12 16:40:35 +0200834 "title": "External port information",
tierno0f98af52018-03-19 10:28:22 +0100835 "type": "object",
836 "properties": {
837 "port": {"type": "string", "minLength": 1, "maxLength": 60},
838 "vlan": vlan_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100839 "mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100840 },
garciadeblas4568a372021-03-24 09:19:48 +0100841 "required": ["port"],
tierno0f98af52018-03-19 10:28:22 +0100842}
843
delacruzramofe598fe2019-10-23 18:25:11 +0200844# K8s Clusters
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500845k8scluster_deploy_method_schema = {
846 "$schema": "http://json-schema.org/draft-04/schema#",
847 "title": "Deployment methods for K8s cluster",
848 "type": "object",
849 "properties": {
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500850 "juju-bundle": {"type": "boolean"},
851 "helm-chart-v3": {"type": "boolean"},
852 },
853 "additionalProperties": False,
Luis Vega0a1efed2023-11-28 16:44:30 +0000854 "minProperties": 2,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500855}
delacruzramofe598fe2019-10-23 18:25:11 +0200856k8scluster_nets_schema = {
857 "title": "k8scluster nets input schema",
858 "$schema": "http://json-schema.org/draft-04/schema#",
859 "type": "object",
tierno8c81ab02020-02-07 10:18:30 +0000860 "patternProperties": {".": {"oneOf": [name_schema, null_schema]}},
delacruzramofe598fe2019-10-23 18:25:11 +0200861 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100862 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200863}
864k8scluster_new_schema = {
865 "title": "k8scluster creation input schema",
866 "$schema": "http://json-schema.org/draft-04/schema#",
867 "type": "object",
868 "properties": {
869 "schema_version": schema_version,
870 "schema_type": schema_type,
871 "name": name_schema,
872 "description": description_schema,
873 "credentials": object_schema,
874 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200875 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200876 "k8s_version": string_schema,
877 "nets": k8scluster_nets_schema,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500878 "deployment_methods": k8scluster_deploy_method_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200879 "namespace": name_schema,
880 "cni": nameshort_list_schema,
881 },
882 "required": ["name", "credentials", "vim_account", "k8s_version", "nets"],
garciadeblas4568a372021-03-24 09:19:48 +0100883 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200884}
885k8scluster_edit_schema = {
886 "title": "vim_account edit input schema",
887 "$schema": "http://json-schema.org/draft-04/schema#",
888 "type": "object",
889 "properties": {
890 "name": name_schema,
891 "description": description_schema,
892 "credentials": object_schema,
893 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200894 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200895 "k8s_version": string_schema,
896 "nets": k8scluster_nets_schema,
897 "namespace": name_schema,
898 "cni": nameshort_list_schema,
899 },
garciadeblas4568a372021-03-24 09:19:48 +0100900 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200901}
902
David Garciaecb41322021-03-31 19:10:46 +0200903# VCA
904vca_new_schema = {
905 "title": "vca creation input schema",
906 "$schema": "http://json-schema.org/draft-04/schema#",
907 "type": "object",
908 "properties": {
909 "schema_version": schema_version,
910 "schema_type": schema_type,
911 "name": name_schema,
912 "description": description_schema,
913 "endpoints": description_list_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100914 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200915 "secret": passwd_schema,
916 "cacert": long_description_schema,
917 "lxd-cloud": shortname_schema,
918 "lxd-credentials": shortname_schema,
919 "k8s-cloud": shortname_schema,
920 "k8s-credentials": shortname_schema,
921 "model-config": object_schema,
922 },
923 "required": [
924 "name",
925 "endpoints",
926 "user",
927 "secret",
928 "cacert",
929 "lxd-cloud",
930 "lxd-credentials",
931 "k8s-cloud",
932 "k8s-credentials",
933 ],
934 "additionalProperties": False,
935}
936vca_edit_schema = {
937 "title": "vca creation input schema",
938 "$schema": "http://json-schema.org/draft-04/schema#",
939 "type": "object",
940 "properties": {
941 "name": name_schema,
942 "description": description_schema,
943 "endpoints": description_list_schema,
944 "port": integer1_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100945 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200946 "secret": passwd_schema,
947 "cacert": long_description_schema,
948 "lxd-cloud": shortname_schema,
949 "lxd-credentials": shortname_schema,
950 "k8s-cloud": shortname_schema,
951 "k8s-credentials": shortname_schema,
952 "model-config": object_schema,
953 },
954 "additionalProperties": False,
955}
956
delacruzramofe598fe2019-10-23 18:25:11 +0200957# K8s Repos
tierno332e0802019-12-03 23:50:49 +0000958k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]}
delacruzramofe598fe2019-10-23 18:25:11 +0200959k8srepo_properties = {
960 "name": name_schema,
961 "description": description_schema,
962 "type": k8srepo_types,
963 "url": description_schema,
Luis Vegaf6574e32023-07-11 18:47:22 +0000964 "cacert": long_description_schema,
965 "user": string_schema,
966 "password": passwd_schema,
garciadeblasf3543892023-10-20 11:53:51 +0200967 "oci": bool_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200968}
969k8srepo_new_schema = {
970 "title": "k8scluster creation input schema",
971 "$schema": "http://json-schema.org/draft-04/schema#",
972 "type": "object",
973 "properties": k8srepo_properties,
974 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100975 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200976}
977k8srepo_edit_schema = {
978 "title": "vim_account edit input schema",
979 "$schema": "http://json-schema.org/draft-04/schema#",
980 "type": "object",
981 "properties": k8srepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100982 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200983}
984
Felipe Vicensb66b0412020-05-06 10:11:00 +0200985# OSM Repos
986osmrepo_types = {"enum": ["osm"]}
987osmrepo_properties = {
988 "name": name_schema,
989 "description": description_schema,
990 "type": osmrepo_types,
rshri2d386cb2024-07-05 14:35:51 +0000991 "url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100992 # "user": string_schema,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200993 # "password": passwd_schema
994}
995osmrepo_new_schema = {
996 "title": "osm repo creation input schema",
997 "$schema": "http://json-schema.org/draft-04/schema#",
998 "type": "object",
999 "properties": osmrepo_properties,
1000 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +01001001 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001002}
1003osmrepo_edit_schema = {
1004 "title": "osm repo edit input schema",
1005 "$schema": "http://json-schema.org/draft-04/schema#",
1006 "type": "object",
1007 "properties": osmrepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +01001008 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001009}
1010
tiernocb83c942018-09-24 17:28:13 +02001011# PDUs
1012pdu_interface = {
1013 "type": "object",
1014 "properties": {
tiernofd160572019-01-21 10:41:37 +00001015 "name": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001016 "mgmt": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001017 "type": {"enum": ["overlay", "underlay"]},
garciadeblas1a01e1f2021-10-26 17:27:35 +02001018 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernocb83c942018-09-24 17:28:13 +02001019 # TODO, add user, password, ssh-key
tierno36ec8602018-11-02 17:27:11 +01001020 "mac-address": mac_schema,
tiernofd160572019-01-21 10:41:37 +00001021 "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
1022 "vim-network-id": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001023 # # provide this in case SDN assist must deal with this interface
1024 # "switch-dpid": dpid_Schema,
tiernofd160572019-01-21 10:41:37 +00001025 # "switch-port": shortname_schema,
1026 # "switch-mac": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001027 # "switch-vlan": vlan_schema,
tiernocb83c942018-09-24 17:28:13 +02001028 },
tierno36ec8602018-11-02 17:27:11 +01001029 "required": ["name", "mgmt", "ip-address"],
garciadeblas4568a372021-03-24 09:19:48 +01001030 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001031}
tiernocb83c942018-09-24 17:28:13 +02001032pdu_new_schema = {
1033 "title": "pdu creation input schema",
1034 "$schema": "http://json-schema.org/draft-04/schema#",
1035 "type": "object",
1036 "properties": {
tiernofd160572019-01-21 10:41:37 +00001037 "name": shortname_schema,
1038 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001039 "description": description_schema,
1040 "shared": bool_schema,
1041 "vims": nameshort_list_schema,
1042 "vim_accounts": nameshort_list_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001043 "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1},
tiernocb83c942018-09-24 17:28:13 +02001044 },
1045 "required": ["name", "type", "interfaces"],
garciadeblas4568a372021-03-24 09:19:48 +01001046 "additionalProperties": False,
tiernocb83c942018-09-24 17:28:13 +02001047}
tiernocb83c942018-09-24 17:28:13 +02001048pdu_edit_schema = {
1049 "title": "pdu edit input schema",
1050 "$schema": "http://json-schema.org/draft-04/schema#",
1051 "type": "object",
1052 "properties": {
tiernofd160572019-01-21 10:41:37 +00001053 "name": shortname_schema,
1054 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001055 "description": description_schema,
1056 "shared": bool_schema,
garciadeblas84bdd552018-11-30 22:59:45 +01001057 "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
1058 "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
garciadeblas4568a372021-03-24 09:19:48 +01001059 "interfaces": {
1060 "oneOf": [
1061 array_edition_schema,
1062 {"type": "array", "items": pdu_interface, "minItems": 1},
1063 ]
1064 },
tiernocb83c942018-09-24 17:28:13 +02001065 },
1066 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001067 "minProperties": 1,
tiernocb83c942018-09-24 17:28:13 +02001068}
1069
delacruzramo271d2002019-12-02 21:00:37 +01001070# VNF PKG OPERATIONS
1071vnfpkgop_new_schema = {
1072 "title": "VNF PKG operation creation input schema",
1073 "$schema": "http://json-schema.org/draft-04/schema#",
1074 "type": "object",
1075 "properties": {
1076 "lcmOperationType": string_schema,
1077 "vnfPkgId": id_schema,
1078 "kdu_name": name_schema,
1079 "primitive": name_schema,
1080 "primitive_params": {"type": "object"},
1081 },
garciadeblas4568a372021-03-24 09:19:48 +01001082 "required": [
1083 "lcmOperationType",
1084 "vnfPkgId",
1085 "kdu_name",
1086 "primitive",
1087 "primitive_params",
1088 ],
1089 "additionalProperties": False,
delacruzramo271d2002019-12-02 21:00:37 +01001090}
1091
rshri2d386cb2024-07-05 14:35:51 +00001092clustercreation_new_schema = {
1093 "title": "cluster creation operation input schema",
1094 "$schema": "http://json-schema.org/draft-04/schema#",
1095 "type": "object",
1096 "properties": {
1097 "name": name_schema,
1098 "vim_account": string_schema,
1099 "k8s_version": string_schema,
1100 "node_size": string_schema,
1101 "node_count": integer0_schema,
rshri17b09ec2024-11-07 05:48:12 +00001102 "description": description_schema,
rshri2d386cb2024-07-05 14:35:51 +00001103 "region_name": string_schema,
1104 "resource_group": string_schema,
1105 "infra_controller_profiles": shortname_schema,
1106 "infra_config_profiles": shortname_schema,
1107 "resource_profiles": shortname_schema,
1108 "app_profiles": shortname_schema,
rshri17b09ec2024-11-07 05:48:12 +00001109 "created": string_schema,
1110 "state": string_schema,
1111 "operatingState": string_schema,
1112 "git_name": string_schema,
1113 "resourceState": string_schema,
1114 "bootstrap": bool_schema,
rshri2d386cb2024-07-05 14:35:51 +00001115 },
1116 "required": [
1117 "name",
1118 "vim_account",
1119 "k8s_version",
1120 "node_size",
1121 "node_count",
rshri2d386cb2024-07-05 14:35:51 +00001122 ],
1123 "additionalProperties": False,
1124}
rshri17b09ec2024-11-07 05:48:12 +00001125clusterregistration_new_schema = {
1126 "title": "cluster registration input schema",
1127 "$schema": "http://json-schema.org/draft-04/schema#",
1128 "type": "object",
1129 "properties": {
1130 "schema_version": schema_version,
1131 "schema_type": schema_type,
1132 "name": name_schema,
1133 "description": description_schema,
1134 "credentials": object_schema,
1135 "vim_account": string_schema,
1136 "bootstrap": bool_schema,
1137 },
1138 "required": ["name", "credentials", "vim_account"],
1139 "additionalProperties": False,
1140}
rshri2d386cb2024-07-05 14:35:51 +00001141
yshah99122b82024-11-18 07:05:29 +00001142cluster_edit_schema = {
1143 "title": "cluster edit schema",
1144 "$schema": "http://json-schema.org/draft-04/schema#",
1145 "type": "object",
1146 "properties": {
1147 "name": name_schema,
1148 "description": string_schema,
1149 },
1150 "additionalProperties": False,
1151}
1152
1153cluster_update_schema = {
1154 "title": "cluster update schema",
1155 "$schema": "http://json-schema.org/draft-04/schema#",
1156 "type": "object",
1157 "properties": {
1158 "k8s_version": string_schema,
1159 "node_size": string_schema,
1160 "node_count": integer0_schema,
1161 },
1162 "additionalProperties": True,
1163}
1164
rshri2d386cb2024-07-05 14:35:51 +00001165infra_controller_profile_create_new_schema = {
1166 "title": "infra profile creation operation input schema",
1167 "$schema": "http://json-schema.org/draft-04/schema#",
1168 "type": "object",
1169 "properties": {
1170 "name": name_schema,
1171 "description": string_schema,
1172 },
1173 "additionalProperties": False,
1174}
1175
1176infra_controller_profile_create_edit_schema = {
1177 "title": "infra profile creation operation input schema",
1178 "$schema": "http://json-schema.org/draft-04/schema#",
1179 "type": "object",
1180 "properties": {
1181 "name": name_schema,
1182 "description": string_schema,
1183 },
1184 "additionalProperties": False,
1185}
1186
1187infra_config_profile_create_new_schema = {
1188 "title": "infra profile creation operation input schema",
1189 "$schema": "http://json-schema.org/draft-04/schema#",
1190 "type": "object",
1191 "properties": {
1192 "name": name_schema,
1193 "description": string_schema,
1194 },
1195 "additionalProperties": False,
1196}
1197
1198infra_config_profile_create_edit_schema = {
1199 "title": "infra profile creation operation input schema",
1200 "$schema": "http://json-schema.org/draft-04/schema#",
1201 "type": "object",
1202 "properties": {
1203 "name": name_schema,
1204 "description": string_schema,
1205 },
1206 "additionalProperties": False,
1207}
1208
1209app_profile_create_new_schema = {
1210 "title": "app profile creation operation input schema",
1211 "$schema": "http://json-schema.org/draft-04/schema#",
1212 "type": "object",
1213 "properties": {
1214 "name": name_schema,
1215 "description": string_schema,
1216 },
1217 "additionalProperties": False,
1218}
1219app_profile_create_edit_schema = {
1220 "title": "app profile creation operation input schema",
1221 "$schema": "http://json-schema.org/draft-04/schema#",
1222 "type": "object",
1223 "properties": {
1224 "name": name_schema,
1225 "description": string_schema,
1226 },
1227 "additionalProperties": False,
1228}
1229
1230resource_profile_create_new_schema = {
1231 "title": "resource profile creation operation input schema",
1232 "$schema": "http://json-schema.org/draft-04/schema#",
1233 "type": "object",
1234 "properties": {
1235 "name": name_schema,
1236 "description": string_schema,
1237 },
1238 "additionalProperties": False,
1239}
1240resource_profile_create_edit_schema = {
1241 "title": "resource profile creation operation input schema",
1242 "$schema": "http://json-schema.org/draft-04/schema#",
1243 "type": "object",
1244 "properties": {
1245 "name": name_schema,
1246 "description": string_schema,
1247 },
1248 "additionalProperties": False,
1249}
1250
1251attach_profile = {
1252 "type": "array",
1253 "items": {
1254 "type": "object",
1255 "properties": {"id": id_schema},
1256 "additionalProperties": False,
1257 },
1258}
1259remove_profile = {
1260 "type": "array",
1261 "items": {
1262 "type": "object",
1263 "properties": {"id": id_schema},
1264 "additionalProperties": False,
1265 },
1266}
1267attach_dettach_profile_schema = {
1268 "title": "attach/dettach profiles",
1269 "$schema": "http://json-schema.org/draft-04/schema#",
1270 "type": "object",
1271 "properties": {
1272 "add_profile": attach_profile,
1273 "remove_profile": remove_profile,
1274 },
1275 "additionalProperties": False,
1276}
tiernocb83c942018-09-24 17:28:13 +02001277# USERS
tiernocf042d32019-06-13 09:06:40 +00001278project_role_mappings = {
1279 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001280 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001281 "type": "array",
1282 "items": {
1283 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001284 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001285 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001286 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001287 },
garciadeblas4568a372021-03-24 09:19:48 +01001288 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001289}
rshri2d386cb2024-07-05 14:35:51 +00001290
tiernocf042d32019-06-13 09:06:40 +00001291project_role_mappings_optional = {
1292 "title": "list of projects/roles or projects only",
1293 "$schema": "http://json-schema.org/draft-04/schema#",
1294 "type": "array",
1295 "items": {
1296 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001297 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001298 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001299 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001300 },
garciadeblas4568a372021-03-24 09:19:48 +01001301 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001302}
rshri2d386cb2024-07-05 14:35:51 +00001303
tiernocd54a4a2018-09-12 16:40:35 +02001304user_new_schema = {
1305 "$schema": "http://json-schema.org/draft-04/schema#",
1306 "title": "New user schema",
1307 "type": "object",
1308 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001309 "username": string_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001310 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001311 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001312 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001313 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001314 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001315 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001316 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001317 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001318}
1319user_edit_schema = {
1320 "$schema": "http://json-schema.org/draft-04/schema#",
1321 "title": "User edit schema for administrators",
1322 "type": "object",
1323 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001324 "password": user_passwd_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001325 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001326 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001327 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001328 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001329 "project_role_mappings": project_role_mappings,
1330 "add_project_role_mappings": project_role_mappings,
1331 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001332 "system_admin_id": id_schema,
1333 "unlock": bool_schema,
1334 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001335 },
1336 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001337 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001338}
1339
1340# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001341topics_with_quota = [
1342 "vnfds",
1343 "nsds",
1344 "slice_templates",
1345 "pduds",
1346 "ns_instances",
1347 "slice_instances",
1348 "vim_accounts",
1349 "wim_accounts",
1350 "sdn_controllers",
1351 "k8sclusters",
1352 "vca",
1353 "k8srepos",
1354 "osmrepos",
1355 "ns_subscriptions",
1356]
tiernocd54a4a2018-09-12 16:40:35 +02001357project_new_schema = {
1358 "$schema": "http://json-schema.org/draft-04/schema#",
1359 "title": "New project schema for administrators",
1360 "type": "object",
1361 "properties": {
tiernofd160572019-01-21 10:41:37 +00001362 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001363 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001364 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001365 "quotas": {
1366 "type": "object",
1367 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001368 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001369 },
tiernocd54a4a2018-09-12 16:40:35 +02001370 },
1371 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001372 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001373}
1374project_edit_schema = {
1375 "$schema": "http://json-schema.org/draft-04/schema#",
1376 "title": "Project edit schema for administrators",
1377 "type": "object",
1378 "properties": {
1379 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001380 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001381 "quotas": {
1382 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001383 "properties": {
1384 topic: {"oneOf": [integer0_schema, null_schema]}
1385 for topic in topics_with_quota
1386 },
1387 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001388 },
tiernocd54a4a2018-09-12 16:40:35 +02001389 },
1390 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001391 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001392}
1393
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001394# ROLES
1395roles_new_schema = {
1396 "$schema": "http://json-schema.org/draft-04/schema#",
1397 "title": "New role schema for administrators",
1398 "type": "object",
1399 "properties": {
1400 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001401 "permissions": {
1402 "type": "object",
1403 "patternProperties": {
1404 ".": bool_schema,
1405 },
1406 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001407 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001408 },
tierno1f029d82019-06-13 22:37:04 +00001409 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001410 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001411}
1412roles_edit_schema = {
1413 "$schema": "http://json-schema.org/draft-04/schema#",
1414 "title": "Roles edit schema for administrators",
1415 "type": "object",
1416 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001417 "name": shortname_schema,
1418 "permissions": {
1419 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001420 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001421 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001422 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001423 },
tierno1f029d82019-06-13 22:37:04 +00001424 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001425 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001426}
1427
tiernocd54a4a2018-09-12 16:40:35 +02001428# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001429
1430nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001431 "users": user_new_schema,
1432 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001433 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001434 "sdns": sdn_new_schema,
1435 "ns_instantiate": ns_instantiate,
1436 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001437 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001438 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001439 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001440 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001441}
1442
1443nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001444 "users": user_edit_schema,
1445 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001446 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001447 "sdns": sdn_edit_schema,
1448 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301449 "vnf": vnf_schema,
1450 "vld": vld_schema,
1451 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001452}
1453
Felipe Vicens07f31722018-10-29 15:16:44 +01001454# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001455nsi_subnet_instantiate = deepcopy(ns_instantiate)
1456nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1457nsi_subnet_instantiate["properties"]["id"] = name_schema
1458del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001459
1460nsi_vld_instantiate = {
1461 "title": "netslice vld instantiation params input schema",
1462 "$schema": "http://json-schema.org/draft-04/schema#",
1463 "type": "object",
1464 "properties": {
1465 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001466 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1467 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001468 "ip-profile": object_schema,
1469 },
delacruzramoc061f562019-04-05 11:00:02 +02001470 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001471 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001472}
1473
Felipe Vicens07f31722018-10-29 15:16:44 +01001474nsi_instantiate = {
1475 "title": "netslice action instantiate input schema",
1476 "$schema": "http://json-schema.org/draft-04/schema#",
1477 "type": "object",
1478 "properties": {
1479 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001480 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001481 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001482 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001483 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001484 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001485 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001486 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001487 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001488 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001489 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001490 "type": "array",
1491 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001492 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001493 },
garciadeblas4568a372021-03-24 09:19:48 +01001494 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001495 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001496 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001497 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001498}
1499
garciadeblas4568a372021-03-24 09:19:48 +01001500nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001501
garciadeblas4568a372021-03-24 09:19:48 +01001502nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001503
preethika.p329b8182020-04-22 12:25:39 +05301504nsinstancesubscriptionfilter_schema = {
1505 "title": "instance identifier schema",
1506 "$schema": "http://json-schema.org/draft-07/schema#",
1507 "type": "object",
1508 "properties": {
1509 "nsdIds": {"type": "array"},
1510 "vnfdIds": {"type": "array"},
1511 "pnfdIds": {"type": "array"},
1512 "nsInstanceIds": {"type": "array"},
1513 "nsInstanceNames": {"type": "array"},
1514 },
1515}
1516
1517nslcmsub_schema = {
1518 "title": "nslcmsubscription input schema",
1519 "$schema": "http://json-schema.org/draft-07/schema#",
1520 "type": "object",
1521 "properties": {
1522 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1523 "notificationTypes": {
1524 "type": "array",
1525 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001526 "enum": [
1527 "NsLcmOperationOccurrenceNotification",
1528 "NsChangeNotification",
1529 "NsIdentifierCreationNotification",
1530 "NsIdentifierDeletionNotification",
1531 ]
1532 },
preethika.p329b8182020-04-22 12:25:39 +05301533 },
1534 "operationTypes": {
1535 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001536 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301537 },
1538 "operationStates": {
1539 "type": "array",
1540 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001541 "enum": [
1542 "PROCESSING",
1543 "COMPLETED",
1544 "PARTIALLY_COMPLETED",
1545 "FAILED",
1546 "FAILED_TEMP",
1547 "ROLLING_BACK",
1548 "ROLLED_BACK",
1549 ]
1550 },
preethika.p329b8182020-04-22 12:25:39 +05301551 },
garciadeblas4568a372021-03-24 09:19:48 +01001552 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301553 "lcmOpNameImpactingNsComponent": {
1554 "type": "array",
1555 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001556 "enum": [
1557 "VNF_INSTANTIATE",
1558 "VNF_SCALE",
1559 "VNF_SCALE_TO_LEVEL",
1560 "VNF_CHANGE_FLAVOUR",
1561 "VNF_TERMINATE",
1562 "VNF_HEAL",
1563 "VNF_OPERATE",
1564 "VNF_CHANGE_EXT_CONN",
1565 "VNF_MODIFY_INFO",
1566 "NS_INSTANTIATE",
1567 "NS_SCALE",
1568 "NS_UPDATE",
1569 "NS_TERMINATE",
1570 "NS_HEAL",
1571 ]
1572 },
preethika.p329b8182020-04-22 12:25:39 +05301573 },
1574 "lcmOpOccStatusImpactingNsComponent": {
1575 "type": "array",
1576 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001577 "enum": [
1578 "START",
1579 "COMPLETED",
1580 "PARTIALLY_COMPLETED",
1581 "FAILED",
1582 "ROLLED_BACK",
1583 ]
1584 },
preethika.p329b8182020-04-22 12:25:39 +05301585 },
1586 },
1587 "allOf": [
1588 {
1589 "if": {
1590 "properties": {
1591 "notificationTypes": {
1592 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1593 }
1594 },
1595 },
1596 "then": {
1597 "anyOf": [
1598 {"required": ["operationTypes"]},
1599 {"required": ["operationStates"]},
1600 ]
garciadeblas4568a372021-03-24 09:19:48 +01001601 },
preethika.p329b8182020-04-22 12:25:39 +05301602 },
1603 {
1604 "if": {
1605 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001606 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301607 },
1608 },
1609 "then": {
1610 "anyOf": [
1611 {"required": ["nsComponentTypes"]},
1612 {"required": ["lcmOpNameImpactingNsComponent"]},
1613 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1614 ]
garciadeblas4568a372021-03-24 09:19:48 +01001615 },
1616 },
1617 ],
preethika.p329b8182020-04-22 12:25:39 +05301618}
1619
1620authentication_schema = {
1621 "title": "authentication schema for subscription",
1622 "$schema": "http://json-schema.org/draft-07/schema#",
1623 "type": "object",
1624 "properties": {
1625 "authType": {"enum": ["basic"]},
1626 "paramsBasic": {
1627 "type": "object",
1628 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001629 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301630 "password": passwd_schema,
1631 },
1632 },
1633 },
1634}
1635
1636subscription = {
1637 "title": "subscription input schema",
1638 "$schema": "http://json-schema.org/draft-07/schema#",
1639 "type": "object",
1640 "properties": {
1641 "filter": nslcmsub_schema,
1642 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001643 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301644 },
1645 "required": ["CallbackUri"],
1646}
1647
selvi.jf1004592022-04-29 05:42:35 +00001648vnflcmsub_schema = {
1649 "title": "vnflcmsubscription input schema",
1650 "$schema": "http://json-schema.org/draft-07/schema#",
1651 "type": "object",
1652 "properties": {
1653 "VnfInstanceSubscriptionFilter": {
1654 "type": "object",
1655 "properties": {
1656 "vnfdIds": {"type": "array"},
1657 "vnfInstanceIds": {"type": "array"},
1658 },
1659 },
1660 "notificationTypes": {
1661 "type": "array",
1662 "items": {
1663 "enum": [
1664 "VnfIdentifierCreationNotification",
1665 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001666 "VnfIdentifierDeletionNotification",
1667 ]
1668 },
selvi.jf1004592022-04-29 05:42:35 +00001669 },
1670 "operationTypes": {
1671 "type": "array",
1672 "items": {
1673 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001674 "INSTANTIATE",
1675 "SCALE",
1676 "SCALE_TO_LEVEL",
1677 "CHANGE_FLAVOUR",
1678 "TERMINATE",
1679 "HEAL",
1680 "OPERATE",
1681 "CHANGE_EXT_CONN",
1682 "MODIFY_INFO",
1683 "CREATE_SNAPSHOT",
1684 "REVERT_TO_SNAPSHOT",
1685 "CHANGE_VNFPKG",
1686 ]
1687 },
selvi.jf1004592022-04-29 05:42:35 +00001688 },
1689 "operationStates": {
1690 "type": "array",
1691 "items": {
1692 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001693 "STARTING",
1694 "PROCESSING",
1695 "COMPLETED",
1696 "FAILED_TEMP",
1697 "FAILED",
1698 "ROLLING_BACK",
1699 "ROLLED_BACK",
1700 ]
1701 },
1702 },
selvi.jf1004592022-04-29 05:42:35 +00001703 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001704 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1705}
selvi.jf1004592022-04-29 05:42:35 +00001706
1707vnf_subscription = {
1708 "title": "vnf subscription input schema",
1709 "$schema": "http://json-schema.org/draft-07/schema#",
1710 "type": "object",
1711 "properties": {
1712 "filter": vnflcmsub_schema,
1713 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001714 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001715 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001716 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001717}
1718
yshah53cc9eb2024-07-05 13:06:31 +00001719oka_schema = {
1720 "title": "Create OKA package input schema",
1721 "$schema": "http://json-schema.org/draft-07/schema#",
1722 "type": "object",
1723 "properties": {
1724 "name": name_schema,
1725 "description": description_schema,
garciadeblas3fb820d2024-12-05 13:11:11 +01001726 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001727 },
1728 "additionalProperties": False,
1729}
1730
1731ksu_schema = {
1732 "title": "ksu schema",
1733 "$schema": "http://json-schema.org/draft-07/schema#",
1734 "type": "object",
1735 "properties": {
1736 "name": name_schema,
1737 "description": description_schema,
1738 "profile": {
1739 "type": "object",
1740 "properties": {
garciadeblas3fb820d2024-12-05 13:11:11 +01001741 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001742 "_id": id_schema,
1743 },
1744 "additionalProperties": False,
1745 },
1746 "oka": {
1747 "type": "array",
1748 "items": {
1749 "type": "object",
1750 "properties": {
1751 "_id": id_schema,
1752 "sw_catalog_path": string_schema,
1753 "transformation": object_schema,
1754 },
1755 "additionalProperties": False,
1756 },
1757 },
1758 },
1759 "additionalProperties": False,
1760}
1761
tierno0f98af52018-03-19 10:28:22 +01001762
1763class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001764 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1765 self.http_code = http_code
1766 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001767
1768
tiernob24258a2018-10-04 18:39:49 +02001769def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001770 """
tiernocd54a4a2018-09-12 16:40:35 +02001771 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001772 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001773 :param schema_to_use: jsonschema to test
1774 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001775 """
1776 try:
tierno0f98af52018-03-19 10:28:22 +01001777 if schema_to_use:
1778 js_v(indata, schema_to_use)
1779 return None
1780 except js_e.ValidationError as e:
1781 if e.path:
tierno0da52252018-06-27 15:47:22 +02001782 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001783 else:
1784 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001785 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001786 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001787 raise ValidationError(
1788 "Bad json schema {}".format(schema_to_use),
1789 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1790 )
delacruzramoc061f562019-04-05 11:00:02 +02001791
1792
1793def is_valid_uuid(x):
1794 """
1795 Test for a valid UUID
1796 :param x: string to test
1797 :return: True if x is a valid uuid, False otherwise
1798 """
1799 try:
1800 if UUID(x):
1801 return True
tiernobdebce92019-07-01 15:36:49 +00001802 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001803 return False