blob: 75d16cad0ab1628f44f2f6af82e1bb5519735894 [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}
jegan2c4bf4e2024-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
garciadeblase073f552024-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,
kayal2001bc7d12e2024-11-28 10:47:32 +0530162 "vim-flavor-name": name_schema,
kayal20012b9052a2024-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,
602 "vdu": {
603 "type": "object",
garciadeblasf2af4a12023-01-24 16:56:54 +0100604 "properties": {
605 "vduId": name_schema,
606 "vduCountIndex": integer0_schema,
607 },
608 "required": ["vduId"],
609 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530610 },
611 },
612 "required": ["vnfInstanceId"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100613 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530614}
tierno65acb4d2018-04-06 16:42:40 +0200615
garciadeblas0964edf2022-02-11 00:43:44 +0100616ns_heal = {
617 "title": "ns heal input schema",
618 "$schema": "http://json-schema.org/draft-04/schema#",
619 "type": "object",
620 "properties": {
621 "lcmOperationType": string_schema,
622 "nsInstanceId": id_schema,
623 "timeout_ns_heal": integer1_schema,
624 "healVnfData": {
625 "type": "array",
626 "items": {
627 "type": "object",
628 "properties": {
629 "vnfInstanceId": id_schema,
630 "cause": description_schema,
631 "additionalParams": {
632 "type": "object",
633 "properties": {
634 "run-day1": bool_schema,
635 "vdu": {
636 "type": "array",
637 "items": {
638 "type": "object",
639 "properties": {
640 "run-day1": bool_schema,
641 "vdu-id": name_schema,
642 "count-index": integer0_schema,
643 },
644 "required": ["vdu-id"],
645 "additionalProperties": False,
646 },
647 },
648 },
649 "additionalProperties": False,
650 },
651 },
652 "required": ["vnfInstanceId"],
653 "additionalProperties": False,
654 },
655 },
656 },
657 "required": ["healVnfData"],
658 "additionalProperties": False,
659}
660
Gabriel Cuba84a60df2023-10-30 14:01:54 -0500661nslcmop_cancel = {
662 "title": "Cancel nslcmop input schema",
663 "$schema": "http://json-schema.org/draft-04/schema#",
664 "type": "object",
665 "properties": {
666 "nsLcmOpOccId": id_schema,
667 "cancelMode": {
668 "enum": [
669 "GRACEFUL",
670 "FORCEFUL",
671 ]
672 },
673 },
674 "required": ["cancelMode"],
675 "additionalProperties": False,
676}
677
tierno0f98af52018-03-19 10:28:22 +0100678schema_version = {"type": "string", "enum": ["1.0"]}
tierno55ba2e62018-12-11 17:22:22 +0000679schema_type = {"type": "string"}
tiernob3d0a0e2019-11-13 15:57:51 +0000680vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200681
tierno09c073e2018-04-26 13:36:48 +0200682vim_account_edit_schema = {
683 "title": "vim_account edit input schema",
684 "$schema": "http://json-schema.org/draft-04/schema#",
685 "type": "object",
686 "properties": {
687 "name": name_schema,
688 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200689 "vim": name_schema,
690 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200691 "vim_type": vim_type,
tierno09c073e2018-04-26 13:36:48 +0200692 "vim_url": description_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200693 # "vim_url_admin": description_schema,
694 # "vim_tenant": name_schema,
tierno09c073e2018-04-26 13:36:48 +0200695 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200696 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200697 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200698 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100699 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000700 "prometheus-config": {"type": "object"},
tierno09c073e2018-04-26 13:36:48 +0200701 },
garciadeblas4568a372021-03-24 09:19:48 +0100702 "additionalProperties": False,
tierno09c073e2018-04-26 13:36:48 +0200703}
tierno0f98af52018-03-19 10:28:22 +0100704
tierno09c073e2018-04-26 13:36:48 +0200705vim_account_new_schema = {
706 "title": "vim_account creation input schema",
tierno0f98af52018-03-19 10:28:22 +0100707 "$schema": "http://json-schema.org/draft-04/schema#",
708 "type": "object",
709 "properties": {
710 "schema_version": schema_version,
711 "schema_type": schema_type,
712 "name": name_schema,
713 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200714 "vim": name_schema,
715 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200716 "vim_type": vim_type,
tierno0f98af52018-03-19 10:28:22 +0100717 "vim_url": description_schema,
718 # "vim_url_admin": description_schema,
719 # "vim_tenant": name_schema,
720 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200721 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200722 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200723 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100724 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000725 "prometheus-config": {"type": "object"},
tierno0f98af52018-03-19 10:28:22 +0100726 },
garciadeblas4568a372021-03-24 09:19:48 +0100727 "required": [
728 "name",
729 "vim_url",
730 "vim_type",
731 "vim_user",
732 "vim_password",
733 "vim_tenant_name",
734 ],
735 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100736}
tierno0f98af52018-03-19 10:28:22 +0100737
tierno85807722019-12-20 14:11:35 +0000738wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200739
tierno55ba2e62018-12-11 17:22:22 +0000740wim_account_edit_schema = {
741 "title": "wim_account edit input schema",
742 "$schema": "http://json-schema.org/draft-04/schema#",
743 "type": "object",
744 "properties": {
745 "name": name_schema,
746 "description": description_schema,
tierno55ba2e62018-12-11 17:22:22 +0000747 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200748 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000749 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100750 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000751 "password": passwd_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100752 "config": {"type": "object"},
tierno55ba2e62018-12-11 17:22:22 +0000753 },
garciadeblas4568a372021-03-24 09:19:48 +0100754 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000755}
756
757wim_account_new_schema = {
758 "title": "wim_account creation input schema",
759 "$schema": "http://json-schema.org/draft-04/schema#",
760 "type": "object",
761 "properties": {
762 "schema_version": schema_version,
763 "schema_type": schema_type,
764 "name": name_schema,
765 "description": description_schema,
766 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200767 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000768 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100769 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000770 "password": passwd_schema,
tiernof0637052019-03-07 16:26:47 +0000771 "config": {
772 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100773 "patternProperties": {".": {"not": {"type": "null"}}},
774 },
tierno55ba2e62018-12-11 17:22:22 +0000775 },
776 "required": ["name", "wim_url", "wim_type"],
garciadeblas4568a372021-03-24 09:19:48 +0100777 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000778}
tierno0f98af52018-03-19 10:28:22 +0100779
780sdn_properties = {
781 "name": name_schema,
tierno7adaeb02019-12-17 16:46:12 +0000782 "type": {"type": "string"},
783 "url": {"type": "string"},
sousaedu80b6fed2021-10-07 15:17:32 +0100784 "user": string_schema,
tierno7adaeb02019-12-17 16:46:12 +0000785 "password": passwd_schema,
786 "config": {"type": "object"},
tiernocfb07c62018-05-10 18:30:51 +0200787 "description": description_schema,
tierno7adaeb02019-12-17 16:46:12 +0000788 # The folowing are deprecated. Maintanied for backward compatibility
tiernocb83c942018-09-24 17:28:13 +0200789 "dpid": dpid_Schema,
tierno0f98af52018-03-19 10:28:22 +0100790 "ip": ip_schema,
791 "port": port_schema,
tierno0f98af52018-03-19 10:28:22 +0100792 "version": {"type": "string", "minLength": 1, "maxLength": 12},
tierno0f98af52018-03-19 10:28:22 +0100793}
794sdn_new_schema = {
795 "title": "sdn controller information schema",
796 "$schema": "http://json-schema.org/draft-04/schema#",
797 "type": "object",
798 "properties": sdn_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100799 "required": ["name", "type"],
800 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100801}
802sdn_edit_schema = {
803 "title": "sdn controller update information schema",
804 "$schema": "http://json-schema.org/draft-04/schema#",
805 "type": "object",
806 "properties": sdn_properties,
tiernocfb07c62018-05-10 18:30:51 +0200807 # "required": ["name", "port", 'ip', 'dpid', 'type'],
garciadeblas4568a372021-03-24 09:19:48 +0100808 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100809}
810sdn_port_mapping_schema = {
811 "$schema": "http://json-schema.org/draft-04/schema#",
812 "title": "sdn port mapping information schema",
813 "type": "array",
814 "items": {
815 "type": "object",
816 "properties": {
tiernofd160572019-01-21 10:41:37 +0000817 "compute_node": shortname_schema,
tierno0f98af52018-03-19 10:28:22 +0100818 "ports": {
819 "type": "array",
820 "items": {
821 "type": "object",
822 "properties": {
tierno42fce592018-11-02 09:23:43 +0100823 "pci": pci_extended_schema,
tiernofd160572019-01-21 10:41:37 +0000824 "switch_port": shortname_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100825 "switch_mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100826 },
garciadeblas4568a372021-03-24 09:19:48 +0100827 "required": ["pci"],
828 },
829 },
tierno0f98af52018-03-19 10:28:22 +0100830 },
garciadeblas4568a372021-03-24 09:19:48 +0100831 "required": ["compute_node", "ports"],
832 },
tierno0f98af52018-03-19 10:28:22 +0100833}
834sdn_external_port_schema = {
835 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocd54a4a2018-09-12 16:40:35 +0200836 "title": "External port information",
tierno0f98af52018-03-19 10:28:22 +0100837 "type": "object",
838 "properties": {
839 "port": {"type": "string", "minLength": 1, "maxLength": 60},
840 "vlan": vlan_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100841 "mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100842 },
garciadeblas4568a372021-03-24 09:19:48 +0100843 "required": ["port"],
tierno0f98af52018-03-19 10:28:22 +0100844}
845
delacruzramofe598fe2019-10-23 18:25:11 +0200846# K8s Clusters
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500847k8scluster_deploy_method_schema = {
848 "$schema": "http://json-schema.org/draft-04/schema#",
849 "title": "Deployment methods for K8s cluster",
850 "type": "object",
851 "properties": {
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500852 "juju-bundle": {"type": "boolean"},
853 "helm-chart-v3": {"type": "boolean"},
854 },
855 "additionalProperties": False,
Luis Vega0a1efed2023-11-28 16:44:30 +0000856 "minProperties": 2,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500857}
delacruzramofe598fe2019-10-23 18:25:11 +0200858k8scluster_nets_schema = {
859 "title": "k8scluster nets input schema",
860 "$schema": "http://json-schema.org/draft-04/schema#",
861 "type": "object",
tierno8c81ab02020-02-07 10:18:30 +0000862 "patternProperties": {".": {"oneOf": [name_schema, null_schema]}},
delacruzramofe598fe2019-10-23 18:25:11 +0200863 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100864 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200865}
866k8scluster_new_schema = {
867 "title": "k8scluster creation input schema",
868 "$schema": "http://json-schema.org/draft-04/schema#",
869 "type": "object",
870 "properties": {
871 "schema_version": schema_version,
872 "schema_type": schema_type,
873 "name": name_schema,
874 "description": description_schema,
875 "credentials": object_schema,
876 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200877 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200878 "k8s_version": string_schema,
879 "nets": k8scluster_nets_schema,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500880 "deployment_methods": k8scluster_deploy_method_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200881 "namespace": name_schema,
882 "cni": nameshort_list_schema,
883 },
884 "required": ["name", "credentials", "vim_account", "k8s_version", "nets"],
garciadeblas4568a372021-03-24 09:19:48 +0100885 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200886}
887k8scluster_edit_schema = {
888 "title": "vim_account edit input schema",
889 "$schema": "http://json-schema.org/draft-04/schema#",
890 "type": "object",
891 "properties": {
892 "name": name_schema,
893 "description": description_schema,
894 "credentials": object_schema,
895 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200896 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200897 "k8s_version": string_schema,
898 "nets": k8scluster_nets_schema,
899 "namespace": name_schema,
900 "cni": nameshort_list_schema,
901 },
garciadeblas4568a372021-03-24 09:19:48 +0100902 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200903}
904
David Garciaecb41322021-03-31 19:10:46 +0200905# VCA
906vca_new_schema = {
907 "title": "vca creation input schema",
908 "$schema": "http://json-schema.org/draft-04/schema#",
909 "type": "object",
910 "properties": {
911 "schema_version": schema_version,
912 "schema_type": schema_type,
913 "name": name_schema,
914 "description": description_schema,
915 "endpoints": description_list_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100916 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200917 "secret": passwd_schema,
918 "cacert": long_description_schema,
919 "lxd-cloud": shortname_schema,
920 "lxd-credentials": shortname_schema,
921 "k8s-cloud": shortname_schema,
922 "k8s-credentials": shortname_schema,
923 "model-config": object_schema,
924 },
925 "required": [
926 "name",
927 "endpoints",
928 "user",
929 "secret",
930 "cacert",
931 "lxd-cloud",
932 "lxd-credentials",
933 "k8s-cloud",
934 "k8s-credentials",
935 ],
936 "additionalProperties": False,
937}
938vca_edit_schema = {
939 "title": "vca creation input schema",
940 "$schema": "http://json-schema.org/draft-04/schema#",
941 "type": "object",
942 "properties": {
943 "name": name_schema,
944 "description": description_schema,
945 "endpoints": description_list_schema,
946 "port": integer1_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100947 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200948 "secret": passwd_schema,
949 "cacert": long_description_schema,
950 "lxd-cloud": shortname_schema,
951 "lxd-credentials": shortname_schema,
952 "k8s-cloud": shortname_schema,
953 "k8s-credentials": shortname_schema,
954 "model-config": object_schema,
955 },
956 "additionalProperties": False,
957}
958
delacruzramofe598fe2019-10-23 18:25:11 +0200959# K8s Repos
tierno332e0802019-12-03 23:50:49 +0000960k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]}
delacruzramofe598fe2019-10-23 18:25:11 +0200961k8srepo_properties = {
962 "name": name_schema,
963 "description": description_schema,
964 "type": k8srepo_types,
965 "url": description_schema,
Luis Vegaf6574e32023-07-11 18:47:22 +0000966 "cacert": long_description_schema,
967 "user": string_schema,
968 "password": passwd_schema,
garciadeblasf3543892023-10-20 11:53:51 +0200969 "oci": bool_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200970}
971k8srepo_new_schema = {
972 "title": "k8scluster creation input schema",
973 "$schema": "http://json-schema.org/draft-04/schema#",
974 "type": "object",
975 "properties": k8srepo_properties,
976 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100977 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200978}
979k8srepo_edit_schema = {
980 "title": "vim_account edit input schema",
981 "$schema": "http://json-schema.org/draft-04/schema#",
982 "type": "object",
983 "properties": k8srepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100984 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200985}
986
Felipe Vicensb66b0412020-05-06 10:11:00 +0200987# OSM Repos
988osmrepo_types = {"enum": ["osm"]}
989osmrepo_properties = {
990 "name": name_schema,
991 "description": description_schema,
992 "type": osmrepo_types,
rshri2d386cb2024-07-05 14:35:51 +0000993 "url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100994 # "user": string_schema,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200995 # "password": passwd_schema
996}
997osmrepo_new_schema = {
998 "title": "osm repo creation input schema",
999 "$schema": "http://json-schema.org/draft-04/schema#",
1000 "type": "object",
1001 "properties": osmrepo_properties,
1002 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +01001003 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001004}
1005osmrepo_edit_schema = {
1006 "title": "osm repo edit input schema",
1007 "$schema": "http://json-schema.org/draft-04/schema#",
1008 "type": "object",
1009 "properties": osmrepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +01001010 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001011}
1012
tiernocb83c942018-09-24 17:28:13 +02001013# PDUs
1014pdu_interface = {
1015 "type": "object",
1016 "properties": {
tiernofd160572019-01-21 10:41:37 +00001017 "name": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001018 "mgmt": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001019 "type": {"enum": ["overlay", "underlay"]},
garciadeblas1a01e1f2021-10-26 17:27:35 +02001020 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernocb83c942018-09-24 17:28:13 +02001021 # TODO, add user, password, ssh-key
tierno36ec8602018-11-02 17:27:11 +01001022 "mac-address": mac_schema,
tiernofd160572019-01-21 10:41:37 +00001023 "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
1024 "vim-network-id": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001025 # # provide this in case SDN assist must deal with this interface
1026 # "switch-dpid": dpid_Schema,
tiernofd160572019-01-21 10:41:37 +00001027 # "switch-port": shortname_schema,
1028 # "switch-mac": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001029 # "switch-vlan": vlan_schema,
tiernocb83c942018-09-24 17:28:13 +02001030 },
tierno36ec8602018-11-02 17:27:11 +01001031 "required": ["name", "mgmt", "ip-address"],
garciadeblas4568a372021-03-24 09:19:48 +01001032 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001033}
tiernocb83c942018-09-24 17:28:13 +02001034pdu_new_schema = {
1035 "title": "pdu creation input schema",
1036 "$schema": "http://json-schema.org/draft-04/schema#",
1037 "type": "object",
1038 "properties": {
tiernofd160572019-01-21 10:41:37 +00001039 "name": shortname_schema,
1040 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001041 "description": description_schema,
1042 "shared": bool_schema,
1043 "vims": nameshort_list_schema,
1044 "vim_accounts": nameshort_list_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001045 "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1},
tiernocb83c942018-09-24 17:28:13 +02001046 },
1047 "required": ["name", "type", "interfaces"],
garciadeblas4568a372021-03-24 09:19:48 +01001048 "additionalProperties": False,
tiernocb83c942018-09-24 17:28:13 +02001049}
tiernocb83c942018-09-24 17:28:13 +02001050pdu_edit_schema = {
1051 "title": "pdu edit input schema",
1052 "$schema": "http://json-schema.org/draft-04/schema#",
1053 "type": "object",
1054 "properties": {
tiernofd160572019-01-21 10:41:37 +00001055 "name": shortname_schema,
1056 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001057 "description": description_schema,
1058 "shared": bool_schema,
garciadeblas84bdd552018-11-30 22:59:45 +01001059 "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
1060 "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
garciadeblas4568a372021-03-24 09:19:48 +01001061 "interfaces": {
1062 "oneOf": [
1063 array_edition_schema,
1064 {"type": "array", "items": pdu_interface, "minItems": 1},
1065 ]
1066 },
tiernocb83c942018-09-24 17:28:13 +02001067 },
1068 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001069 "minProperties": 1,
tiernocb83c942018-09-24 17:28:13 +02001070}
1071
delacruzramo271d2002019-12-02 21:00:37 +01001072# VNF PKG OPERATIONS
1073vnfpkgop_new_schema = {
1074 "title": "VNF PKG operation creation input schema",
1075 "$schema": "http://json-schema.org/draft-04/schema#",
1076 "type": "object",
1077 "properties": {
1078 "lcmOperationType": string_schema,
1079 "vnfPkgId": id_schema,
1080 "kdu_name": name_schema,
1081 "primitive": name_schema,
1082 "primitive_params": {"type": "object"},
1083 },
garciadeblas4568a372021-03-24 09:19:48 +01001084 "required": [
1085 "lcmOperationType",
1086 "vnfPkgId",
1087 "kdu_name",
1088 "primitive",
1089 "primitive_params",
1090 ],
1091 "additionalProperties": False,
delacruzramo271d2002019-12-02 21:00:37 +01001092}
1093
rshri2d386cb2024-07-05 14:35:51 +00001094clustercreation_new_schema = {
1095 "title": "cluster creation operation input schema",
1096 "$schema": "http://json-schema.org/draft-04/schema#",
1097 "type": "object",
1098 "properties": {
1099 "name": name_schema,
1100 "vim_account": string_schema,
1101 "k8s_version": string_schema,
1102 "node_size": string_schema,
1103 "node_count": integer0_schema,
rshri3d243162024-11-07 05:48:12 +00001104 "description": description_schema,
rshri2d386cb2024-07-05 14:35:51 +00001105 "region_name": string_schema,
1106 "resource_group": string_schema,
1107 "infra_controller_profiles": shortname_schema,
1108 "infra_config_profiles": shortname_schema,
1109 "resource_profiles": shortname_schema,
1110 "app_profiles": shortname_schema,
rshri3d243162024-11-07 05:48:12 +00001111 "created": string_schema,
1112 "state": string_schema,
1113 "operatingState": string_schema,
1114 "git_name": string_schema,
1115 "resourceState": string_schema,
1116 "bootstrap": bool_schema,
rshri2d386cb2024-07-05 14:35:51 +00001117 },
1118 "required": [
1119 "name",
1120 "vim_account",
1121 "k8s_version",
1122 "node_size",
1123 "node_count",
rshri2d386cb2024-07-05 14:35:51 +00001124 ],
1125 "additionalProperties": False,
1126}
rshri3d243162024-11-07 05:48:12 +00001127clusterregistration_new_schema = {
1128 "title": "cluster registration input schema",
1129 "$schema": "http://json-schema.org/draft-04/schema#",
1130 "type": "object",
1131 "properties": {
1132 "schema_version": schema_version,
1133 "schema_type": schema_type,
1134 "name": name_schema,
1135 "description": description_schema,
1136 "credentials": object_schema,
1137 "vim_account": string_schema,
1138 "bootstrap": bool_schema,
1139 },
1140 "required": ["name", "credentials", "vim_account"],
1141 "additionalProperties": False,
1142}
rshri2d386cb2024-07-05 14:35:51 +00001143
yshah4ad91e12024-11-18 07:05:29 +00001144cluster_edit_schema = {
1145 "title": "cluster edit schema",
1146 "$schema": "http://json-schema.org/draft-04/schema#",
1147 "type": "object",
1148 "properties": {
1149 "name": name_schema,
1150 "description": string_schema,
1151 },
1152 "additionalProperties": False,
1153}
1154
1155cluster_update_schema = {
1156 "title": "cluster update schema",
1157 "$schema": "http://json-schema.org/draft-04/schema#",
1158 "type": "object",
1159 "properties": {
1160 "k8s_version": string_schema,
1161 "node_size": string_schema,
1162 "node_count": integer0_schema,
1163 },
1164 "additionalProperties": True,
1165}
1166
rshri2d386cb2024-07-05 14:35:51 +00001167infra_controller_profile_create_new_schema = {
1168 "title": "infra profile creation operation input schema",
1169 "$schema": "http://json-schema.org/draft-04/schema#",
1170 "type": "object",
1171 "properties": {
1172 "name": name_schema,
1173 "description": string_schema,
1174 },
1175 "additionalProperties": False,
1176}
1177
1178infra_controller_profile_create_edit_schema = {
1179 "title": "infra profile creation operation input schema",
1180 "$schema": "http://json-schema.org/draft-04/schema#",
1181 "type": "object",
1182 "properties": {
1183 "name": name_schema,
1184 "description": string_schema,
1185 },
1186 "additionalProperties": False,
1187}
1188
1189infra_config_profile_create_new_schema = {
1190 "title": "infra profile creation operation input schema",
1191 "$schema": "http://json-schema.org/draft-04/schema#",
1192 "type": "object",
1193 "properties": {
1194 "name": name_schema,
1195 "description": string_schema,
1196 },
1197 "additionalProperties": False,
1198}
1199
1200infra_config_profile_create_edit_schema = {
1201 "title": "infra profile creation operation input schema",
1202 "$schema": "http://json-schema.org/draft-04/schema#",
1203 "type": "object",
1204 "properties": {
1205 "name": name_schema,
1206 "description": string_schema,
1207 },
1208 "additionalProperties": False,
1209}
1210
1211app_profile_create_new_schema = {
1212 "title": "app profile creation operation input schema",
1213 "$schema": "http://json-schema.org/draft-04/schema#",
1214 "type": "object",
1215 "properties": {
1216 "name": name_schema,
1217 "description": string_schema,
1218 },
1219 "additionalProperties": False,
1220}
1221app_profile_create_edit_schema = {
1222 "title": "app profile creation operation input schema",
1223 "$schema": "http://json-schema.org/draft-04/schema#",
1224 "type": "object",
1225 "properties": {
1226 "name": name_schema,
1227 "description": string_schema,
1228 },
1229 "additionalProperties": False,
1230}
1231
1232resource_profile_create_new_schema = {
1233 "title": "resource profile creation operation input schema",
1234 "$schema": "http://json-schema.org/draft-04/schema#",
1235 "type": "object",
1236 "properties": {
1237 "name": name_schema,
1238 "description": string_schema,
1239 },
1240 "additionalProperties": False,
1241}
1242resource_profile_create_edit_schema = {
1243 "title": "resource profile creation operation input schema",
1244 "$schema": "http://json-schema.org/draft-04/schema#",
1245 "type": "object",
1246 "properties": {
1247 "name": name_schema,
1248 "description": string_schema,
1249 },
1250 "additionalProperties": False,
1251}
1252
1253attach_profile = {
1254 "type": "array",
1255 "items": {
1256 "type": "object",
1257 "properties": {"id": id_schema},
1258 "additionalProperties": False,
1259 },
1260}
1261remove_profile = {
1262 "type": "array",
1263 "items": {
1264 "type": "object",
1265 "properties": {"id": id_schema},
1266 "additionalProperties": False,
1267 },
1268}
1269attach_dettach_profile_schema = {
1270 "title": "attach/dettach profiles",
1271 "$schema": "http://json-schema.org/draft-04/schema#",
1272 "type": "object",
1273 "properties": {
1274 "add_profile": attach_profile,
1275 "remove_profile": remove_profile,
1276 },
1277 "additionalProperties": False,
1278}
tiernocb83c942018-09-24 17:28:13 +02001279# USERS
tiernocf042d32019-06-13 09:06:40 +00001280project_role_mappings = {
1281 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001282 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001283 "type": "array",
1284 "items": {
1285 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001286 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001287 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001288 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001289 },
garciadeblas4568a372021-03-24 09:19:48 +01001290 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001291}
rshri2d386cb2024-07-05 14:35:51 +00001292
tiernocf042d32019-06-13 09:06:40 +00001293project_role_mappings_optional = {
1294 "title": "list of projects/roles or projects only",
1295 "$schema": "http://json-schema.org/draft-04/schema#",
1296 "type": "array",
1297 "items": {
1298 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001299 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001300 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001301 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001302 },
garciadeblas4568a372021-03-24 09:19:48 +01001303 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001304}
rshri2d386cb2024-07-05 14:35:51 +00001305
tiernocd54a4a2018-09-12 16:40:35 +02001306user_new_schema = {
1307 "$schema": "http://json-schema.org/draft-04/schema#",
1308 "title": "New user schema",
1309 "type": "object",
1310 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001311 "username": string_schema,
jegan2c4bf4e2024-06-04 12:05:19 +00001312 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001313 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001314 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001315 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001316 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001317 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001318 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001319 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001320}
1321user_edit_schema = {
1322 "$schema": "http://json-schema.org/draft-04/schema#",
1323 "title": "User edit schema for administrators",
1324 "type": "object",
1325 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001326 "password": user_passwd_schema,
jegan2c4bf4e2024-06-04 12:05:19 +00001327 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001328 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001329 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001330 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001331 "project_role_mappings": project_role_mappings,
1332 "add_project_role_mappings": project_role_mappings,
1333 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001334 "system_admin_id": id_schema,
1335 "unlock": bool_schema,
1336 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001337 },
1338 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001339 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001340}
1341
1342# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001343topics_with_quota = [
1344 "vnfds",
1345 "nsds",
1346 "slice_templates",
1347 "pduds",
1348 "ns_instances",
1349 "slice_instances",
1350 "vim_accounts",
1351 "wim_accounts",
1352 "sdn_controllers",
1353 "k8sclusters",
1354 "vca",
1355 "k8srepos",
1356 "osmrepos",
1357 "ns_subscriptions",
1358]
tiernocd54a4a2018-09-12 16:40:35 +02001359project_new_schema = {
1360 "$schema": "http://json-schema.org/draft-04/schema#",
1361 "title": "New project schema for administrators",
1362 "type": "object",
1363 "properties": {
tiernofd160572019-01-21 10:41:37 +00001364 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001365 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001366 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001367 "quotas": {
1368 "type": "object",
1369 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001370 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001371 },
tiernocd54a4a2018-09-12 16:40:35 +02001372 },
1373 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001374 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001375}
1376project_edit_schema = {
1377 "$schema": "http://json-schema.org/draft-04/schema#",
1378 "title": "Project edit schema for administrators",
1379 "type": "object",
1380 "properties": {
1381 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001382 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001383 "quotas": {
1384 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001385 "properties": {
1386 topic: {"oneOf": [integer0_schema, null_schema]}
1387 for topic in topics_with_quota
1388 },
1389 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001390 },
tiernocd54a4a2018-09-12 16:40:35 +02001391 },
1392 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001393 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001394}
1395
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001396# ROLES
1397roles_new_schema = {
1398 "$schema": "http://json-schema.org/draft-04/schema#",
1399 "title": "New role schema for administrators",
1400 "type": "object",
1401 "properties": {
1402 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001403 "permissions": {
1404 "type": "object",
1405 "patternProperties": {
1406 ".": bool_schema,
1407 },
1408 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001409 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001410 },
tierno1f029d82019-06-13 22:37:04 +00001411 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001412 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001413}
1414roles_edit_schema = {
1415 "$schema": "http://json-schema.org/draft-04/schema#",
1416 "title": "Roles edit schema for administrators",
1417 "type": "object",
1418 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001419 "name": shortname_schema,
1420 "permissions": {
1421 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001422 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001423 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001424 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001425 },
tierno1f029d82019-06-13 22:37:04 +00001426 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001427 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001428}
1429
tiernocd54a4a2018-09-12 16:40:35 +02001430# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001431
1432nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001433 "users": user_new_schema,
1434 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001435 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001436 "sdns": sdn_new_schema,
1437 "ns_instantiate": ns_instantiate,
1438 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001439 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001440 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001441 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001442 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001443}
1444
1445nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001446 "users": user_edit_schema,
1447 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001448 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001449 "sdns": sdn_edit_schema,
1450 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301451 "vnf": vnf_schema,
1452 "vld": vld_schema,
1453 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001454}
1455
Felipe Vicens07f31722018-10-29 15:16:44 +01001456# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001457nsi_subnet_instantiate = deepcopy(ns_instantiate)
1458nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1459nsi_subnet_instantiate["properties"]["id"] = name_schema
1460del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001461
1462nsi_vld_instantiate = {
1463 "title": "netslice vld instantiation params input schema",
1464 "$schema": "http://json-schema.org/draft-04/schema#",
1465 "type": "object",
1466 "properties": {
1467 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001468 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1469 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001470 "ip-profile": object_schema,
1471 },
delacruzramoc061f562019-04-05 11:00:02 +02001472 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001473 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001474}
1475
Felipe Vicens07f31722018-10-29 15:16:44 +01001476nsi_instantiate = {
1477 "title": "netslice action instantiate input schema",
1478 "$schema": "http://json-schema.org/draft-04/schema#",
1479 "type": "object",
1480 "properties": {
1481 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001482 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001483 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001484 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001485 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001486 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001487 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001488 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001489 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001490 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001491 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001492 "type": "array",
1493 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001494 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001495 },
garciadeblas4568a372021-03-24 09:19:48 +01001496 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001497 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001498 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001499 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001500}
1501
garciadeblas4568a372021-03-24 09:19:48 +01001502nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001503
garciadeblas4568a372021-03-24 09:19:48 +01001504nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001505
preethika.p329b8182020-04-22 12:25:39 +05301506nsinstancesubscriptionfilter_schema = {
1507 "title": "instance identifier schema",
1508 "$schema": "http://json-schema.org/draft-07/schema#",
1509 "type": "object",
1510 "properties": {
1511 "nsdIds": {"type": "array"},
1512 "vnfdIds": {"type": "array"},
1513 "pnfdIds": {"type": "array"},
1514 "nsInstanceIds": {"type": "array"},
1515 "nsInstanceNames": {"type": "array"},
1516 },
1517}
1518
1519nslcmsub_schema = {
1520 "title": "nslcmsubscription input schema",
1521 "$schema": "http://json-schema.org/draft-07/schema#",
1522 "type": "object",
1523 "properties": {
1524 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1525 "notificationTypes": {
1526 "type": "array",
1527 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001528 "enum": [
1529 "NsLcmOperationOccurrenceNotification",
1530 "NsChangeNotification",
1531 "NsIdentifierCreationNotification",
1532 "NsIdentifierDeletionNotification",
1533 ]
1534 },
preethika.p329b8182020-04-22 12:25:39 +05301535 },
1536 "operationTypes": {
1537 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001538 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301539 },
1540 "operationStates": {
1541 "type": "array",
1542 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001543 "enum": [
1544 "PROCESSING",
1545 "COMPLETED",
1546 "PARTIALLY_COMPLETED",
1547 "FAILED",
1548 "FAILED_TEMP",
1549 "ROLLING_BACK",
1550 "ROLLED_BACK",
1551 ]
1552 },
preethika.p329b8182020-04-22 12:25:39 +05301553 },
garciadeblas4568a372021-03-24 09:19:48 +01001554 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301555 "lcmOpNameImpactingNsComponent": {
1556 "type": "array",
1557 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001558 "enum": [
1559 "VNF_INSTANTIATE",
1560 "VNF_SCALE",
1561 "VNF_SCALE_TO_LEVEL",
1562 "VNF_CHANGE_FLAVOUR",
1563 "VNF_TERMINATE",
1564 "VNF_HEAL",
1565 "VNF_OPERATE",
1566 "VNF_CHANGE_EXT_CONN",
1567 "VNF_MODIFY_INFO",
1568 "NS_INSTANTIATE",
1569 "NS_SCALE",
1570 "NS_UPDATE",
1571 "NS_TERMINATE",
1572 "NS_HEAL",
1573 ]
1574 },
preethika.p329b8182020-04-22 12:25:39 +05301575 },
1576 "lcmOpOccStatusImpactingNsComponent": {
1577 "type": "array",
1578 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001579 "enum": [
1580 "START",
1581 "COMPLETED",
1582 "PARTIALLY_COMPLETED",
1583 "FAILED",
1584 "ROLLED_BACK",
1585 ]
1586 },
preethika.p329b8182020-04-22 12:25:39 +05301587 },
1588 },
1589 "allOf": [
1590 {
1591 "if": {
1592 "properties": {
1593 "notificationTypes": {
1594 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1595 }
1596 },
1597 },
1598 "then": {
1599 "anyOf": [
1600 {"required": ["operationTypes"]},
1601 {"required": ["operationStates"]},
1602 ]
garciadeblas4568a372021-03-24 09:19:48 +01001603 },
preethika.p329b8182020-04-22 12:25:39 +05301604 },
1605 {
1606 "if": {
1607 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001608 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301609 },
1610 },
1611 "then": {
1612 "anyOf": [
1613 {"required": ["nsComponentTypes"]},
1614 {"required": ["lcmOpNameImpactingNsComponent"]},
1615 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1616 ]
garciadeblas4568a372021-03-24 09:19:48 +01001617 },
1618 },
1619 ],
preethika.p329b8182020-04-22 12:25:39 +05301620}
1621
1622authentication_schema = {
1623 "title": "authentication schema for subscription",
1624 "$schema": "http://json-schema.org/draft-07/schema#",
1625 "type": "object",
1626 "properties": {
1627 "authType": {"enum": ["basic"]},
1628 "paramsBasic": {
1629 "type": "object",
1630 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001631 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301632 "password": passwd_schema,
1633 },
1634 },
1635 },
1636}
1637
1638subscription = {
1639 "title": "subscription input schema",
1640 "$schema": "http://json-schema.org/draft-07/schema#",
1641 "type": "object",
1642 "properties": {
1643 "filter": nslcmsub_schema,
1644 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001645 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301646 },
1647 "required": ["CallbackUri"],
1648}
1649
selvi.jf1004592022-04-29 05:42:35 +00001650vnflcmsub_schema = {
1651 "title": "vnflcmsubscription input schema",
1652 "$schema": "http://json-schema.org/draft-07/schema#",
1653 "type": "object",
1654 "properties": {
1655 "VnfInstanceSubscriptionFilter": {
1656 "type": "object",
1657 "properties": {
1658 "vnfdIds": {"type": "array"},
1659 "vnfInstanceIds": {"type": "array"},
1660 },
1661 },
1662 "notificationTypes": {
1663 "type": "array",
1664 "items": {
1665 "enum": [
1666 "VnfIdentifierCreationNotification",
1667 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001668 "VnfIdentifierDeletionNotification",
1669 ]
1670 },
selvi.jf1004592022-04-29 05:42:35 +00001671 },
1672 "operationTypes": {
1673 "type": "array",
1674 "items": {
1675 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001676 "INSTANTIATE",
1677 "SCALE",
1678 "SCALE_TO_LEVEL",
1679 "CHANGE_FLAVOUR",
1680 "TERMINATE",
1681 "HEAL",
1682 "OPERATE",
1683 "CHANGE_EXT_CONN",
1684 "MODIFY_INFO",
1685 "CREATE_SNAPSHOT",
1686 "REVERT_TO_SNAPSHOT",
1687 "CHANGE_VNFPKG",
1688 ]
1689 },
selvi.jf1004592022-04-29 05:42:35 +00001690 },
1691 "operationStates": {
1692 "type": "array",
1693 "items": {
1694 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001695 "STARTING",
1696 "PROCESSING",
1697 "COMPLETED",
1698 "FAILED_TEMP",
1699 "FAILED",
1700 "ROLLING_BACK",
1701 "ROLLED_BACK",
1702 ]
1703 },
1704 },
selvi.jf1004592022-04-29 05:42:35 +00001705 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001706 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1707}
selvi.jf1004592022-04-29 05:42:35 +00001708
1709vnf_subscription = {
1710 "title": "vnf subscription input schema",
1711 "$schema": "http://json-schema.org/draft-07/schema#",
1712 "type": "object",
1713 "properties": {
1714 "filter": vnflcmsub_schema,
1715 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001716 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001717 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001718 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001719}
1720
yshah53cc9eb2024-07-05 13:06:31 +00001721oka_schema = {
1722 "title": "Create OKA package input schema",
1723 "$schema": "http://json-schema.org/draft-07/schema#",
1724 "type": "object",
1725 "properties": {
1726 "name": name_schema,
1727 "description": description_schema,
garciadeblase073f552024-12-05 13:11:11 +01001728 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001729 },
1730 "additionalProperties": False,
1731}
1732
1733ksu_schema = {
1734 "title": "ksu schema",
1735 "$schema": "http://json-schema.org/draft-07/schema#",
1736 "type": "object",
1737 "properties": {
1738 "name": name_schema,
1739 "description": description_schema,
1740 "profile": {
1741 "type": "object",
1742 "properties": {
garciadeblase073f552024-12-05 13:11:11 +01001743 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001744 "_id": id_schema,
1745 },
1746 "additionalProperties": False,
1747 },
1748 "oka": {
1749 "type": "array",
1750 "items": {
1751 "type": "object",
1752 "properties": {
1753 "_id": id_schema,
1754 "sw_catalog_path": string_schema,
1755 "transformation": object_schema,
1756 },
1757 "additionalProperties": False,
1758 },
1759 },
1760 },
1761 "additionalProperties": False,
1762}
1763
tierno0f98af52018-03-19 10:28:22 +01001764
1765class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001766 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1767 self.http_code = http_code
1768 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001769
1770
tiernob24258a2018-10-04 18:39:49 +02001771def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001772 """
tiernocd54a4a2018-09-12 16:40:35 +02001773 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001774 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001775 :param schema_to_use: jsonschema to test
1776 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001777 """
1778 try:
tierno0f98af52018-03-19 10:28:22 +01001779 if schema_to_use:
1780 js_v(indata, schema_to_use)
1781 return None
1782 except js_e.ValidationError as e:
1783 if e.path:
tierno0da52252018-06-27 15:47:22 +02001784 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001785 else:
1786 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001787 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001788 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001789 raise ValidationError(
1790 "Bad json schema {}".format(schema_to_use),
1791 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1792 )
delacruzramoc061f562019-04-05 11:00:02 +02001793
1794
1795def is_valid_uuid(x):
1796 """
1797 Test for a valid UUID
1798 :param x: string to test
1799 :return: True if x is a valid uuid, False otherwise
1800 """
1801 try:
1802 if UUID(x):
1803 return True
tiernobdebce92019-07-01 15:36:49 +00001804 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001805 return False