blob: 0ba0a5fdcedc42e3e524a3d38c1aa3a6bd7c82ad [file] [log] [blame]
tierno0f98af52018-03-19 10:28:22 +01001# -*- coding: utf-8 -*-
2
tiernod125caf2018-11-22 16:05:54 +00003# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
tierno0f98af52018-03-19 10:28:22 +010016from jsonschema import validate as js_v, exceptions as js_e
tierno36ec8602018-11-02 17:27:11 +010017from http import HTTPStatus
garciadeblasdaf8cc52018-11-30 14:17:20 +010018from copy import deepcopy
garciadeblas4568a372021-03-24 09:19:48 +010019from uuid import UUID # To test for valid UUID
tierno0f98af52018-03-19 10:28:22 +010020
21__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
22__version__ = "0.1"
23version_date = "Mar 2018"
24
25"""
26Validator of input data using JSON schemas for those items that not contains an OSM yang information model
27"""
28
29# Basis schemas
30patern_name = "^[ -~]+$"
garciadeblas4568a372021-03-24 09:19:48 +010031shortname_schema = {
32 "type": "string",
33 "minLength": 1,
34 "maxLength": 60,
35 "pattern": "^[^,;()\\.\\$'\"]+$",
36}
tierno0f98af52018-03-19 10:28:22 +010037passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60}
garciadeblas6d83f8f2023-06-19 22:34:49 +020038user_passwd_schema = {
39 "type": "string",
40 "pattern": "^.*(?=.{8,})((?=.*[!@#$%^&*()\\-_=+{};:,<.>]){1})(?=.*\\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$",
41}
garciadeblas4568a372021-03-24 09:19:48 +010042name_schema = {
43 "type": "string",
44 "minLength": 1,
45 "maxLength": 255,
46 "pattern": "^[^,;()'\"]+$",
47}
tierno0da52252018-06-27 15:47:22 +020048string_schema = {"type": "string", "minLength": 1, "maxLength": 255}
jeganbe1a3df2024-06-04 12:05:19 +000049email_schema = {
50 "type": "string",
51 "minLength": 1,
52 "maxLength": 320,
53 "pattern": "^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$",
54}
garciadeblas4568a372021-03-24 09:19:48 +010055xml_text_schema = {
56 "type": "string",
57 "minLength": 1,
58 "maxLength": 1000,
59 "pattern": "^[^']+$",
60}
61description_schema = {
62 "type": ["string", "null"],
63 "maxLength": 255,
64 "pattern": "^[^'\"]+$",
65}
66long_description_schema = {
67 "type": ["string", "null"],
68 "maxLength": 3000,
69 "pattern": "^[^'\"]+$",
70}
tierno441dbbf2018-07-10 12:52:48 +020071id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36}
72bool_schema = {"type": "boolean"}
73null_schema = {"type": "null"}
tierno2236d202018-05-16 19:05:16 +020074# "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
garciadeblas4568a372021-03-24 09:19:48 +010075id_schema = {
76 "type": "string",
77 "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$",
78}
79time_schema = {
80 "type": "string",
81 "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}",
82}
83pci_schema = {
84 "type": "string",
85 "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$",
86}
tierno42fce592018-11-02 09:23:43 +010087# allows [] for wildcards. For that reason huge length limit is set
88pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\\[\\]]{12,40}$"}
K Sai Kiran990ac462020-05-20 12:25:12 +053089http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"}
tierno0f98af52018-03-19 10:28:22 +010090bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"}
91memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"}
92integer0_schema = {"type": "integer", "minimum": 0}
93integer1_schema = {"type": "integer", "minimum": 1}
tierno87006042018-10-24 12:50:20 +020094path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"}
tierno0f98af52018-03-19 10:28:22 +010095vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095}
96vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095}
garciadeblas4568a372021-03-24 09:19:48 +010097mac_schema = {
98 "type": "string",
99 "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$",
100} # must be unicast: LSB bit of MSB byte ==0
tiernocb83c942018-09-24 17:28:13 +0200101dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"}
tierno0f98af52018-03-19 10:28:22 +0100102# mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
garciadeblas4568a372021-03-24 09:19:48 +0100103ip_schema = {
104 "type": "string",
105 "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
106}
garciadeblas1a01e1f2021-10-26 17:27:35 +0200107ipv6_schema = {
108 "type": "string",
garciadeblasf2af4a12023-01-24 16:56:54 +0100109 "pattern": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))", # noqa: W605
garciadeblas1a01e1f2021-10-26 17:27:35 +0200110}
garciadeblas4568a372021-03-24 09:19:48 +0100111ip_prefix_schema = {
112 "type": "string",
113 "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
114 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$",
115}
tierno0f98af52018-03-19 10:28:22 +0100116port_schema = {"type": "integer", "minimum": 1, "maximum": 65534}
117object_schema = {"type": "object"}
118schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2}
119# schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
garciadeblas4568a372021-03-24 09:19:48 +0100120log_level_schema = {
121 "type": "string",
122 "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
123}
tierno0f98af52018-03-19 10:28:22 +0100124checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"}
125size_schema = {"type": "integer", "minimum": 1, "maximum": 100}
tiernocd54a4a2018-09-12 16:40:35 +0200126array_edition_schema = {
127 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100128 "patternProperties": {"^\\$": {}},
tiernocd54a4a2018-09-12 16:40:35 +0200129 "additionalProperties": False,
130 "minProperties": 1,
131}
tiernocb83c942018-09-24 17:28:13 +0200132nameshort_list_schema = {
133 "type": "array",
134 "minItems": 1,
tiernofd160572019-01-21 10:41:37 +0000135 "items": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +0200136}
tiernocd54a4a2018-09-12 16:40:35 +0200137
David Garciaecb41322021-03-31 19:10:46 +0200138description_list_schema = {
139 "type": "array",
140 "minItems": 1,
141 "items": description_schema,
142}
tierno0f98af52018-03-19 10:28:22 +0100143
garciadeblas3fb820d2024-12-05 13:11:11 +0100144profile_type_schema = {
145 "type": "string",
146 "enum": [
147 "infra_controller_profiles",
148 "infra_config_profiles",
149 "app_profiles",
150 "resource_profiles",
151 ],
152}
153
tierno441dbbf2018-07-10 12:52:48 +0200154ns_instantiate_vdu = {
155 "title": "ns action instantiate input schema for vdu",
156 "$schema": "http://json-schema.org/draft-04/schema#",
157 "type": "object",
158 "properties": {
159 "id": name_schema,
Gabriel Cubae88401b2023-04-05 15:24:52 -0500160 "vim-flavor-id": name_schema,
kayal20016a3bce72024-06-27 11:14:59 +0530161 "instance_name": name_schema,
kayal2001b16cf252024-11-28 10:47:32 +0530162 "vim-flavor-name": name_schema,
tierno441dbbf2018-07-10 12:52:48 +0200163 "volume": {
164 "type": "array",
165 "minItems": 1,
166 "items": {
167 "type": "object",
168 "properties": {
169 "name": name_schema,
170 "vim-volume-id": name_schema,
171 },
172 "required": ["name", "vim-volume-id"],
garciadeblas4568a372021-03-24 09:19:48 +0100173 "additionalProperties": False,
174 },
tierno441dbbf2018-07-10 12:52:48 +0200175 },
176 "interface": {
177 "type": "array",
178 "minItems": 1,
179 "items": {
180 "type": "object",
181 "properties": {
182 "name": name_schema,
garciadeblas9fb32712022-04-04 16:33:59 +0200183 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200184 "mac-address": mac_schema,
185 "floating-ip-required": bool_schema,
186 },
187 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +0100188 "additionalProperties": False,
189 },
190 },
tierno441dbbf2018-07-10 12:52:48 +0200191 },
192 "required": ["id"],
garciadeblas4568a372021-03-24 09:19:48 +0100193 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200194}
195
196ip_profile_dns_schema = {
197 "type": "array",
198 "minItems": 1,
199 "items": {
200 "type": "object",
201 "properties": {
garciadeblas9fb32712022-04-04 16:33:59 +0200202 "address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200203 },
204 "required": ["address"],
garciadeblas4568a372021-03-24 09:19:48 +0100205 "additionalProperties": False,
206 },
tierno441dbbf2018-07-10 12:52:48 +0200207}
208
209ip_profile_dhcp_schema = {
210 "type": "object",
211 "properties": {
212 "enabled": {"type": "boolean"},
213 "count": integer1_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100214 "start-address": ip_schema,
tierno441dbbf2018-07-10 12:52:48 +0200215 },
216 "additionalProperties": False,
217}
218
219ip_profile_schema = {
tierno2a929042020-03-10 16:34:25 +0000220 "title": "ip profile validation schema",
tierno441dbbf2018-07-10 12:52:48 +0200221 "$schema": "http://json-schema.org/draft-04/schema#",
222 "type": "object",
223 "properties": {
224 "ip-version": {"enum": ["ipv4", "ipv6"]},
tierno441dbbf2018-07-10 12:52:48 +0200225 "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]},
226 "gateway-address": {"oneOf": [null_schema, ip_schema]},
227 "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200228 "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]},
229 },
garciadeblas4568a372021-03-24 09:19:48 +0100230 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200231}
232
kbsub21f03f52019-10-17 16:26:56 +0000233provider_network_schema = {
tierno2a929042020-03-10 16:34:25 +0000234 "title": "provider network validation schema",
kbsub21f03f52019-10-17 16:26:56 +0000235 "$schema": "http://json-schema.org/draft-04/schema#",
236 "type": "object",
237 "properties": {
238 "physical-network": name_schema,
239 "segmentation-id": name_schema,
tierno2a929042020-03-10 16:34:25 +0000240 "sdn-ports": { # external ports to append to the SDN-assist network
241 "type": "array",
242 "items": {
243 "type": "object",
244 "properties": {
245 "switch_id": shortname_schema,
246 "switch_port": shortname_schema,
247 "mac_address": mac_schema,
248 "vlan": vlan_schema,
249 },
garciadeblas4568a372021-03-24 09:19:48 +0100250 "additionalProperties": True,
251 },
tierno2a929042020-03-10 16:34:25 +0000252 },
253 "network-type": shortname_schema,
kbsub21f03f52019-10-17 16:26:56 +0000254 },
garciadeblas4568a372021-03-24 09:19:48 +0100255 "additionalProperties": True,
kbsub21f03f52019-10-17 16:26:56 +0000256}
257
tierno441dbbf2018-07-10 12:52:48 +0200258ns_instantiate_internal_vld = {
garciadeblas9fb32712022-04-04 16:33:59 +0200259 "title": "ns action instantiate input schema for vld",
tierno441dbbf2018-07-10 12:52:48 +0200260 "$schema": "http://json-schema.org/draft-04/schema#",
261 "type": "object",
262 "properties": {
263 "name": name_schema,
264 "vim-network-name": name_schema,
gcalvino17d5b732018-12-17 16:26:21 +0100265 "vim-network-id": name_schema,
garciadeblas120105b2023-02-22 16:52:24 +0100266 "ip-profile": ip_profile_schema,
kbsub21f03f52019-10-17 16:26:56 +0000267 "provider-network": provider_network_schema,
tierno441dbbf2018-07-10 12:52:48 +0200268 "internal-connection-point": {
269 "type": "array",
270 "minItems": 1,
271 "items": {
272 "type": "object",
273 "properties": {
274 "id-ref": name_schema,
275 "ip-address": ip_schema,
tiernob7c6f2a2018-09-03 14:32:10 +0200276 # "mac-address": mac_schema,
tierno441dbbf2018-07-10 12:52:48 +0200277 },
tiernob7c6f2a2018-09-03 14:32:10 +0200278 "required": ["id-ref"],
279 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100280 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200281 },
garciadeblas4568a372021-03-24 09:19:48 +0100282 },
tierno441dbbf2018-07-10 12:52:48 +0200283 },
284 "required": ["name"],
285 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100286 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200287}
tierno65acb4d2018-04-06 16:42:40 +0200288
tiernofd160572019-01-21 10:41:37 +0000289additional_params_for_vnf = {
290 "type": "array",
291 "items": {
292 "type": "object",
293 "properties": {
294 "member-vnf-index": name_schema,
295 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000296 "k8s-namespace": name_schema,
tiernof62ac6a2020-04-29 13:46:13 +0000297 "config-units": integer1_schema, # number of configuration units of this vnf, by default 1
tierno714954e2019-11-29 13:43:26 +0000298 "additionalParamsForVdu": {
299 "type": "array",
300 "items": {
301 "type": "object",
302 "properties": {
303 "vdu_id": name_schema,
304 "additionalParams": object_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100305 "config-units": integer1_schema, # number of configuration units of this vdu, by default 1
tierno714954e2019-11-29 13:43:26 +0000306 },
tiernof62ac6a2020-04-29 13:46:13 +0000307 "required": ["vdu_id"],
308 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000309 "additionalProperties": False,
310 },
311 },
312 "additionalParamsForKdu": {
313 "type": "array",
314 "items": {
315 "type": "object",
316 "properties": {
317 "kdu_name": name_schema,
318 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000319 "kdu_model": name_schema,
320 "k8s-namespace": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100321 "config-units": integer1_schema, # number of configuration units of this knf, by default 1
romeromonserbfebfc02021-05-28 10:51:35 +0200322 "kdu-deployment-name": name_schema,
tierno714954e2019-11-29 13:43:26 +0000323 },
tierno54db2e42020-04-06 15:29:42 +0000324 "required": ["kdu_name"],
325 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000326 "additionalProperties": False,
327 },
328 },
Alexis Romeroee31f532022-04-26 19:10:21 +0200329 "affinity-or-anti-affinity-group": {
330 "type": "array",
331 "items": {
332 "type": "object",
333 "properties": {
334 "id": name_schema,
335 "vim-affinity-group-id": name_schema,
336 },
337 "required": ["id"],
338 "minProperties": 2,
339 "additionalProperties": False,
340 },
341 },
tiernofd160572019-01-21 10:41:37 +0000342 },
tierno714954e2019-11-29 13:43:26 +0000343 "required": ["member-vnf-index"],
344 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100345 "additionalProperties": False,
346 },
tiernofd160572019-01-21 10:41:37 +0000347}
348
kayal2001f71c2e82024-06-25 15:26:24 +0530349vnf_schema = {
350 "type": "array",
351 "minItems": 1,
352 "items": {
353 "type": "object",
354 "properties": {
355 "member-vnf-index": name_schema,
356 "vimAccountId": id_schema,
357 "vdu": {
358 "type": "array",
359 "minItems": 1,
360 "items": ns_instantiate_vdu,
361 },
362 "internal-vld": {
363 "type": "array",
364 "minItems": 1,
365 "items": ns_instantiate_internal_vld,
366 },
367 },
368 "required": ["member-vnf-index"],
369 "minProperties": 2,
370 "additionalProperties": False,
371 },
372}
373
374vld_schema = {
375 "type": "array",
376 "minItems": 1,
377 "items": {
378 "type": "object",
379 "properties": {
380 "name": string_schema,
381 "vim-network-name": {"oneOf": [string_schema, object_schema]},
382 "vim-network-id": {"oneOf": [string_schema, object_schema]},
383 "ns-net": object_schema,
384 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
385 "ip-profile": ip_profile_schema,
386 "provider-network": provider_network_schema,
387 "vnfd-connection-point-ref": {
388 "type": "array",
389 "minItems": 1,
390 "items": {
391 "type": "object",
392 "properties": {
393 "member-vnf-index-ref": name_schema,
394 "vnfd-connection-point-ref": name_schema,
395 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
396 # "mac-address": mac_schema,
397 },
398 "required": [
399 "member-vnf-index-ref",
400 "vnfd-connection-point-ref",
401 ],
402 "minProperties": 3,
403 "additionalProperties": False,
404 },
405 },
406 },
407 "required": ["name"],
408 "additionalProperties": False,
409 },
410}
411
412ns_config_template = {
413 "title": " ns config template input schema",
414 "$schema": "http://json-schema.org/draft-04/schema#",
415 "type": "object",
416 "properties": {
417 "name": string_schema,
418 "nsdId": id_schema,
419 "config": object_schema,
420 },
421 "required": ["name", "nsdId", "config"],
422 "additionalProperties": False,
423}
424
tierno65acb4d2018-04-06 16:42:40 +0200425ns_instantiate = {
426 "title": "ns action instantiate input schema",
427 "$schema": "http://json-schema.org/draft-04/schema#",
428 "type": "object",
tierno0da52252018-06-27 15:47:22 +0200429 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200430 "lcmOperationType": string_schema,
431 "nsInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +0100432 "netsliceInstanceId": id_schema,
tierno0da52252018-06-27 15:47:22 +0200433 "nsName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +0000434 "nsDescription": {"oneOf": [description_schema, null_schema]},
tierno0da52252018-06-27 15:47:22 +0200435 "nsdId": id_schema,
436 "vimAccountId": id_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530437 "nsConfigTemplateId": id_schema,
tierno195a36c2020-09-18 14:18:55 +0000438 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
magnussonlf318b302020-01-20 18:38:18 +0100439 "placement-engine": string_schema,
440 "placement-constraints": object_schema,
tiernobee085c2018-12-12 17:03:04 +0000441 "additionalParamsForNs": object_schema,
tiernofd160572019-01-21 10:41:37 +0000442 "additionalParamsForVnf": additional_params_for_vnf,
garciadeblas4568a372021-03-24 09:19:48 +0100443 "config-units": integer1_schema, # number of configuration units of this ns, by default 1
tierno54db2e42020-04-06 15:29:42 +0000444 "k8s-namespace": name_schema,
tiernofc5089c2018-10-31 09:28:11 +0100445 "ssh_keys": {"type": "array", "items": {"type": "string"}},
tiernoa8186a52020-01-14 15:54:48 +0000446 "timeout_ns_deploy": integer1_schema,
tierno441dbbf2018-07-10 12:52:48 +0200447 "nsr_id": id_schema,
tiernocc103432018-10-19 14:10:35 +0200448 "vduImage": name_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530449 "vnf": vnf_schema,
450 "vld": vld_schema,
tierno0da52252018-06-27 15:47:22 +0200451 },
tierno441dbbf2018-07-10 12:52:48 +0200452 "required": ["nsName", "nsdId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +0100453 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200454}
tierno0da52252018-06-27 15:47:22 +0200455
tierno1c38f2f2020-03-24 11:51:39 +0000456ns_terminate = {
457 "title": "ns terminate input schema",
458 "$schema": "http://json-schema.org/draft-04/schema#",
459 "type": "object",
460 "properties": {
461 "lcmOperationType": string_schema,
462 "nsInstanceId": id_schema,
463 "autoremove": bool_schema,
464 "timeout_ns_terminate": integer1_schema,
465 "skip_terminate_primitives": bool_schema,
tierno0b8752f2020-05-12 09:42:02 +0000466 "netsliceInstanceId": id_schema,
tierno1c38f2f2020-03-24 11:51:39 +0000467 },
garciadeblas4568a372021-03-24 09:19:48 +0100468 "additionalProperties": False,
tierno1c38f2f2020-03-24 11:51:39 +0000469}
470
aticig544a2ae2022-04-05 09:00:17 +0300471ns_update = {
472 "title": "ns update input schema",
473 "$schema": "http://json-schema.org/draft-04/schema#",
474 "type": "object",
475 "properties": {
476 "lcmOperationType": string_schema,
477 "nsInstanceId": id_schema,
garciadeblaseab15072022-05-19 10:31:52 +0200478 "timeout_ns_update": integer1_schema,
aticig544a2ae2022-04-05 09:00:17 +0300479 "updateType": {
garciadeblasf2af4a12023-01-24 16:56:54 +0100480 "enum": [
481 "CHANGE_VNFPKG",
482 "REMOVE_VNF",
483 "MODIFY_VNF_INFORMATION",
484 "OPERATE_VNF",
Rahul Kumara30391b2024-05-24 14:40:23 +0530485 "VERTICAL_SCALE",
garciadeblasf2af4a12023-01-24 16:56:54 +0100486 ]
aticig544a2ae2022-04-05 09:00:17 +0300487 },
488 "modifyVnfInfoData": {
489 "type": "object",
490 "properties": {
491 "vnfInstanceId": id_schema,
492 "vnfdId": id_schema,
493 },
494 "required": ["vnfInstanceId", "vnfdId"],
495 },
496 "removeVnfInstanceId": id_schema,
497 "changeVnfPackageData": {
498 "type": "object",
499 "properties": {
500 "vnfInstanceId": id_schema,
501 "vnfdId": id_schema,
502 },
503 "required": ["vnfInstanceId", "vnfdId"],
504 },
k4.rahule3dca382022-04-29 12:30:36 +0000505 "operateVnfData": {
506 "type": "object",
507 "properties": {
508 "vnfInstanceId": id_schema,
509 "changeStateTo": name_schema,
510 "additionalParam": {
511 "type": "object",
512 "properties": {
513 "run-day1": bool_schema,
514 "vdu_id": name_schema,
515 "count-index": integer0_schema,
516 },
517 "required": ["vdu_id", "count-index"],
518 "additionalProperties": False,
garciadeblasf2af4a12023-01-24 16:56:54 +0100519 },
k4.rahule3dca382022-04-29 12:30:36 +0000520 },
521 "required": ["vnfInstanceId", "changeStateTo"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100522 },
Rahul Kumara30391b2024-05-24 14:40:23 +0530523 "verticalScaleVnf": {
524 "type": "object",
525 "properties": {
526 "vnfInstanceId": id_schema,
527 "vnfdId": id_schema,
528 "vduId": name_schema,
529 "countIndex": integer0_schema,
530 },
531 "required": ["vnfInstanceId", "vnfdId", "vduId"],
532 },
aticig544a2ae2022-04-05 09:00:17 +0300533 },
534 "required": ["updateType"],
535 "additionalProperties": False,
536}
537
garciadeblas4568a372021-03-24 09:19:48 +0100538ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
tiernof759d822018-06-11 18:54:54 +0200539 "title": "ns action input schema",
tierno65acb4d2018-04-06 16:42:40 +0200540 "$schema": "http://json-schema.org/draft-04/schema#",
541 "type": "object",
542 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200543 "lcmOperationType": string_schema,
544 "nsInstanceId": id_schema,
tiernof5298be2018-05-16 14:43:57 +0200545 "member_vnf_index": name_schema,
546 "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future
tierno7ce1db92018-07-25 12:50:52 +0200547 "vdu_id": name_schema,
tiernof0637052019-03-07 16:26:47 +0000548 "vdu_count_index": integer0_schema,
tierno9cb7d672019-10-30 12:13:48 +0000549 "kdu_name": name_schema,
tierno65acb4d2018-04-06 16:42:40 +0200550 "primitive": name_schema,
tierno50c8e6e2020-04-02 15:40:12 +0000551 "timeout_ns_action": integer1_schema,
tierno65acb4d2018-04-06 16:42:40 +0200552 "primitive_params": {"type": "object"},
553 },
garciadeblas4568a372021-03-24 09:19:48 +0100554 "required": ["primitive", "primitive_params"], # TODO add member_vnf_index
555 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200556}
garciadeblas0964edf2022-02-11 00:43:44 +0100557
garciadeblas4568a372021-03-24 09:19:48 +0100558ns_scale = { # TODO for the moment it is only VDU-scaling
tiernof759d822018-06-11 18:54:54 +0200559 "title": "ns scale input schema",
560 "$schema": "http://json-schema.org/draft-04/schema#",
561 "type": "object",
562 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200563 "lcmOperationType": string_schema,
564 "nsInstanceId": id_schema,
tiernof759d822018-06-11 18:54:54 +0200565 "scaleType": {"enum": ["SCALE_VNF"]},
tierno50c8e6e2020-04-02 15:40:12 +0000566 "timeout_ns_scale": integer1_schema,
tiernof759d822018-06-11 18:54:54 +0200567 "scaleVnfData": {
568 "type": "object",
569 "properties": {
570 "vnfInstanceId": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100571 "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]},
tiernof759d822018-06-11 18:54:54 +0200572 "scaleByStepData": {
573 "type": "object",
574 "properties": {
575 "scaling-group-descriptor": name_schema,
576 "member-vnf-index": name_schema,
577 "scaling-policy": name_schema,
578 },
579 "required": ["scaling-group-descriptor", "member-vnf-index"],
garciadeblas4568a372021-03-24 09:19:48 +0100580 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200581 },
582 },
583 "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId
garciadeblas4568a372021-03-24 09:19:48 +0100584 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200585 },
586 "scaleTime": time_schema,
587 },
588 "required": ["scaleType", "scaleVnfData"],
garciadeblas4568a372021-03-24 09:19:48 +0100589 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200590}
tierno65acb4d2018-04-06 16:42:40 +0200591
elumalai8e3806c2022-04-28 17:26:24 +0530592ns_migrate = {
593 "title": "ns migrate input schema",
594 "$schema": "http://json-schema.org/draft-04/schema#",
595 "type": "object",
596 "properties": {
597 "lcmOperationType": string_schema,
598 "nsInstanceId": id_schema,
599 "vnfInstanceId": id_schema,
600 "migrateToHost": string_schema,
601 "vdu": {
602 "type": "object",
garciadeblasf2af4a12023-01-24 16:56:54 +0100603 "properties": {
604 "vduId": name_schema,
605 "vduCountIndex": integer0_schema,
606 },
607 "required": ["vduId"],
608 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530609 },
610 },
611 "required": ["vnfInstanceId"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100612 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530613}
tierno65acb4d2018-04-06 16:42:40 +0200614
garciadeblas0964edf2022-02-11 00:43:44 +0100615ns_heal = {
616 "title": "ns heal input schema",
617 "$schema": "http://json-schema.org/draft-04/schema#",
618 "type": "object",
619 "properties": {
620 "lcmOperationType": string_schema,
621 "nsInstanceId": id_schema,
622 "timeout_ns_heal": integer1_schema,
623 "healVnfData": {
624 "type": "array",
625 "items": {
626 "type": "object",
627 "properties": {
628 "vnfInstanceId": id_schema,
629 "cause": description_schema,
630 "additionalParams": {
631 "type": "object",
632 "properties": {
633 "run-day1": bool_schema,
634 "vdu": {
635 "type": "array",
636 "items": {
637 "type": "object",
638 "properties": {
639 "run-day1": bool_schema,
640 "vdu-id": name_schema,
641 "count-index": integer0_schema,
642 },
643 "required": ["vdu-id"],
644 "additionalProperties": False,
645 },
646 },
647 },
648 "additionalProperties": False,
649 },
650 },
651 "required": ["vnfInstanceId"],
652 "additionalProperties": False,
653 },
654 },
655 },
656 "required": ["healVnfData"],
657 "additionalProperties": False,
658}
659
Gabriel Cuba84a60df2023-10-30 14:01:54 -0500660nslcmop_cancel = {
661 "title": "Cancel nslcmop input schema",
662 "$schema": "http://json-schema.org/draft-04/schema#",
663 "type": "object",
664 "properties": {
665 "nsLcmOpOccId": id_schema,
666 "cancelMode": {
667 "enum": [
668 "GRACEFUL",
669 "FORCEFUL",
670 ]
671 },
672 },
673 "required": ["cancelMode"],
674 "additionalProperties": False,
675}
676
tierno0f98af52018-03-19 10:28:22 +0100677schema_version = {"type": "string", "enum": ["1.0"]}
tierno55ba2e62018-12-11 17:22:22 +0000678schema_type = {"type": "string"}
tiernob3d0a0e2019-11-13 15:57:51 +0000679vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200680
tierno09c073e2018-04-26 13:36:48 +0200681vim_account_edit_schema = {
682 "title": "vim_account edit input schema",
683 "$schema": "http://json-schema.org/draft-04/schema#",
684 "type": "object",
685 "properties": {
686 "name": name_schema,
687 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200688 "vim": name_schema,
689 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200690 "vim_type": vim_type,
tierno09c073e2018-04-26 13:36:48 +0200691 "vim_url": description_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200692 # "vim_url_admin": description_schema,
693 # "vim_tenant": name_schema,
tierno09c073e2018-04-26 13:36:48 +0200694 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200695 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200696 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200697 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100698 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000699 "prometheus-config": {"type": "object"},
tierno09c073e2018-04-26 13:36:48 +0200700 },
garciadeblas4568a372021-03-24 09:19:48 +0100701 "additionalProperties": False,
tierno09c073e2018-04-26 13:36:48 +0200702}
tierno0f98af52018-03-19 10:28:22 +0100703
tierno09c073e2018-04-26 13:36:48 +0200704vim_account_new_schema = {
705 "title": "vim_account creation input schema",
tierno0f98af52018-03-19 10:28:22 +0100706 "$schema": "http://json-schema.org/draft-04/schema#",
707 "type": "object",
708 "properties": {
709 "schema_version": schema_version,
710 "schema_type": schema_type,
711 "name": name_schema,
712 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200713 "vim": name_schema,
714 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200715 "vim_type": vim_type,
tierno0f98af52018-03-19 10:28:22 +0100716 "vim_url": description_schema,
717 # "vim_url_admin": description_schema,
718 # "vim_tenant": name_schema,
719 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200720 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200721 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200722 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100723 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000724 "prometheus-config": {"type": "object"},
tierno0f98af52018-03-19 10:28:22 +0100725 },
garciadeblas4568a372021-03-24 09:19:48 +0100726 "required": [
727 "name",
728 "vim_url",
729 "vim_type",
730 "vim_user",
731 "vim_password",
732 "vim_tenant_name",
733 ],
734 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100735}
tierno0f98af52018-03-19 10:28:22 +0100736
tierno85807722019-12-20 14:11:35 +0000737wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200738
tierno55ba2e62018-12-11 17:22:22 +0000739wim_account_edit_schema = {
740 "title": "wim_account edit input schema",
741 "$schema": "http://json-schema.org/draft-04/schema#",
742 "type": "object",
743 "properties": {
744 "name": name_schema,
745 "description": description_schema,
tierno55ba2e62018-12-11 17:22:22 +0000746 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200747 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000748 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100749 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000750 "password": passwd_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100751 "config": {"type": "object"},
tierno55ba2e62018-12-11 17:22:22 +0000752 },
garciadeblas4568a372021-03-24 09:19:48 +0100753 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000754}
755
756wim_account_new_schema = {
757 "title": "wim_account creation input schema",
758 "$schema": "http://json-schema.org/draft-04/schema#",
759 "type": "object",
760 "properties": {
761 "schema_version": schema_version,
762 "schema_type": schema_type,
763 "name": name_schema,
764 "description": description_schema,
765 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200766 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000767 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100768 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000769 "password": passwd_schema,
tiernof0637052019-03-07 16:26:47 +0000770 "config": {
771 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100772 "patternProperties": {".": {"not": {"type": "null"}}},
773 },
tierno55ba2e62018-12-11 17:22:22 +0000774 },
775 "required": ["name", "wim_url", "wim_type"],
garciadeblas4568a372021-03-24 09:19:48 +0100776 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000777}
tierno0f98af52018-03-19 10:28:22 +0100778
779sdn_properties = {
780 "name": name_schema,
tierno7adaeb02019-12-17 16:46:12 +0000781 "type": {"type": "string"},
782 "url": {"type": "string"},
sousaedu80b6fed2021-10-07 15:17:32 +0100783 "user": string_schema,
tierno7adaeb02019-12-17 16:46:12 +0000784 "password": passwd_schema,
785 "config": {"type": "object"},
tiernocfb07c62018-05-10 18:30:51 +0200786 "description": description_schema,
tierno7adaeb02019-12-17 16:46:12 +0000787 # The folowing are deprecated. Maintanied for backward compatibility
tiernocb83c942018-09-24 17:28:13 +0200788 "dpid": dpid_Schema,
tierno0f98af52018-03-19 10:28:22 +0100789 "ip": ip_schema,
790 "port": port_schema,
tierno0f98af52018-03-19 10:28:22 +0100791 "version": {"type": "string", "minLength": 1, "maxLength": 12},
tierno0f98af52018-03-19 10:28:22 +0100792}
793sdn_new_schema = {
794 "title": "sdn controller information schema",
795 "$schema": "http://json-schema.org/draft-04/schema#",
796 "type": "object",
797 "properties": sdn_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100798 "required": ["name", "type"],
799 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100800}
801sdn_edit_schema = {
802 "title": "sdn controller update information schema",
803 "$schema": "http://json-schema.org/draft-04/schema#",
804 "type": "object",
805 "properties": sdn_properties,
tiernocfb07c62018-05-10 18:30:51 +0200806 # "required": ["name", "port", 'ip', 'dpid', 'type'],
garciadeblas4568a372021-03-24 09:19:48 +0100807 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100808}
809sdn_port_mapping_schema = {
810 "$schema": "http://json-schema.org/draft-04/schema#",
811 "title": "sdn port mapping information schema",
812 "type": "array",
813 "items": {
814 "type": "object",
815 "properties": {
tiernofd160572019-01-21 10:41:37 +0000816 "compute_node": shortname_schema,
tierno0f98af52018-03-19 10:28:22 +0100817 "ports": {
818 "type": "array",
819 "items": {
820 "type": "object",
821 "properties": {
tierno42fce592018-11-02 09:23:43 +0100822 "pci": pci_extended_schema,
tiernofd160572019-01-21 10:41:37 +0000823 "switch_port": shortname_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100824 "switch_mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100825 },
garciadeblas4568a372021-03-24 09:19:48 +0100826 "required": ["pci"],
827 },
828 },
tierno0f98af52018-03-19 10:28:22 +0100829 },
garciadeblas4568a372021-03-24 09:19:48 +0100830 "required": ["compute_node", "ports"],
831 },
tierno0f98af52018-03-19 10:28:22 +0100832}
833sdn_external_port_schema = {
834 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocd54a4a2018-09-12 16:40:35 +0200835 "title": "External port information",
tierno0f98af52018-03-19 10:28:22 +0100836 "type": "object",
837 "properties": {
838 "port": {"type": "string", "minLength": 1, "maxLength": 60},
839 "vlan": vlan_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100840 "mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100841 },
garciadeblas4568a372021-03-24 09:19:48 +0100842 "required": ["port"],
tierno0f98af52018-03-19 10:28:22 +0100843}
844
delacruzramofe598fe2019-10-23 18:25:11 +0200845# K8s Clusters
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500846k8scluster_deploy_method_schema = {
847 "$schema": "http://json-schema.org/draft-04/schema#",
848 "title": "Deployment methods for K8s cluster",
849 "type": "object",
850 "properties": {
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500851 "juju-bundle": {"type": "boolean"},
852 "helm-chart-v3": {"type": "boolean"},
853 },
854 "additionalProperties": False,
Luis Vega0a1efed2023-11-28 16:44:30 +0000855 "minProperties": 2,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500856}
delacruzramofe598fe2019-10-23 18:25:11 +0200857k8scluster_nets_schema = {
858 "title": "k8scluster nets input schema",
859 "$schema": "http://json-schema.org/draft-04/schema#",
860 "type": "object",
tierno8c81ab02020-02-07 10:18:30 +0000861 "patternProperties": {".": {"oneOf": [name_schema, null_schema]}},
delacruzramofe598fe2019-10-23 18:25:11 +0200862 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100863 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200864}
865k8scluster_new_schema = {
866 "title": "k8scluster creation input schema",
867 "$schema": "http://json-schema.org/draft-04/schema#",
868 "type": "object",
869 "properties": {
870 "schema_version": schema_version,
871 "schema_type": schema_type,
872 "name": name_schema,
873 "description": description_schema,
874 "credentials": object_schema,
875 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200876 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200877 "k8s_version": string_schema,
878 "nets": k8scluster_nets_schema,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500879 "deployment_methods": k8scluster_deploy_method_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200880 "namespace": name_schema,
881 "cni": nameshort_list_schema,
882 },
883 "required": ["name", "credentials", "vim_account", "k8s_version", "nets"],
garciadeblas4568a372021-03-24 09:19:48 +0100884 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200885}
886k8scluster_edit_schema = {
887 "title": "vim_account edit input schema",
888 "$schema": "http://json-schema.org/draft-04/schema#",
889 "type": "object",
890 "properties": {
891 "name": name_schema,
892 "description": description_schema,
893 "credentials": object_schema,
894 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200895 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200896 "k8s_version": string_schema,
897 "nets": k8scluster_nets_schema,
898 "namespace": name_schema,
899 "cni": nameshort_list_schema,
900 },
garciadeblas4568a372021-03-24 09:19:48 +0100901 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200902}
903
David Garciaecb41322021-03-31 19:10:46 +0200904# VCA
905vca_new_schema = {
906 "title": "vca creation input schema",
907 "$schema": "http://json-schema.org/draft-04/schema#",
908 "type": "object",
909 "properties": {
910 "schema_version": schema_version,
911 "schema_type": schema_type,
912 "name": name_schema,
913 "description": description_schema,
914 "endpoints": description_list_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100915 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200916 "secret": passwd_schema,
917 "cacert": long_description_schema,
918 "lxd-cloud": shortname_schema,
919 "lxd-credentials": shortname_schema,
920 "k8s-cloud": shortname_schema,
921 "k8s-credentials": shortname_schema,
922 "model-config": object_schema,
923 },
924 "required": [
925 "name",
926 "endpoints",
927 "user",
928 "secret",
929 "cacert",
930 "lxd-cloud",
931 "lxd-credentials",
932 "k8s-cloud",
933 "k8s-credentials",
934 ],
935 "additionalProperties": False,
936}
937vca_edit_schema = {
938 "title": "vca creation input schema",
939 "$schema": "http://json-schema.org/draft-04/schema#",
940 "type": "object",
941 "properties": {
942 "name": name_schema,
943 "description": description_schema,
944 "endpoints": description_list_schema,
945 "port": integer1_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100946 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200947 "secret": passwd_schema,
948 "cacert": long_description_schema,
949 "lxd-cloud": shortname_schema,
950 "lxd-credentials": shortname_schema,
951 "k8s-cloud": shortname_schema,
952 "k8s-credentials": shortname_schema,
953 "model-config": object_schema,
954 },
955 "additionalProperties": False,
956}
957
delacruzramofe598fe2019-10-23 18:25:11 +0200958# K8s Repos
tierno332e0802019-12-03 23:50:49 +0000959k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]}
delacruzramofe598fe2019-10-23 18:25:11 +0200960k8srepo_properties = {
961 "name": name_schema,
962 "description": description_schema,
963 "type": k8srepo_types,
964 "url": description_schema,
Luis Vegaf6574e32023-07-11 18:47:22 +0000965 "cacert": long_description_schema,
966 "user": string_schema,
967 "password": passwd_schema,
garciadeblasf3543892023-10-20 11:53:51 +0200968 "oci": bool_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200969}
970k8srepo_new_schema = {
971 "title": "k8scluster creation input schema",
972 "$schema": "http://json-schema.org/draft-04/schema#",
973 "type": "object",
974 "properties": k8srepo_properties,
975 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100976 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200977}
978k8srepo_edit_schema = {
979 "title": "vim_account edit input schema",
980 "$schema": "http://json-schema.org/draft-04/schema#",
981 "type": "object",
982 "properties": k8srepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100983 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200984}
985
Felipe Vicensb66b0412020-05-06 10:11:00 +0200986# OSM Repos
987osmrepo_types = {"enum": ["osm"]}
988osmrepo_properties = {
989 "name": name_schema,
990 "description": description_schema,
991 "type": osmrepo_types,
rshri2d386cb2024-07-05 14:35:51 +0000992 "url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100993 # "user": string_schema,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200994 # "password": passwd_schema
995}
996osmrepo_new_schema = {
997 "title": "osm repo creation input schema",
998 "$schema": "http://json-schema.org/draft-04/schema#",
999 "type": "object",
1000 "properties": osmrepo_properties,
1001 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +01001002 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001003}
1004osmrepo_edit_schema = {
1005 "title": "osm repo edit input schema",
1006 "$schema": "http://json-schema.org/draft-04/schema#",
1007 "type": "object",
1008 "properties": osmrepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +01001009 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +02001010}
1011
tiernocb83c942018-09-24 17:28:13 +02001012# PDUs
1013pdu_interface = {
1014 "type": "object",
1015 "properties": {
tiernofd160572019-01-21 10:41:37 +00001016 "name": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001017 "mgmt": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001018 "type": {"enum": ["overlay", "underlay"]},
garciadeblas1a01e1f2021-10-26 17:27:35 +02001019 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernocb83c942018-09-24 17:28:13 +02001020 # TODO, add user, password, ssh-key
tierno36ec8602018-11-02 17:27:11 +01001021 "mac-address": mac_schema,
tiernofd160572019-01-21 10:41:37 +00001022 "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
1023 "vim-network-id": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001024 # # provide this in case SDN assist must deal with this interface
1025 # "switch-dpid": dpid_Schema,
tiernofd160572019-01-21 10:41:37 +00001026 # "switch-port": shortname_schema,
1027 # "switch-mac": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001028 # "switch-vlan": vlan_schema,
tiernocb83c942018-09-24 17:28:13 +02001029 },
tierno36ec8602018-11-02 17:27:11 +01001030 "required": ["name", "mgmt", "ip-address"],
garciadeblas4568a372021-03-24 09:19:48 +01001031 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001032}
tiernocb83c942018-09-24 17:28:13 +02001033pdu_new_schema = {
1034 "title": "pdu creation input schema",
1035 "$schema": "http://json-schema.org/draft-04/schema#",
1036 "type": "object",
1037 "properties": {
tiernofd160572019-01-21 10:41:37 +00001038 "name": shortname_schema,
1039 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001040 "description": description_schema,
1041 "shared": bool_schema,
1042 "vims": nameshort_list_schema,
1043 "vim_accounts": nameshort_list_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001044 "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1},
tiernocb83c942018-09-24 17:28:13 +02001045 },
1046 "required": ["name", "type", "interfaces"],
garciadeblas4568a372021-03-24 09:19:48 +01001047 "additionalProperties": False,
tiernocb83c942018-09-24 17:28:13 +02001048}
tiernocb83c942018-09-24 17:28:13 +02001049pdu_edit_schema = {
1050 "title": "pdu edit input schema",
1051 "$schema": "http://json-schema.org/draft-04/schema#",
1052 "type": "object",
1053 "properties": {
tiernofd160572019-01-21 10:41:37 +00001054 "name": shortname_schema,
1055 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001056 "description": description_schema,
1057 "shared": bool_schema,
garciadeblas84bdd552018-11-30 22:59:45 +01001058 "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
1059 "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
garciadeblas4568a372021-03-24 09:19:48 +01001060 "interfaces": {
1061 "oneOf": [
1062 array_edition_schema,
1063 {"type": "array", "items": pdu_interface, "minItems": 1},
1064 ]
1065 },
tiernocb83c942018-09-24 17:28:13 +02001066 },
1067 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001068 "minProperties": 1,
tiernocb83c942018-09-24 17:28:13 +02001069}
1070
delacruzramo271d2002019-12-02 21:00:37 +01001071# VNF PKG OPERATIONS
1072vnfpkgop_new_schema = {
1073 "title": "VNF PKG operation creation input schema",
1074 "$schema": "http://json-schema.org/draft-04/schema#",
1075 "type": "object",
1076 "properties": {
1077 "lcmOperationType": string_schema,
1078 "vnfPkgId": id_schema,
1079 "kdu_name": name_schema,
1080 "primitive": name_schema,
1081 "primitive_params": {"type": "object"},
1082 },
garciadeblas4568a372021-03-24 09:19:48 +01001083 "required": [
1084 "lcmOperationType",
1085 "vnfPkgId",
1086 "kdu_name",
1087 "primitive",
1088 "primitive_params",
1089 ],
1090 "additionalProperties": False,
delacruzramo271d2002019-12-02 21:00:37 +01001091}
1092
rshri2d386cb2024-07-05 14:35:51 +00001093clustercreation_new_schema = {
1094 "title": "cluster creation operation input schema",
1095 "$schema": "http://json-schema.org/draft-04/schema#",
1096 "type": "object",
1097 "properties": {
1098 "name": name_schema,
1099 "vim_account": string_schema,
1100 "k8s_version": string_schema,
1101 "node_size": string_schema,
1102 "node_count": integer0_schema,
rshri17b09ec2024-11-07 05:48:12 +00001103 "description": description_schema,
rshri2d386cb2024-07-05 14:35:51 +00001104 "region_name": string_schema,
1105 "resource_group": string_schema,
1106 "infra_controller_profiles": shortname_schema,
1107 "infra_config_profiles": shortname_schema,
1108 "resource_profiles": shortname_schema,
1109 "app_profiles": shortname_schema,
rshri17b09ec2024-11-07 05:48:12 +00001110 "created": string_schema,
1111 "state": string_schema,
1112 "operatingState": string_schema,
1113 "git_name": string_schema,
1114 "resourceState": string_schema,
1115 "bootstrap": bool_schema,
rshri2d386cb2024-07-05 14:35:51 +00001116 },
1117 "required": [
1118 "name",
1119 "vim_account",
1120 "k8s_version",
1121 "node_size",
1122 "node_count",
rshri2d386cb2024-07-05 14:35:51 +00001123 ],
1124 "additionalProperties": False,
1125}
rshri17b09ec2024-11-07 05:48:12 +00001126clusterregistration_new_schema = {
1127 "title": "cluster registration input schema",
1128 "$schema": "http://json-schema.org/draft-04/schema#",
1129 "type": "object",
1130 "properties": {
1131 "schema_version": schema_version,
1132 "schema_type": schema_type,
1133 "name": name_schema,
1134 "description": description_schema,
1135 "credentials": object_schema,
1136 "vim_account": string_schema,
1137 "bootstrap": bool_schema,
1138 },
1139 "required": ["name", "credentials", "vim_account"],
1140 "additionalProperties": False,
1141}
rshri2d386cb2024-07-05 14:35:51 +00001142
yshah99122b82024-11-18 07:05:29 +00001143cluster_edit_schema = {
1144 "title": "cluster edit schema",
1145 "$schema": "http://json-schema.org/draft-04/schema#",
1146 "type": "object",
1147 "properties": {
1148 "name": name_schema,
1149 "description": string_schema,
1150 },
1151 "additionalProperties": False,
1152}
1153
1154cluster_update_schema = {
1155 "title": "cluster update schema",
1156 "$schema": "http://json-schema.org/draft-04/schema#",
1157 "type": "object",
1158 "properties": {
1159 "k8s_version": string_schema,
1160 "node_size": string_schema,
1161 "node_count": integer0_schema,
1162 },
1163 "additionalProperties": True,
1164}
1165
rshri2d386cb2024-07-05 14:35:51 +00001166infra_controller_profile_create_new_schema = {
1167 "title": "infra profile creation operation input schema",
1168 "$schema": "http://json-schema.org/draft-04/schema#",
1169 "type": "object",
1170 "properties": {
1171 "name": name_schema,
1172 "description": string_schema,
1173 },
1174 "additionalProperties": False,
1175}
1176
1177infra_controller_profile_create_edit_schema = {
1178 "title": "infra profile creation operation input schema",
1179 "$schema": "http://json-schema.org/draft-04/schema#",
1180 "type": "object",
1181 "properties": {
1182 "name": name_schema,
1183 "description": string_schema,
1184 },
1185 "additionalProperties": False,
1186}
1187
1188infra_config_profile_create_new_schema = {
1189 "title": "infra profile creation operation input schema",
1190 "$schema": "http://json-schema.org/draft-04/schema#",
1191 "type": "object",
1192 "properties": {
1193 "name": name_schema,
1194 "description": string_schema,
1195 },
1196 "additionalProperties": False,
1197}
1198
1199infra_config_profile_create_edit_schema = {
1200 "title": "infra profile creation operation input schema",
1201 "$schema": "http://json-schema.org/draft-04/schema#",
1202 "type": "object",
1203 "properties": {
1204 "name": name_schema,
1205 "description": string_schema,
1206 },
1207 "additionalProperties": False,
1208}
1209
1210app_profile_create_new_schema = {
1211 "title": "app profile creation operation input schema",
1212 "$schema": "http://json-schema.org/draft-04/schema#",
1213 "type": "object",
1214 "properties": {
1215 "name": name_schema,
1216 "description": string_schema,
1217 },
1218 "additionalProperties": False,
1219}
1220app_profile_create_edit_schema = {
1221 "title": "app profile creation operation input schema",
1222 "$schema": "http://json-schema.org/draft-04/schema#",
1223 "type": "object",
1224 "properties": {
1225 "name": name_schema,
1226 "description": string_schema,
1227 },
1228 "additionalProperties": False,
1229}
1230
1231resource_profile_create_new_schema = {
1232 "title": "resource profile creation operation input schema",
1233 "$schema": "http://json-schema.org/draft-04/schema#",
1234 "type": "object",
1235 "properties": {
1236 "name": name_schema,
1237 "description": string_schema,
1238 },
1239 "additionalProperties": False,
1240}
1241resource_profile_create_edit_schema = {
1242 "title": "resource profile creation operation input schema",
1243 "$schema": "http://json-schema.org/draft-04/schema#",
1244 "type": "object",
1245 "properties": {
1246 "name": name_schema,
1247 "description": string_schema,
1248 },
1249 "additionalProperties": False,
1250}
1251
1252attach_profile = {
1253 "type": "array",
1254 "items": {
1255 "type": "object",
1256 "properties": {"id": id_schema},
1257 "additionalProperties": False,
1258 },
1259}
1260remove_profile = {
1261 "type": "array",
1262 "items": {
1263 "type": "object",
1264 "properties": {"id": id_schema},
1265 "additionalProperties": False,
1266 },
1267}
1268attach_dettach_profile_schema = {
1269 "title": "attach/dettach profiles",
1270 "$schema": "http://json-schema.org/draft-04/schema#",
1271 "type": "object",
1272 "properties": {
1273 "add_profile": attach_profile,
1274 "remove_profile": remove_profile,
1275 },
1276 "additionalProperties": False,
1277}
tiernocb83c942018-09-24 17:28:13 +02001278# USERS
tiernocf042d32019-06-13 09:06:40 +00001279project_role_mappings = {
1280 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001281 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001282 "type": "array",
1283 "items": {
1284 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001285 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001286 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001287 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001288 },
garciadeblas4568a372021-03-24 09:19:48 +01001289 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001290}
rshri2d386cb2024-07-05 14:35:51 +00001291
tiernocf042d32019-06-13 09:06:40 +00001292project_role_mappings_optional = {
1293 "title": "list of projects/roles or projects only",
1294 "$schema": "http://json-schema.org/draft-04/schema#",
1295 "type": "array",
1296 "items": {
1297 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001298 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001299 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001300 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001301 },
garciadeblas4568a372021-03-24 09:19:48 +01001302 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001303}
rshri2d386cb2024-07-05 14:35:51 +00001304
tiernocd54a4a2018-09-12 16:40:35 +02001305user_new_schema = {
1306 "$schema": "http://json-schema.org/draft-04/schema#",
1307 "title": "New user schema",
1308 "type": "object",
1309 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001310 "username": string_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001311 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001312 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001313 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001314 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001315 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001316 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001317 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001318 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001319}
1320user_edit_schema = {
1321 "$schema": "http://json-schema.org/draft-04/schema#",
1322 "title": "User edit schema for administrators",
1323 "type": "object",
1324 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001325 "password": user_passwd_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001326 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001327 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001328 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001329 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001330 "project_role_mappings": project_role_mappings,
1331 "add_project_role_mappings": project_role_mappings,
1332 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001333 "system_admin_id": id_schema,
1334 "unlock": bool_schema,
1335 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001336 },
1337 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001338 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001339}
1340
1341# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001342topics_with_quota = [
1343 "vnfds",
1344 "nsds",
1345 "slice_templates",
1346 "pduds",
1347 "ns_instances",
1348 "slice_instances",
1349 "vim_accounts",
1350 "wim_accounts",
1351 "sdn_controllers",
1352 "k8sclusters",
1353 "vca",
1354 "k8srepos",
1355 "osmrepos",
1356 "ns_subscriptions",
1357]
tiernocd54a4a2018-09-12 16:40:35 +02001358project_new_schema = {
1359 "$schema": "http://json-schema.org/draft-04/schema#",
1360 "title": "New project schema for administrators",
1361 "type": "object",
1362 "properties": {
tiernofd160572019-01-21 10:41:37 +00001363 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001364 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001365 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001366 "quotas": {
1367 "type": "object",
1368 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001369 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001370 },
tiernocd54a4a2018-09-12 16:40:35 +02001371 },
1372 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001373 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001374}
1375project_edit_schema = {
1376 "$schema": "http://json-schema.org/draft-04/schema#",
1377 "title": "Project edit schema for administrators",
1378 "type": "object",
1379 "properties": {
1380 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001381 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001382 "quotas": {
1383 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001384 "properties": {
1385 topic: {"oneOf": [integer0_schema, null_schema]}
1386 for topic in topics_with_quota
1387 },
1388 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001389 },
tiernocd54a4a2018-09-12 16:40:35 +02001390 },
1391 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001392 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001393}
1394
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001395# ROLES
1396roles_new_schema = {
1397 "$schema": "http://json-schema.org/draft-04/schema#",
1398 "title": "New role schema for administrators",
1399 "type": "object",
1400 "properties": {
1401 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001402 "permissions": {
1403 "type": "object",
1404 "patternProperties": {
1405 ".": bool_schema,
1406 },
1407 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001408 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001409 },
tierno1f029d82019-06-13 22:37:04 +00001410 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001411 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001412}
1413roles_edit_schema = {
1414 "$schema": "http://json-schema.org/draft-04/schema#",
1415 "title": "Roles edit schema for administrators",
1416 "type": "object",
1417 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001418 "name": shortname_schema,
1419 "permissions": {
1420 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001421 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001422 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001423 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001424 },
tierno1f029d82019-06-13 22:37:04 +00001425 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001426 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001427}
1428
tiernocd54a4a2018-09-12 16:40:35 +02001429# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001430
1431nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001432 "users": user_new_schema,
1433 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001434 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001435 "sdns": sdn_new_schema,
1436 "ns_instantiate": ns_instantiate,
1437 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001438 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001439 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001440 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001441 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001442}
1443
1444nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001445 "users": user_edit_schema,
1446 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001447 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001448 "sdns": sdn_edit_schema,
1449 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301450 "vnf": vnf_schema,
1451 "vld": vld_schema,
1452 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001453}
1454
Felipe Vicens07f31722018-10-29 15:16:44 +01001455# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001456nsi_subnet_instantiate = deepcopy(ns_instantiate)
1457nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1458nsi_subnet_instantiate["properties"]["id"] = name_schema
1459del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001460
1461nsi_vld_instantiate = {
1462 "title": "netslice vld instantiation params input schema",
1463 "$schema": "http://json-schema.org/draft-04/schema#",
1464 "type": "object",
1465 "properties": {
1466 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001467 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1468 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001469 "ip-profile": object_schema,
1470 },
delacruzramoc061f562019-04-05 11:00:02 +02001471 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001472 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001473}
1474
Felipe Vicens07f31722018-10-29 15:16:44 +01001475nsi_instantiate = {
1476 "title": "netslice action instantiate input schema",
1477 "$schema": "http://json-schema.org/draft-04/schema#",
1478 "type": "object",
1479 "properties": {
1480 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001481 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001482 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001483 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001484 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001485 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001486 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001487 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001488 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001489 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001490 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001491 "type": "array",
1492 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001493 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001494 },
garciadeblas4568a372021-03-24 09:19:48 +01001495 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001496 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001497 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001498 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001499}
1500
garciadeblas4568a372021-03-24 09:19:48 +01001501nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001502
garciadeblas4568a372021-03-24 09:19:48 +01001503nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001504
preethika.p329b8182020-04-22 12:25:39 +05301505nsinstancesubscriptionfilter_schema = {
1506 "title": "instance identifier schema",
1507 "$schema": "http://json-schema.org/draft-07/schema#",
1508 "type": "object",
1509 "properties": {
1510 "nsdIds": {"type": "array"},
1511 "vnfdIds": {"type": "array"},
1512 "pnfdIds": {"type": "array"},
1513 "nsInstanceIds": {"type": "array"},
1514 "nsInstanceNames": {"type": "array"},
1515 },
1516}
1517
1518nslcmsub_schema = {
1519 "title": "nslcmsubscription input schema",
1520 "$schema": "http://json-schema.org/draft-07/schema#",
1521 "type": "object",
1522 "properties": {
1523 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1524 "notificationTypes": {
1525 "type": "array",
1526 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001527 "enum": [
1528 "NsLcmOperationOccurrenceNotification",
1529 "NsChangeNotification",
1530 "NsIdentifierCreationNotification",
1531 "NsIdentifierDeletionNotification",
1532 ]
1533 },
preethika.p329b8182020-04-22 12:25:39 +05301534 },
1535 "operationTypes": {
1536 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001537 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301538 },
1539 "operationStates": {
1540 "type": "array",
1541 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001542 "enum": [
1543 "PROCESSING",
1544 "COMPLETED",
1545 "PARTIALLY_COMPLETED",
1546 "FAILED",
1547 "FAILED_TEMP",
1548 "ROLLING_BACK",
1549 "ROLLED_BACK",
1550 ]
1551 },
preethika.p329b8182020-04-22 12:25:39 +05301552 },
garciadeblas4568a372021-03-24 09:19:48 +01001553 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301554 "lcmOpNameImpactingNsComponent": {
1555 "type": "array",
1556 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001557 "enum": [
1558 "VNF_INSTANTIATE",
1559 "VNF_SCALE",
1560 "VNF_SCALE_TO_LEVEL",
1561 "VNF_CHANGE_FLAVOUR",
1562 "VNF_TERMINATE",
1563 "VNF_HEAL",
1564 "VNF_OPERATE",
1565 "VNF_CHANGE_EXT_CONN",
1566 "VNF_MODIFY_INFO",
1567 "NS_INSTANTIATE",
1568 "NS_SCALE",
1569 "NS_UPDATE",
1570 "NS_TERMINATE",
1571 "NS_HEAL",
1572 ]
1573 },
preethika.p329b8182020-04-22 12:25:39 +05301574 },
1575 "lcmOpOccStatusImpactingNsComponent": {
1576 "type": "array",
1577 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001578 "enum": [
1579 "START",
1580 "COMPLETED",
1581 "PARTIALLY_COMPLETED",
1582 "FAILED",
1583 "ROLLED_BACK",
1584 ]
1585 },
preethika.p329b8182020-04-22 12:25:39 +05301586 },
1587 },
1588 "allOf": [
1589 {
1590 "if": {
1591 "properties": {
1592 "notificationTypes": {
1593 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1594 }
1595 },
1596 },
1597 "then": {
1598 "anyOf": [
1599 {"required": ["operationTypes"]},
1600 {"required": ["operationStates"]},
1601 ]
garciadeblas4568a372021-03-24 09:19:48 +01001602 },
preethika.p329b8182020-04-22 12:25:39 +05301603 },
1604 {
1605 "if": {
1606 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001607 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301608 },
1609 },
1610 "then": {
1611 "anyOf": [
1612 {"required": ["nsComponentTypes"]},
1613 {"required": ["lcmOpNameImpactingNsComponent"]},
1614 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1615 ]
garciadeblas4568a372021-03-24 09:19:48 +01001616 },
1617 },
1618 ],
preethika.p329b8182020-04-22 12:25:39 +05301619}
1620
1621authentication_schema = {
1622 "title": "authentication schema for subscription",
1623 "$schema": "http://json-schema.org/draft-07/schema#",
1624 "type": "object",
1625 "properties": {
1626 "authType": {"enum": ["basic"]},
1627 "paramsBasic": {
1628 "type": "object",
1629 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001630 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301631 "password": passwd_schema,
1632 },
1633 },
1634 },
1635}
1636
1637subscription = {
1638 "title": "subscription input schema",
1639 "$schema": "http://json-schema.org/draft-07/schema#",
1640 "type": "object",
1641 "properties": {
1642 "filter": nslcmsub_schema,
1643 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001644 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301645 },
1646 "required": ["CallbackUri"],
1647}
1648
selvi.jf1004592022-04-29 05:42:35 +00001649vnflcmsub_schema = {
1650 "title": "vnflcmsubscription input schema",
1651 "$schema": "http://json-schema.org/draft-07/schema#",
1652 "type": "object",
1653 "properties": {
1654 "VnfInstanceSubscriptionFilter": {
1655 "type": "object",
1656 "properties": {
1657 "vnfdIds": {"type": "array"},
1658 "vnfInstanceIds": {"type": "array"},
1659 },
1660 },
1661 "notificationTypes": {
1662 "type": "array",
1663 "items": {
1664 "enum": [
1665 "VnfIdentifierCreationNotification",
1666 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001667 "VnfIdentifierDeletionNotification",
1668 ]
1669 },
selvi.jf1004592022-04-29 05:42:35 +00001670 },
1671 "operationTypes": {
1672 "type": "array",
1673 "items": {
1674 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001675 "INSTANTIATE",
1676 "SCALE",
1677 "SCALE_TO_LEVEL",
1678 "CHANGE_FLAVOUR",
1679 "TERMINATE",
1680 "HEAL",
1681 "OPERATE",
1682 "CHANGE_EXT_CONN",
1683 "MODIFY_INFO",
1684 "CREATE_SNAPSHOT",
1685 "REVERT_TO_SNAPSHOT",
1686 "CHANGE_VNFPKG",
1687 ]
1688 },
selvi.jf1004592022-04-29 05:42:35 +00001689 },
1690 "operationStates": {
1691 "type": "array",
1692 "items": {
1693 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001694 "STARTING",
1695 "PROCESSING",
1696 "COMPLETED",
1697 "FAILED_TEMP",
1698 "FAILED",
1699 "ROLLING_BACK",
1700 "ROLLED_BACK",
1701 ]
1702 },
1703 },
selvi.jf1004592022-04-29 05:42:35 +00001704 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001705 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1706}
selvi.jf1004592022-04-29 05:42:35 +00001707
1708vnf_subscription = {
1709 "title": "vnf subscription input schema",
1710 "$schema": "http://json-schema.org/draft-07/schema#",
1711 "type": "object",
1712 "properties": {
1713 "filter": vnflcmsub_schema,
1714 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001715 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001716 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001717 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001718}
1719
yshah53cc9eb2024-07-05 13:06:31 +00001720oka_schema = {
1721 "title": "Create OKA package input schema",
1722 "$schema": "http://json-schema.org/draft-07/schema#",
1723 "type": "object",
1724 "properties": {
1725 "name": name_schema,
1726 "description": description_schema,
garciadeblas3fb820d2024-12-05 13:11:11 +01001727 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001728 },
1729 "additionalProperties": False,
1730}
1731
1732ksu_schema = {
1733 "title": "ksu schema",
1734 "$schema": "http://json-schema.org/draft-07/schema#",
1735 "type": "object",
1736 "properties": {
1737 "name": name_schema,
1738 "description": description_schema,
1739 "profile": {
1740 "type": "object",
1741 "properties": {
garciadeblas3fb820d2024-12-05 13:11:11 +01001742 "profile_type": profile_type_schema,
yshah53cc9eb2024-07-05 13:06:31 +00001743 "_id": id_schema,
1744 },
1745 "additionalProperties": False,
1746 },
1747 "oka": {
1748 "type": "array",
1749 "items": {
1750 "type": "object",
1751 "properties": {
1752 "_id": id_schema,
1753 "sw_catalog_path": string_schema,
1754 "transformation": object_schema,
1755 },
1756 "additionalProperties": False,
1757 },
1758 },
1759 },
1760 "additionalProperties": False,
1761}
1762
tierno0f98af52018-03-19 10:28:22 +01001763
1764class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001765 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1766 self.http_code = http_code
1767 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001768
1769
tiernob24258a2018-10-04 18:39:49 +02001770def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001771 """
tiernocd54a4a2018-09-12 16:40:35 +02001772 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001773 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001774 :param schema_to_use: jsonschema to test
1775 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001776 """
1777 try:
tierno0f98af52018-03-19 10:28:22 +01001778 if schema_to_use:
1779 js_v(indata, schema_to_use)
1780 return None
1781 except js_e.ValidationError as e:
1782 if e.path:
tierno0da52252018-06-27 15:47:22 +02001783 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001784 else:
1785 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001786 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001787 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001788 raise ValidationError(
1789 "Bad json schema {}".format(schema_to_use),
1790 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1791 )
delacruzramoc061f562019-04-05 11:00:02 +02001792
1793
1794def is_valid_uuid(x):
1795 """
1796 Test for a valid UUID
1797 :param x: string to test
1798 :return: True if x is a valid uuid, False otherwise
1799 """
1800 try:
1801 if UUID(x):
1802 return True
tiernobdebce92019-07-01 15:36:49 +00001803 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001804 return False