blob: e22d05d6a8e8cbb11ecbcaf2e65bf4ef8dceb4d0 [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
tierno441dbbf2018-07-10 12:52:48 +0200144ns_instantiate_vdu = {
145 "title": "ns action instantiate input schema for vdu",
146 "$schema": "http://json-schema.org/draft-04/schema#",
147 "type": "object",
148 "properties": {
149 "id": name_schema,
Gabriel Cubae88401b2023-04-05 15:24:52 -0500150 "vim-flavor-id": name_schema,
kayal20016a3bce72024-06-27 11:14:59 +0530151 "instance_name": name_schema,
tierno441dbbf2018-07-10 12:52:48 +0200152 "volume": {
153 "type": "array",
154 "minItems": 1,
155 "items": {
156 "type": "object",
157 "properties": {
158 "name": name_schema,
159 "vim-volume-id": name_schema,
160 },
161 "required": ["name", "vim-volume-id"],
garciadeblas4568a372021-03-24 09:19:48 +0100162 "additionalProperties": False,
163 },
tierno441dbbf2018-07-10 12:52:48 +0200164 },
165 "interface": {
166 "type": "array",
167 "minItems": 1,
168 "items": {
169 "type": "object",
170 "properties": {
171 "name": name_schema,
garciadeblas9fb32712022-04-04 16:33:59 +0200172 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200173 "mac-address": mac_schema,
174 "floating-ip-required": bool_schema,
175 },
176 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +0100177 "additionalProperties": False,
178 },
179 },
tierno441dbbf2018-07-10 12:52:48 +0200180 },
181 "required": ["id"],
garciadeblas4568a372021-03-24 09:19:48 +0100182 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200183}
184
185ip_profile_dns_schema = {
186 "type": "array",
187 "minItems": 1,
188 "items": {
189 "type": "object",
190 "properties": {
garciadeblas9fb32712022-04-04 16:33:59 +0200191 "address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200192 },
193 "required": ["address"],
garciadeblas4568a372021-03-24 09:19:48 +0100194 "additionalProperties": False,
195 },
tierno441dbbf2018-07-10 12:52:48 +0200196}
197
198ip_profile_dhcp_schema = {
199 "type": "object",
200 "properties": {
201 "enabled": {"type": "boolean"},
202 "count": integer1_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100203 "start-address": ip_schema,
tierno441dbbf2018-07-10 12:52:48 +0200204 },
205 "additionalProperties": False,
206}
207
208ip_profile_schema = {
tierno2a929042020-03-10 16:34:25 +0000209 "title": "ip profile validation schema",
tierno441dbbf2018-07-10 12:52:48 +0200210 "$schema": "http://json-schema.org/draft-04/schema#",
211 "type": "object",
212 "properties": {
213 "ip-version": {"enum": ["ipv4", "ipv6"]},
tierno441dbbf2018-07-10 12:52:48 +0200214 "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]},
215 "gateway-address": {"oneOf": [null_schema, ip_schema]},
216 "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200217 "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]},
218 },
garciadeblas4568a372021-03-24 09:19:48 +0100219 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200220}
221
kbsub21f03f52019-10-17 16:26:56 +0000222provider_network_schema = {
tierno2a929042020-03-10 16:34:25 +0000223 "title": "provider network validation schema",
kbsub21f03f52019-10-17 16:26:56 +0000224 "$schema": "http://json-schema.org/draft-04/schema#",
225 "type": "object",
226 "properties": {
227 "physical-network": name_schema,
228 "segmentation-id": name_schema,
tierno2a929042020-03-10 16:34:25 +0000229 "sdn-ports": { # external ports to append to the SDN-assist network
230 "type": "array",
231 "items": {
232 "type": "object",
233 "properties": {
234 "switch_id": shortname_schema,
235 "switch_port": shortname_schema,
236 "mac_address": mac_schema,
237 "vlan": vlan_schema,
238 },
garciadeblas4568a372021-03-24 09:19:48 +0100239 "additionalProperties": True,
240 },
tierno2a929042020-03-10 16:34:25 +0000241 },
242 "network-type": shortname_schema,
kbsub21f03f52019-10-17 16:26:56 +0000243 },
garciadeblas4568a372021-03-24 09:19:48 +0100244 "additionalProperties": True,
kbsub21f03f52019-10-17 16:26:56 +0000245}
246
tierno441dbbf2018-07-10 12:52:48 +0200247ns_instantiate_internal_vld = {
garciadeblas9fb32712022-04-04 16:33:59 +0200248 "title": "ns action instantiate input schema for vld",
tierno441dbbf2018-07-10 12:52:48 +0200249 "$schema": "http://json-schema.org/draft-04/schema#",
250 "type": "object",
251 "properties": {
252 "name": name_schema,
253 "vim-network-name": name_schema,
gcalvino17d5b732018-12-17 16:26:21 +0100254 "vim-network-id": name_schema,
garciadeblas120105b2023-02-22 16:52:24 +0100255 "ip-profile": ip_profile_schema,
kbsub21f03f52019-10-17 16:26:56 +0000256 "provider-network": provider_network_schema,
tierno441dbbf2018-07-10 12:52:48 +0200257 "internal-connection-point": {
258 "type": "array",
259 "minItems": 1,
260 "items": {
261 "type": "object",
262 "properties": {
263 "id-ref": name_schema,
264 "ip-address": ip_schema,
tiernob7c6f2a2018-09-03 14:32:10 +0200265 # "mac-address": mac_schema,
tierno441dbbf2018-07-10 12:52:48 +0200266 },
tiernob7c6f2a2018-09-03 14:32:10 +0200267 "required": ["id-ref"],
268 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100269 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200270 },
garciadeblas4568a372021-03-24 09:19:48 +0100271 },
tierno441dbbf2018-07-10 12:52:48 +0200272 },
273 "required": ["name"],
274 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100275 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200276}
tierno65acb4d2018-04-06 16:42:40 +0200277
tiernofd160572019-01-21 10:41:37 +0000278additional_params_for_vnf = {
279 "type": "array",
280 "items": {
281 "type": "object",
282 "properties": {
283 "member-vnf-index": name_schema,
284 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000285 "k8s-namespace": name_schema,
tiernof62ac6a2020-04-29 13:46:13 +0000286 "config-units": integer1_schema, # number of configuration units of this vnf, by default 1
tierno714954e2019-11-29 13:43:26 +0000287 "additionalParamsForVdu": {
288 "type": "array",
289 "items": {
290 "type": "object",
291 "properties": {
292 "vdu_id": name_schema,
293 "additionalParams": object_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100294 "config-units": integer1_schema, # number of configuration units of this vdu, by default 1
tierno714954e2019-11-29 13:43:26 +0000295 },
tiernof62ac6a2020-04-29 13:46:13 +0000296 "required": ["vdu_id"],
297 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000298 "additionalProperties": False,
299 },
300 },
301 "additionalParamsForKdu": {
302 "type": "array",
303 "items": {
304 "type": "object",
305 "properties": {
306 "kdu_name": name_schema,
307 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000308 "kdu_model": name_schema,
309 "k8s-namespace": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100310 "config-units": integer1_schema, # number of configuration units of this knf, by default 1
romeromonserbfebfc02021-05-28 10:51:35 +0200311 "kdu-deployment-name": name_schema,
tierno714954e2019-11-29 13:43:26 +0000312 },
tierno54db2e42020-04-06 15:29:42 +0000313 "required": ["kdu_name"],
314 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000315 "additionalProperties": False,
316 },
317 },
Alexis Romeroee31f532022-04-26 19:10:21 +0200318 "affinity-or-anti-affinity-group": {
319 "type": "array",
320 "items": {
321 "type": "object",
322 "properties": {
323 "id": name_schema,
324 "vim-affinity-group-id": name_schema,
325 },
326 "required": ["id"],
327 "minProperties": 2,
328 "additionalProperties": False,
329 },
330 },
tiernofd160572019-01-21 10:41:37 +0000331 },
tierno714954e2019-11-29 13:43:26 +0000332 "required": ["member-vnf-index"],
333 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100334 "additionalProperties": False,
335 },
tiernofd160572019-01-21 10:41:37 +0000336}
337
kayal2001f71c2e82024-06-25 15:26:24 +0530338vnf_schema = {
339 "type": "array",
340 "minItems": 1,
341 "items": {
342 "type": "object",
343 "properties": {
344 "member-vnf-index": name_schema,
345 "vimAccountId": id_schema,
346 "vdu": {
347 "type": "array",
348 "minItems": 1,
349 "items": ns_instantiate_vdu,
350 },
351 "internal-vld": {
352 "type": "array",
353 "minItems": 1,
354 "items": ns_instantiate_internal_vld,
355 },
356 },
357 "required": ["member-vnf-index"],
358 "minProperties": 2,
359 "additionalProperties": False,
360 },
361}
362
363vld_schema = {
364 "type": "array",
365 "minItems": 1,
366 "items": {
367 "type": "object",
368 "properties": {
369 "name": string_schema,
370 "vim-network-name": {"oneOf": [string_schema, object_schema]},
371 "vim-network-id": {"oneOf": [string_schema, object_schema]},
372 "ns-net": object_schema,
373 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
374 "ip-profile": ip_profile_schema,
375 "provider-network": provider_network_schema,
376 "vnfd-connection-point-ref": {
377 "type": "array",
378 "minItems": 1,
379 "items": {
380 "type": "object",
381 "properties": {
382 "member-vnf-index-ref": name_schema,
383 "vnfd-connection-point-ref": name_schema,
384 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
385 # "mac-address": mac_schema,
386 },
387 "required": [
388 "member-vnf-index-ref",
389 "vnfd-connection-point-ref",
390 ],
391 "minProperties": 3,
392 "additionalProperties": False,
393 },
394 },
395 },
396 "required": ["name"],
397 "additionalProperties": False,
398 },
399}
400
401ns_config_template = {
402 "title": " ns config template input schema",
403 "$schema": "http://json-schema.org/draft-04/schema#",
404 "type": "object",
405 "properties": {
406 "name": string_schema,
407 "nsdId": id_schema,
408 "config": object_schema,
409 },
410 "required": ["name", "nsdId", "config"],
411 "additionalProperties": False,
412}
413
tierno65acb4d2018-04-06 16:42:40 +0200414ns_instantiate = {
415 "title": "ns action instantiate input schema",
416 "$schema": "http://json-schema.org/draft-04/schema#",
417 "type": "object",
tierno0da52252018-06-27 15:47:22 +0200418 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200419 "lcmOperationType": string_schema,
420 "nsInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +0100421 "netsliceInstanceId": id_schema,
tierno0da52252018-06-27 15:47:22 +0200422 "nsName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +0000423 "nsDescription": {"oneOf": [description_schema, null_schema]},
tierno0da52252018-06-27 15:47:22 +0200424 "nsdId": id_schema,
425 "vimAccountId": id_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530426 "nsConfigTemplateId": id_schema,
tierno195a36c2020-09-18 14:18:55 +0000427 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
magnussonlf318b302020-01-20 18:38:18 +0100428 "placement-engine": string_schema,
429 "placement-constraints": object_schema,
tiernobee085c2018-12-12 17:03:04 +0000430 "additionalParamsForNs": object_schema,
tiernofd160572019-01-21 10:41:37 +0000431 "additionalParamsForVnf": additional_params_for_vnf,
garciadeblas4568a372021-03-24 09:19:48 +0100432 "config-units": integer1_schema, # number of configuration units of this ns, by default 1
tierno54db2e42020-04-06 15:29:42 +0000433 "k8s-namespace": name_schema,
tiernofc5089c2018-10-31 09:28:11 +0100434 "ssh_keys": {"type": "array", "items": {"type": "string"}},
tiernoa8186a52020-01-14 15:54:48 +0000435 "timeout_ns_deploy": integer1_schema,
tierno441dbbf2018-07-10 12:52:48 +0200436 "nsr_id": id_schema,
tiernocc103432018-10-19 14:10:35 +0200437 "vduImage": name_schema,
kayal2001f71c2e82024-06-25 15:26:24 +0530438 "vnf": vnf_schema,
439 "vld": vld_schema,
tierno0da52252018-06-27 15:47:22 +0200440 },
tierno441dbbf2018-07-10 12:52:48 +0200441 "required": ["nsName", "nsdId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +0100442 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200443}
tierno0da52252018-06-27 15:47:22 +0200444
tierno1c38f2f2020-03-24 11:51:39 +0000445ns_terminate = {
446 "title": "ns terminate input schema",
447 "$schema": "http://json-schema.org/draft-04/schema#",
448 "type": "object",
449 "properties": {
450 "lcmOperationType": string_schema,
451 "nsInstanceId": id_schema,
452 "autoremove": bool_schema,
453 "timeout_ns_terminate": integer1_schema,
454 "skip_terminate_primitives": bool_schema,
tierno0b8752f2020-05-12 09:42:02 +0000455 "netsliceInstanceId": id_schema,
tierno1c38f2f2020-03-24 11:51:39 +0000456 },
garciadeblas4568a372021-03-24 09:19:48 +0100457 "additionalProperties": False,
tierno1c38f2f2020-03-24 11:51:39 +0000458}
459
aticig544a2ae2022-04-05 09:00:17 +0300460ns_update = {
461 "title": "ns update input schema",
462 "$schema": "http://json-schema.org/draft-04/schema#",
463 "type": "object",
464 "properties": {
465 "lcmOperationType": string_schema,
466 "nsInstanceId": id_schema,
garciadeblaseab15072022-05-19 10:31:52 +0200467 "timeout_ns_update": integer1_schema,
aticig544a2ae2022-04-05 09:00:17 +0300468 "updateType": {
garciadeblasf2af4a12023-01-24 16:56:54 +0100469 "enum": [
470 "CHANGE_VNFPKG",
471 "REMOVE_VNF",
472 "MODIFY_VNF_INFORMATION",
473 "OPERATE_VNF",
Rahul Kumara30391b2024-05-24 14:40:23 +0530474 "VERTICAL_SCALE",
garciadeblasf2af4a12023-01-24 16:56:54 +0100475 ]
aticig544a2ae2022-04-05 09:00:17 +0300476 },
477 "modifyVnfInfoData": {
478 "type": "object",
479 "properties": {
480 "vnfInstanceId": id_schema,
481 "vnfdId": id_schema,
482 },
483 "required": ["vnfInstanceId", "vnfdId"],
484 },
485 "removeVnfInstanceId": id_schema,
486 "changeVnfPackageData": {
487 "type": "object",
488 "properties": {
489 "vnfInstanceId": id_schema,
490 "vnfdId": id_schema,
491 },
492 "required": ["vnfInstanceId", "vnfdId"],
493 },
k4.rahule3dca382022-04-29 12:30:36 +0000494 "operateVnfData": {
495 "type": "object",
496 "properties": {
497 "vnfInstanceId": id_schema,
498 "changeStateTo": name_schema,
499 "additionalParam": {
500 "type": "object",
501 "properties": {
502 "run-day1": bool_schema,
503 "vdu_id": name_schema,
504 "count-index": integer0_schema,
505 },
506 "required": ["vdu_id", "count-index"],
507 "additionalProperties": False,
garciadeblasf2af4a12023-01-24 16:56:54 +0100508 },
k4.rahule3dca382022-04-29 12:30:36 +0000509 },
510 "required": ["vnfInstanceId", "changeStateTo"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100511 },
Rahul Kumara30391b2024-05-24 14:40:23 +0530512 "verticalScaleVnf": {
513 "type": "object",
514 "properties": {
515 "vnfInstanceId": id_schema,
516 "vnfdId": id_schema,
517 "vduId": name_schema,
518 "countIndex": integer0_schema,
519 },
520 "required": ["vnfInstanceId", "vnfdId", "vduId"],
521 },
aticig544a2ae2022-04-05 09:00:17 +0300522 },
523 "required": ["updateType"],
524 "additionalProperties": False,
525}
526
garciadeblas4568a372021-03-24 09:19:48 +0100527ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
tiernof759d822018-06-11 18:54:54 +0200528 "title": "ns action input schema",
tierno65acb4d2018-04-06 16:42:40 +0200529 "$schema": "http://json-schema.org/draft-04/schema#",
530 "type": "object",
531 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200532 "lcmOperationType": string_schema,
533 "nsInstanceId": id_schema,
tiernof5298be2018-05-16 14:43:57 +0200534 "member_vnf_index": name_schema,
535 "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future
tierno7ce1db92018-07-25 12:50:52 +0200536 "vdu_id": name_schema,
tiernof0637052019-03-07 16:26:47 +0000537 "vdu_count_index": integer0_schema,
tierno9cb7d672019-10-30 12:13:48 +0000538 "kdu_name": name_schema,
tierno65acb4d2018-04-06 16:42:40 +0200539 "primitive": name_schema,
tierno50c8e6e2020-04-02 15:40:12 +0000540 "timeout_ns_action": integer1_schema,
tierno65acb4d2018-04-06 16:42:40 +0200541 "primitive_params": {"type": "object"},
542 },
garciadeblas4568a372021-03-24 09:19:48 +0100543 "required": ["primitive", "primitive_params"], # TODO add member_vnf_index
544 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200545}
garciadeblas0964edf2022-02-11 00:43:44 +0100546
garciadeblas4568a372021-03-24 09:19:48 +0100547ns_scale = { # TODO for the moment it is only VDU-scaling
tiernof759d822018-06-11 18:54:54 +0200548 "title": "ns scale input schema",
549 "$schema": "http://json-schema.org/draft-04/schema#",
550 "type": "object",
551 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200552 "lcmOperationType": string_schema,
553 "nsInstanceId": id_schema,
tiernof759d822018-06-11 18:54:54 +0200554 "scaleType": {"enum": ["SCALE_VNF"]},
tierno50c8e6e2020-04-02 15:40:12 +0000555 "timeout_ns_scale": integer1_schema,
tiernof759d822018-06-11 18:54:54 +0200556 "scaleVnfData": {
557 "type": "object",
558 "properties": {
559 "vnfInstanceId": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100560 "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]},
tiernof759d822018-06-11 18:54:54 +0200561 "scaleByStepData": {
562 "type": "object",
563 "properties": {
564 "scaling-group-descriptor": name_schema,
565 "member-vnf-index": name_schema,
566 "scaling-policy": name_schema,
567 },
568 "required": ["scaling-group-descriptor", "member-vnf-index"],
garciadeblas4568a372021-03-24 09:19:48 +0100569 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200570 },
571 },
572 "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId
garciadeblas4568a372021-03-24 09:19:48 +0100573 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200574 },
575 "scaleTime": time_schema,
576 },
577 "required": ["scaleType", "scaleVnfData"],
garciadeblas4568a372021-03-24 09:19:48 +0100578 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200579}
tierno65acb4d2018-04-06 16:42:40 +0200580
elumalai8e3806c2022-04-28 17:26:24 +0530581ns_migrate = {
582 "title": "ns migrate input schema",
583 "$schema": "http://json-schema.org/draft-04/schema#",
584 "type": "object",
585 "properties": {
586 "lcmOperationType": string_schema,
587 "nsInstanceId": id_schema,
588 "vnfInstanceId": id_schema,
589 "migrateToHost": string_schema,
590 "vdu": {
591 "type": "object",
garciadeblasf2af4a12023-01-24 16:56:54 +0100592 "properties": {
593 "vduId": name_schema,
594 "vduCountIndex": integer0_schema,
595 },
596 "required": ["vduId"],
597 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530598 },
599 },
600 "required": ["vnfInstanceId"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100601 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530602}
tierno65acb4d2018-04-06 16:42:40 +0200603
garciadeblas0964edf2022-02-11 00:43:44 +0100604ns_heal = {
605 "title": "ns heal input schema",
606 "$schema": "http://json-schema.org/draft-04/schema#",
607 "type": "object",
608 "properties": {
609 "lcmOperationType": string_schema,
610 "nsInstanceId": id_schema,
611 "timeout_ns_heal": integer1_schema,
612 "healVnfData": {
613 "type": "array",
614 "items": {
615 "type": "object",
616 "properties": {
617 "vnfInstanceId": id_schema,
618 "cause": description_schema,
619 "additionalParams": {
620 "type": "object",
621 "properties": {
622 "run-day1": bool_schema,
623 "vdu": {
624 "type": "array",
625 "items": {
626 "type": "object",
627 "properties": {
628 "run-day1": bool_schema,
629 "vdu-id": name_schema,
630 "count-index": integer0_schema,
631 },
632 "required": ["vdu-id"],
633 "additionalProperties": False,
634 },
635 },
636 },
637 "additionalProperties": False,
638 },
639 },
640 "required": ["vnfInstanceId"],
641 "additionalProperties": False,
642 },
643 },
644 },
645 "required": ["healVnfData"],
646 "additionalProperties": False,
647}
648
Gabriel Cuba84a60df2023-10-30 14:01:54 -0500649nslcmop_cancel = {
650 "title": "Cancel nslcmop input schema",
651 "$schema": "http://json-schema.org/draft-04/schema#",
652 "type": "object",
653 "properties": {
654 "nsLcmOpOccId": id_schema,
655 "cancelMode": {
656 "enum": [
657 "GRACEFUL",
658 "FORCEFUL",
659 ]
660 },
661 },
662 "required": ["cancelMode"],
663 "additionalProperties": False,
664}
665
tierno0f98af52018-03-19 10:28:22 +0100666schema_version = {"type": "string", "enum": ["1.0"]}
tierno55ba2e62018-12-11 17:22:22 +0000667schema_type = {"type": "string"}
tiernob3d0a0e2019-11-13 15:57:51 +0000668vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200669
tierno09c073e2018-04-26 13:36:48 +0200670vim_account_edit_schema = {
671 "title": "vim_account edit input schema",
672 "$schema": "http://json-schema.org/draft-04/schema#",
673 "type": "object",
674 "properties": {
675 "name": name_schema,
676 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200677 "vim": name_schema,
678 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200679 "vim_type": vim_type,
tierno09c073e2018-04-26 13:36:48 +0200680 "vim_url": description_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200681 # "vim_url_admin": description_schema,
682 # "vim_tenant": name_schema,
tierno09c073e2018-04-26 13:36:48 +0200683 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200684 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200685 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200686 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100687 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000688 "prometheus-config": {"type": "object"},
tierno09c073e2018-04-26 13:36:48 +0200689 },
garciadeblas4568a372021-03-24 09:19:48 +0100690 "additionalProperties": False,
tierno09c073e2018-04-26 13:36:48 +0200691}
tierno0f98af52018-03-19 10:28:22 +0100692
tierno09c073e2018-04-26 13:36:48 +0200693vim_account_new_schema = {
694 "title": "vim_account creation input schema",
tierno0f98af52018-03-19 10:28:22 +0100695 "$schema": "http://json-schema.org/draft-04/schema#",
696 "type": "object",
697 "properties": {
698 "schema_version": schema_version,
699 "schema_type": schema_type,
700 "name": name_schema,
701 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200702 "vim": name_schema,
703 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200704 "vim_type": vim_type,
tierno0f98af52018-03-19 10:28:22 +0100705 "vim_url": description_schema,
706 # "vim_url_admin": description_schema,
707 # "vim_tenant": name_schema,
708 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200709 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200710 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200711 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100712 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000713 "prometheus-config": {"type": "object"},
tierno0f98af52018-03-19 10:28:22 +0100714 },
garciadeblas4568a372021-03-24 09:19:48 +0100715 "required": [
716 "name",
717 "vim_url",
718 "vim_type",
719 "vim_user",
720 "vim_password",
721 "vim_tenant_name",
722 ],
723 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100724}
tierno0f98af52018-03-19 10:28:22 +0100725
tierno85807722019-12-20 14:11:35 +0000726wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200727
tierno55ba2e62018-12-11 17:22:22 +0000728wim_account_edit_schema = {
729 "title": "wim_account edit input schema",
730 "$schema": "http://json-schema.org/draft-04/schema#",
731 "type": "object",
732 "properties": {
733 "name": name_schema,
734 "description": description_schema,
tierno55ba2e62018-12-11 17:22:22 +0000735 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200736 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000737 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100738 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000739 "password": passwd_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100740 "config": {"type": "object"},
tierno55ba2e62018-12-11 17:22:22 +0000741 },
garciadeblas4568a372021-03-24 09:19:48 +0100742 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000743}
744
745wim_account_new_schema = {
746 "title": "wim_account creation input schema",
747 "$schema": "http://json-schema.org/draft-04/schema#",
748 "type": "object",
749 "properties": {
750 "schema_version": schema_version,
751 "schema_type": schema_type,
752 "name": name_schema,
753 "description": description_schema,
754 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200755 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000756 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100757 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000758 "password": passwd_schema,
tiernof0637052019-03-07 16:26:47 +0000759 "config": {
760 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100761 "patternProperties": {".": {"not": {"type": "null"}}},
762 },
tierno55ba2e62018-12-11 17:22:22 +0000763 },
764 "required": ["name", "wim_url", "wim_type"],
garciadeblas4568a372021-03-24 09:19:48 +0100765 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000766}
tierno0f98af52018-03-19 10:28:22 +0100767
768sdn_properties = {
769 "name": name_schema,
tierno7adaeb02019-12-17 16:46:12 +0000770 "type": {"type": "string"},
771 "url": {"type": "string"},
sousaedu80b6fed2021-10-07 15:17:32 +0100772 "user": string_schema,
tierno7adaeb02019-12-17 16:46:12 +0000773 "password": passwd_schema,
774 "config": {"type": "object"},
tiernocfb07c62018-05-10 18:30:51 +0200775 "description": description_schema,
tierno7adaeb02019-12-17 16:46:12 +0000776 # The folowing are deprecated. Maintanied for backward compatibility
tiernocb83c942018-09-24 17:28:13 +0200777 "dpid": dpid_Schema,
tierno0f98af52018-03-19 10:28:22 +0100778 "ip": ip_schema,
779 "port": port_schema,
tierno0f98af52018-03-19 10:28:22 +0100780 "version": {"type": "string", "minLength": 1, "maxLength": 12},
tierno0f98af52018-03-19 10:28:22 +0100781}
782sdn_new_schema = {
783 "title": "sdn controller information schema",
784 "$schema": "http://json-schema.org/draft-04/schema#",
785 "type": "object",
786 "properties": sdn_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100787 "required": ["name", "type"],
788 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100789}
790sdn_edit_schema = {
791 "title": "sdn controller update information schema",
792 "$schema": "http://json-schema.org/draft-04/schema#",
793 "type": "object",
794 "properties": sdn_properties,
tiernocfb07c62018-05-10 18:30:51 +0200795 # "required": ["name", "port", 'ip', 'dpid', 'type'],
garciadeblas4568a372021-03-24 09:19:48 +0100796 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100797}
798sdn_port_mapping_schema = {
799 "$schema": "http://json-schema.org/draft-04/schema#",
800 "title": "sdn port mapping information schema",
801 "type": "array",
802 "items": {
803 "type": "object",
804 "properties": {
tiernofd160572019-01-21 10:41:37 +0000805 "compute_node": shortname_schema,
tierno0f98af52018-03-19 10:28:22 +0100806 "ports": {
807 "type": "array",
808 "items": {
809 "type": "object",
810 "properties": {
tierno42fce592018-11-02 09:23:43 +0100811 "pci": pci_extended_schema,
tiernofd160572019-01-21 10:41:37 +0000812 "switch_port": shortname_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100813 "switch_mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100814 },
garciadeblas4568a372021-03-24 09:19:48 +0100815 "required": ["pci"],
816 },
817 },
tierno0f98af52018-03-19 10:28:22 +0100818 },
garciadeblas4568a372021-03-24 09:19:48 +0100819 "required": ["compute_node", "ports"],
820 },
tierno0f98af52018-03-19 10:28:22 +0100821}
822sdn_external_port_schema = {
823 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocd54a4a2018-09-12 16:40:35 +0200824 "title": "External port information",
tierno0f98af52018-03-19 10:28:22 +0100825 "type": "object",
826 "properties": {
827 "port": {"type": "string", "minLength": 1, "maxLength": 60},
828 "vlan": vlan_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100829 "mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100830 },
garciadeblas4568a372021-03-24 09:19:48 +0100831 "required": ["port"],
tierno0f98af52018-03-19 10:28:22 +0100832}
833
delacruzramofe598fe2019-10-23 18:25:11 +0200834# K8s Clusters
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500835k8scluster_deploy_method_schema = {
836 "$schema": "http://json-schema.org/draft-04/schema#",
837 "title": "Deployment methods for K8s cluster",
838 "type": "object",
839 "properties": {
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500840 "juju-bundle": {"type": "boolean"},
841 "helm-chart-v3": {"type": "boolean"},
842 },
843 "additionalProperties": False,
Luis Vega0a1efed2023-11-28 16:44:30 +0000844 "minProperties": 2,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500845}
delacruzramofe598fe2019-10-23 18:25:11 +0200846k8scluster_nets_schema = {
847 "title": "k8scluster nets input schema",
848 "$schema": "http://json-schema.org/draft-04/schema#",
849 "type": "object",
tierno8c81ab02020-02-07 10:18:30 +0000850 "patternProperties": {".": {"oneOf": [name_schema, null_schema]}},
delacruzramofe598fe2019-10-23 18:25:11 +0200851 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100852 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200853}
854k8scluster_new_schema = {
855 "title": "k8scluster creation input schema",
856 "$schema": "http://json-schema.org/draft-04/schema#",
857 "type": "object",
858 "properties": {
859 "schema_version": schema_version,
860 "schema_type": schema_type,
861 "name": name_schema,
862 "description": description_schema,
863 "credentials": object_schema,
864 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200865 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200866 "k8s_version": string_schema,
867 "nets": k8scluster_nets_schema,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500868 "deployment_methods": k8scluster_deploy_method_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200869 "namespace": name_schema,
870 "cni": nameshort_list_schema,
871 },
872 "required": ["name", "credentials", "vim_account", "k8s_version", "nets"],
garciadeblas4568a372021-03-24 09:19:48 +0100873 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200874}
875k8scluster_edit_schema = {
876 "title": "vim_account edit input schema",
877 "$schema": "http://json-schema.org/draft-04/schema#",
878 "type": "object",
879 "properties": {
880 "name": name_schema,
881 "description": description_schema,
882 "credentials": object_schema,
883 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200884 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200885 "k8s_version": string_schema,
886 "nets": k8scluster_nets_schema,
887 "namespace": name_schema,
888 "cni": nameshort_list_schema,
889 },
garciadeblas4568a372021-03-24 09:19:48 +0100890 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200891}
892
David Garciaecb41322021-03-31 19:10:46 +0200893# VCA
894vca_new_schema = {
895 "title": "vca creation input schema",
896 "$schema": "http://json-schema.org/draft-04/schema#",
897 "type": "object",
898 "properties": {
899 "schema_version": schema_version,
900 "schema_type": schema_type,
901 "name": name_schema,
902 "description": description_schema,
903 "endpoints": description_list_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100904 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200905 "secret": passwd_schema,
906 "cacert": long_description_schema,
907 "lxd-cloud": shortname_schema,
908 "lxd-credentials": shortname_schema,
909 "k8s-cloud": shortname_schema,
910 "k8s-credentials": shortname_schema,
911 "model-config": object_schema,
912 },
913 "required": [
914 "name",
915 "endpoints",
916 "user",
917 "secret",
918 "cacert",
919 "lxd-cloud",
920 "lxd-credentials",
921 "k8s-cloud",
922 "k8s-credentials",
923 ],
924 "additionalProperties": False,
925}
926vca_edit_schema = {
927 "title": "vca creation input schema",
928 "$schema": "http://json-schema.org/draft-04/schema#",
929 "type": "object",
930 "properties": {
931 "name": name_schema,
932 "description": description_schema,
933 "endpoints": description_list_schema,
934 "port": integer1_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100935 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200936 "secret": passwd_schema,
937 "cacert": long_description_schema,
938 "lxd-cloud": shortname_schema,
939 "lxd-credentials": shortname_schema,
940 "k8s-cloud": shortname_schema,
941 "k8s-credentials": shortname_schema,
942 "model-config": object_schema,
943 },
944 "additionalProperties": False,
945}
946
delacruzramofe598fe2019-10-23 18:25:11 +0200947# K8s Repos
tierno332e0802019-12-03 23:50:49 +0000948k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]}
delacruzramofe598fe2019-10-23 18:25:11 +0200949k8srepo_properties = {
950 "name": name_schema,
951 "description": description_schema,
952 "type": k8srepo_types,
953 "url": description_schema,
Luis Vegaf6574e32023-07-11 18:47:22 +0000954 "cacert": long_description_schema,
955 "user": string_schema,
956 "password": passwd_schema,
garciadeblasf3543892023-10-20 11:53:51 +0200957 "oci": bool_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200958}
959k8srepo_new_schema = {
960 "title": "k8scluster creation input schema",
961 "$schema": "http://json-schema.org/draft-04/schema#",
962 "type": "object",
963 "properties": k8srepo_properties,
964 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100965 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200966}
967k8srepo_edit_schema = {
968 "title": "vim_account edit input schema",
969 "$schema": "http://json-schema.org/draft-04/schema#",
970 "type": "object",
971 "properties": k8srepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100972 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200973}
974
Felipe Vicensb66b0412020-05-06 10:11:00 +0200975# OSM Repos
976osmrepo_types = {"enum": ["osm"]}
977osmrepo_properties = {
978 "name": name_schema,
979 "description": description_schema,
980 "type": osmrepo_types,
rshri2d386cb2024-07-05 14:35:51 +0000981 "url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100982 # "user": string_schema,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200983 # "password": passwd_schema
984}
985osmrepo_new_schema = {
986 "title": "osm repo creation input schema",
987 "$schema": "http://json-schema.org/draft-04/schema#",
988 "type": "object",
989 "properties": osmrepo_properties,
990 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100991 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200992}
993osmrepo_edit_schema = {
994 "title": "osm repo edit input schema",
995 "$schema": "http://json-schema.org/draft-04/schema#",
996 "type": "object",
997 "properties": osmrepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100998 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200999}
1000
tiernocb83c942018-09-24 17:28:13 +02001001# PDUs
1002pdu_interface = {
1003 "type": "object",
1004 "properties": {
tiernofd160572019-01-21 10:41:37 +00001005 "name": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001006 "mgmt": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001007 "type": {"enum": ["overlay", "underlay"]},
garciadeblas1a01e1f2021-10-26 17:27:35 +02001008 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernocb83c942018-09-24 17:28:13 +02001009 # TODO, add user, password, ssh-key
tierno36ec8602018-11-02 17:27:11 +01001010 "mac-address": mac_schema,
tiernofd160572019-01-21 10:41:37 +00001011 "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
1012 "vim-network-id": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001013 # # provide this in case SDN assist must deal with this interface
1014 # "switch-dpid": dpid_Schema,
tiernofd160572019-01-21 10:41:37 +00001015 # "switch-port": shortname_schema,
1016 # "switch-mac": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +01001017 # "switch-vlan": vlan_schema,
tiernocb83c942018-09-24 17:28:13 +02001018 },
tierno36ec8602018-11-02 17:27:11 +01001019 "required": ["name", "mgmt", "ip-address"],
garciadeblas4568a372021-03-24 09:19:48 +01001020 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001021}
tiernocb83c942018-09-24 17:28:13 +02001022pdu_new_schema = {
1023 "title": "pdu creation input schema",
1024 "$schema": "http://json-schema.org/draft-04/schema#",
1025 "type": "object",
1026 "properties": {
tiernofd160572019-01-21 10:41:37 +00001027 "name": shortname_schema,
1028 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001029 "description": description_schema,
1030 "shared": bool_schema,
1031 "vims": nameshort_list_schema,
1032 "vim_accounts": nameshort_list_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001033 "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1},
tiernocb83c942018-09-24 17:28:13 +02001034 },
1035 "required": ["name", "type", "interfaces"],
garciadeblas4568a372021-03-24 09:19:48 +01001036 "additionalProperties": False,
tiernocb83c942018-09-24 17:28:13 +02001037}
tiernocb83c942018-09-24 17:28:13 +02001038pdu_edit_schema = {
1039 "title": "pdu edit input schema",
1040 "$schema": "http://json-schema.org/draft-04/schema#",
1041 "type": "object",
1042 "properties": {
tiernofd160572019-01-21 10:41:37 +00001043 "name": shortname_schema,
1044 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001045 "description": description_schema,
1046 "shared": bool_schema,
garciadeblas84bdd552018-11-30 22:59:45 +01001047 "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
1048 "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
garciadeblas4568a372021-03-24 09:19:48 +01001049 "interfaces": {
1050 "oneOf": [
1051 array_edition_schema,
1052 {"type": "array", "items": pdu_interface, "minItems": 1},
1053 ]
1054 },
tiernocb83c942018-09-24 17:28:13 +02001055 },
1056 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001057 "minProperties": 1,
tiernocb83c942018-09-24 17:28:13 +02001058}
1059
delacruzramo271d2002019-12-02 21:00:37 +01001060# VNF PKG OPERATIONS
1061vnfpkgop_new_schema = {
1062 "title": "VNF PKG operation creation input schema",
1063 "$schema": "http://json-schema.org/draft-04/schema#",
1064 "type": "object",
1065 "properties": {
1066 "lcmOperationType": string_schema,
1067 "vnfPkgId": id_schema,
1068 "kdu_name": name_schema,
1069 "primitive": name_schema,
1070 "primitive_params": {"type": "object"},
1071 },
garciadeblas4568a372021-03-24 09:19:48 +01001072 "required": [
1073 "lcmOperationType",
1074 "vnfPkgId",
1075 "kdu_name",
1076 "primitive",
1077 "primitive_params",
1078 ],
1079 "additionalProperties": False,
delacruzramo271d2002019-12-02 21:00:37 +01001080}
1081
rshri2d386cb2024-07-05 14:35:51 +00001082clustercreation_new_schema = {
1083 "title": "cluster creation operation input schema",
1084 "$schema": "http://json-schema.org/draft-04/schema#",
1085 "type": "object",
1086 "properties": {
1087 "name": name_schema,
1088 "vim_account": string_schema,
1089 "k8s_version": string_schema,
1090 "node_size": string_schema,
1091 "node_count": integer0_schema,
rshri17b09ec2024-11-07 05:48:12 +00001092 "description": description_schema,
rshri2d386cb2024-07-05 14:35:51 +00001093 "region_name": string_schema,
1094 "resource_group": string_schema,
1095 "infra_controller_profiles": shortname_schema,
1096 "infra_config_profiles": shortname_schema,
1097 "resource_profiles": shortname_schema,
1098 "app_profiles": shortname_schema,
rshri17b09ec2024-11-07 05:48:12 +00001099 "created": string_schema,
1100 "state": string_schema,
1101 "operatingState": string_schema,
1102 "git_name": string_schema,
1103 "resourceState": string_schema,
1104 "bootstrap": bool_schema,
rshri2d386cb2024-07-05 14:35:51 +00001105 },
1106 "required": [
1107 "name",
1108 "vim_account",
1109 "k8s_version",
1110 "node_size",
1111 "node_count",
rshri2d386cb2024-07-05 14:35:51 +00001112 ],
1113 "additionalProperties": False,
1114}
rshri17b09ec2024-11-07 05:48:12 +00001115clusterregistration_new_schema = {
1116 "title": "cluster registration input schema",
1117 "$schema": "http://json-schema.org/draft-04/schema#",
1118 "type": "object",
1119 "properties": {
1120 "schema_version": schema_version,
1121 "schema_type": schema_type,
1122 "name": name_schema,
1123 "description": description_schema,
1124 "credentials": object_schema,
1125 "vim_account": string_schema,
1126 "bootstrap": bool_schema,
1127 },
1128 "required": ["name", "credentials", "vim_account"],
1129 "additionalProperties": False,
1130}
rshri2d386cb2024-07-05 14:35:51 +00001131
yshah99122b82024-11-18 07:05:29 +00001132cluster_edit_schema = {
1133 "title": "cluster edit schema",
1134 "$schema": "http://json-schema.org/draft-04/schema#",
1135 "type": "object",
1136 "properties": {
1137 "name": name_schema,
1138 "description": string_schema,
1139 },
1140 "additionalProperties": False,
1141}
1142
1143cluster_update_schema = {
1144 "title": "cluster update schema",
1145 "$schema": "http://json-schema.org/draft-04/schema#",
1146 "type": "object",
1147 "properties": {
1148 "k8s_version": string_schema,
1149 "node_size": string_schema,
1150 "node_count": integer0_schema,
1151 },
1152 "additionalProperties": True,
1153}
1154
rshri2d386cb2024-07-05 14:35:51 +00001155infra_controller_profile_create_new_schema = {
1156 "title": "infra profile creation operation input schema",
1157 "$schema": "http://json-schema.org/draft-04/schema#",
1158 "type": "object",
1159 "properties": {
1160 "name": name_schema,
1161 "description": string_schema,
1162 },
1163 "additionalProperties": False,
1164}
1165
1166infra_controller_profile_create_edit_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_config_profile_create_new_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_edit_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
1199app_profile_create_new_schema = {
1200 "title": "app 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}
1209app_profile_create_edit_schema = {
1210 "title": "app profile creation operation input schema",
1211 "$schema": "http://json-schema.org/draft-04/schema#",
1212 "type": "object",
1213 "properties": {
1214 "name": name_schema,
1215 "description": string_schema,
1216 },
1217 "additionalProperties": False,
1218}
1219
1220resource_profile_create_new_schema = {
1221 "title": "resource 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}
1230resource_profile_create_edit_schema = {
1231 "title": "resource profile creation operation input schema",
1232 "$schema": "http://json-schema.org/draft-04/schema#",
1233 "type": "object",
1234 "properties": {
1235 "name": name_schema,
1236 "description": string_schema,
1237 },
1238 "additionalProperties": False,
1239}
1240
1241attach_profile = {
1242 "type": "array",
1243 "items": {
1244 "type": "object",
1245 "properties": {"id": id_schema},
1246 "additionalProperties": False,
1247 },
1248}
1249remove_profile = {
1250 "type": "array",
1251 "items": {
1252 "type": "object",
1253 "properties": {"id": id_schema},
1254 "additionalProperties": False,
1255 },
1256}
1257attach_dettach_profile_schema = {
1258 "title": "attach/dettach profiles",
1259 "$schema": "http://json-schema.org/draft-04/schema#",
1260 "type": "object",
1261 "properties": {
1262 "add_profile": attach_profile,
1263 "remove_profile": remove_profile,
1264 },
1265 "additionalProperties": False,
1266}
tiernocb83c942018-09-24 17:28:13 +02001267# USERS
tiernocf042d32019-06-13 09:06:40 +00001268project_role_mappings = {
1269 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001270 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001271 "type": "array",
1272 "items": {
1273 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001274 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001275 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001276 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001277 },
garciadeblas4568a372021-03-24 09:19:48 +01001278 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001279}
rshri2d386cb2024-07-05 14:35:51 +00001280
tiernocf042d32019-06-13 09:06:40 +00001281project_role_mappings_optional = {
1282 "title": "list of projects/roles or projects only",
1283 "$schema": "http://json-schema.org/draft-04/schema#",
1284 "type": "array",
1285 "items": {
1286 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001287 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001288 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001289 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001290 },
garciadeblas4568a372021-03-24 09:19:48 +01001291 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001292}
rshri2d386cb2024-07-05 14:35:51 +00001293
tiernocd54a4a2018-09-12 16:40:35 +02001294user_new_schema = {
1295 "$schema": "http://json-schema.org/draft-04/schema#",
1296 "title": "New user schema",
1297 "type": "object",
1298 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001299 "username": string_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001300 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001301 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001302 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001303 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001304 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001305 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001306 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001307 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001308}
1309user_edit_schema = {
1310 "$schema": "http://json-schema.org/draft-04/schema#",
1311 "title": "User edit schema for administrators",
1312 "type": "object",
1313 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001314 "password": user_passwd_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001315 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001316 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001317 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001318 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001319 "project_role_mappings": project_role_mappings,
1320 "add_project_role_mappings": project_role_mappings,
1321 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001322 "system_admin_id": id_schema,
1323 "unlock": bool_schema,
1324 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001325 },
1326 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001327 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001328}
1329
1330# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001331topics_with_quota = [
1332 "vnfds",
1333 "nsds",
1334 "slice_templates",
1335 "pduds",
1336 "ns_instances",
1337 "slice_instances",
1338 "vim_accounts",
1339 "wim_accounts",
1340 "sdn_controllers",
1341 "k8sclusters",
1342 "vca",
1343 "k8srepos",
1344 "osmrepos",
1345 "ns_subscriptions",
1346]
tiernocd54a4a2018-09-12 16:40:35 +02001347project_new_schema = {
1348 "$schema": "http://json-schema.org/draft-04/schema#",
1349 "title": "New project schema for administrators",
1350 "type": "object",
1351 "properties": {
tiernofd160572019-01-21 10:41:37 +00001352 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001353 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001354 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001355 "quotas": {
1356 "type": "object",
1357 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001358 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001359 },
tiernocd54a4a2018-09-12 16:40:35 +02001360 },
1361 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001362 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001363}
1364project_edit_schema = {
1365 "$schema": "http://json-schema.org/draft-04/schema#",
1366 "title": "Project edit schema for administrators",
1367 "type": "object",
1368 "properties": {
1369 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001370 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001371 "quotas": {
1372 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001373 "properties": {
1374 topic: {"oneOf": [integer0_schema, null_schema]}
1375 for topic in topics_with_quota
1376 },
1377 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001378 },
tiernocd54a4a2018-09-12 16:40:35 +02001379 },
1380 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001381 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001382}
1383
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001384# ROLES
1385roles_new_schema = {
1386 "$schema": "http://json-schema.org/draft-04/schema#",
1387 "title": "New role schema for administrators",
1388 "type": "object",
1389 "properties": {
1390 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001391 "permissions": {
1392 "type": "object",
1393 "patternProperties": {
1394 ".": bool_schema,
1395 },
1396 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001397 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001398 },
tierno1f029d82019-06-13 22:37:04 +00001399 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001400 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001401}
1402roles_edit_schema = {
1403 "$schema": "http://json-schema.org/draft-04/schema#",
1404 "title": "Roles edit schema for administrators",
1405 "type": "object",
1406 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001407 "name": shortname_schema,
1408 "permissions": {
1409 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001410 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001411 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001412 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001413 },
tierno1f029d82019-06-13 22:37:04 +00001414 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001415 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001416}
1417
tiernocd54a4a2018-09-12 16:40:35 +02001418# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001419
1420nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001421 "users": user_new_schema,
1422 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001423 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001424 "sdns": sdn_new_schema,
1425 "ns_instantiate": ns_instantiate,
1426 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001427 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001428 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001429 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001430 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001431}
1432
1433nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001434 "users": user_edit_schema,
1435 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001436 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001437 "sdns": sdn_edit_schema,
1438 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301439 "vnf": vnf_schema,
1440 "vld": vld_schema,
1441 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001442}
1443
Felipe Vicens07f31722018-10-29 15:16:44 +01001444# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001445nsi_subnet_instantiate = deepcopy(ns_instantiate)
1446nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1447nsi_subnet_instantiate["properties"]["id"] = name_schema
1448del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001449
1450nsi_vld_instantiate = {
1451 "title": "netslice vld instantiation params input schema",
1452 "$schema": "http://json-schema.org/draft-04/schema#",
1453 "type": "object",
1454 "properties": {
1455 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001456 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1457 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001458 "ip-profile": object_schema,
1459 },
delacruzramoc061f562019-04-05 11:00:02 +02001460 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001461 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001462}
1463
Felipe Vicens07f31722018-10-29 15:16:44 +01001464nsi_instantiate = {
1465 "title": "netslice action instantiate input schema",
1466 "$schema": "http://json-schema.org/draft-04/schema#",
1467 "type": "object",
1468 "properties": {
1469 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001470 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001471 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001472 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001473 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001474 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001475 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001476 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001477 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001478 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001479 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001480 "type": "array",
1481 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001482 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001483 },
garciadeblas4568a372021-03-24 09:19:48 +01001484 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001485 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001486 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001487 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001488}
1489
garciadeblas4568a372021-03-24 09:19:48 +01001490nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001491
garciadeblas4568a372021-03-24 09:19:48 +01001492nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001493
preethika.p329b8182020-04-22 12:25:39 +05301494nsinstancesubscriptionfilter_schema = {
1495 "title": "instance identifier schema",
1496 "$schema": "http://json-schema.org/draft-07/schema#",
1497 "type": "object",
1498 "properties": {
1499 "nsdIds": {"type": "array"},
1500 "vnfdIds": {"type": "array"},
1501 "pnfdIds": {"type": "array"},
1502 "nsInstanceIds": {"type": "array"},
1503 "nsInstanceNames": {"type": "array"},
1504 },
1505}
1506
1507nslcmsub_schema = {
1508 "title": "nslcmsubscription input schema",
1509 "$schema": "http://json-schema.org/draft-07/schema#",
1510 "type": "object",
1511 "properties": {
1512 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1513 "notificationTypes": {
1514 "type": "array",
1515 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001516 "enum": [
1517 "NsLcmOperationOccurrenceNotification",
1518 "NsChangeNotification",
1519 "NsIdentifierCreationNotification",
1520 "NsIdentifierDeletionNotification",
1521 ]
1522 },
preethika.p329b8182020-04-22 12:25:39 +05301523 },
1524 "operationTypes": {
1525 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001526 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301527 },
1528 "operationStates": {
1529 "type": "array",
1530 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001531 "enum": [
1532 "PROCESSING",
1533 "COMPLETED",
1534 "PARTIALLY_COMPLETED",
1535 "FAILED",
1536 "FAILED_TEMP",
1537 "ROLLING_BACK",
1538 "ROLLED_BACK",
1539 ]
1540 },
preethika.p329b8182020-04-22 12:25:39 +05301541 },
garciadeblas4568a372021-03-24 09:19:48 +01001542 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301543 "lcmOpNameImpactingNsComponent": {
1544 "type": "array",
1545 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001546 "enum": [
1547 "VNF_INSTANTIATE",
1548 "VNF_SCALE",
1549 "VNF_SCALE_TO_LEVEL",
1550 "VNF_CHANGE_FLAVOUR",
1551 "VNF_TERMINATE",
1552 "VNF_HEAL",
1553 "VNF_OPERATE",
1554 "VNF_CHANGE_EXT_CONN",
1555 "VNF_MODIFY_INFO",
1556 "NS_INSTANTIATE",
1557 "NS_SCALE",
1558 "NS_UPDATE",
1559 "NS_TERMINATE",
1560 "NS_HEAL",
1561 ]
1562 },
preethika.p329b8182020-04-22 12:25:39 +05301563 },
1564 "lcmOpOccStatusImpactingNsComponent": {
1565 "type": "array",
1566 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001567 "enum": [
1568 "START",
1569 "COMPLETED",
1570 "PARTIALLY_COMPLETED",
1571 "FAILED",
1572 "ROLLED_BACK",
1573 ]
1574 },
preethika.p329b8182020-04-22 12:25:39 +05301575 },
1576 },
1577 "allOf": [
1578 {
1579 "if": {
1580 "properties": {
1581 "notificationTypes": {
1582 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1583 }
1584 },
1585 },
1586 "then": {
1587 "anyOf": [
1588 {"required": ["operationTypes"]},
1589 {"required": ["operationStates"]},
1590 ]
garciadeblas4568a372021-03-24 09:19:48 +01001591 },
preethika.p329b8182020-04-22 12:25:39 +05301592 },
1593 {
1594 "if": {
1595 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001596 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301597 },
1598 },
1599 "then": {
1600 "anyOf": [
1601 {"required": ["nsComponentTypes"]},
1602 {"required": ["lcmOpNameImpactingNsComponent"]},
1603 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1604 ]
garciadeblas4568a372021-03-24 09:19:48 +01001605 },
1606 },
1607 ],
preethika.p329b8182020-04-22 12:25:39 +05301608}
1609
1610authentication_schema = {
1611 "title": "authentication schema for subscription",
1612 "$schema": "http://json-schema.org/draft-07/schema#",
1613 "type": "object",
1614 "properties": {
1615 "authType": {"enum": ["basic"]},
1616 "paramsBasic": {
1617 "type": "object",
1618 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001619 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301620 "password": passwd_schema,
1621 },
1622 },
1623 },
1624}
1625
1626subscription = {
1627 "title": "subscription input schema",
1628 "$schema": "http://json-schema.org/draft-07/schema#",
1629 "type": "object",
1630 "properties": {
1631 "filter": nslcmsub_schema,
1632 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001633 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301634 },
1635 "required": ["CallbackUri"],
1636}
1637
selvi.jf1004592022-04-29 05:42:35 +00001638vnflcmsub_schema = {
1639 "title": "vnflcmsubscription input schema",
1640 "$schema": "http://json-schema.org/draft-07/schema#",
1641 "type": "object",
1642 "properties": {
1643 "VnfInstanceSubscriptionFilter": {
1644 "type": "object",
1645 "properties": {
1646 "vnfdIds": {"type": "array"},
1647 "vnfInstanceIds": {"type": "array"},
1648 },
1649 },
1650 "notificationTypes": {
1651 "type": "array",
1652 "items": {
1653 "enum": [
1654 "VnfIdentifierCreationNotification",
1655 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001656 "VnfIdentifierDeletionNotification",
1657 ]
1658 },
selvi.jf1004592022-04-29 05:42:35 +00001659 },
1660 "operationTypes": {
1661 "type": "array",
1662 "items": {
1663 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001664 "INSTANTIATE",
1665 "SCALE",
1666 "SCALE_TO_LEVEL",
1667 "CHANGE_FLAVOUR",
1668 "TERMINATE",
1669 "HEAL",
1670 "OPERATE",
1671 "CHANGE_EXT_CONN",
1672 "MODIFY_INFO",
1673 "CREATE_SNAPSHOT",
1674 "REVERT_TO_SNAPSHOT",
1675 "CHANGE_VNFPKG",
1676 ]
1677 },
selvi.jf1004592022-04-29 05:42:35 +00001678 },
1679 "operationStates": {
1680 "type": "array",
1681 "items": {
1682 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001683 "STARTING",
1684 "PROCESSING",
1685 "COMPLETED",
1686 "FAILED_TEMP",
1687 "FAILED",
1688 "ROLLING_BACK",
1689 "ROLLED_BACK",
1690 ]
1691 },
1692 },
selvi.jf1004592022-04-29 05:42:35 +00001693 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001694 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1695}
selvi.jf1004592022-04-29 05:42:35 +00001696
1697vnf_subscription = {
1698 "title": "vnf subscription input schema",
1699 "$schema": "http://json-schema.org/draft-07/schema#",
1700 "type": "object",
1701 "properties": {
1702 "filter": vnflcmsub_schema,
1703 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001704 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001705 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001706 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001707}
1708
yshah53cc9eb2024-07-05 13:06:31 +00001709oka_schema = {
1710 "title": "Create OKA package input schema",
1711 "$schema": "http://json-schema.org/draft-07/schema#",
1712 "type": "object",
1713 "properties": {
1714 "name": name_schema,
1715 "description": description_schema,
1716 },
1717 "additionalProperties": False,
1718}
1719
1720ksu_schema = {
1721 "title": "ksu schema",
1722 "$schema": "http://json-schema.org/draft-07/schema#",
1723 "type": "object",
1724 "properties": {
1725 "name": name_schema,
1726 "description": description_schema,
1727 "profile": {
1728 "type": "object",
1729 "properties": {
1730 "profile_type": string_schema,
1731 "_id": id_schema,
1732 },
1733 "additionalProperties": False,
1734 },
1735 "oka": {
1736 "type": "array",
1737 "items": {
1738 "type": "object",
1739 "properties": {
1740 "_id": id_schema,
1741 "sw_catalog_path": string_schema,
1742 "transformation": object_schema,
1743 },
1744 "additionalProperties": False,
1745 },
1746 },
1747 },
1748 "additionalProperties": False,
1749}
1750
tierno0f98af52018-03-19 10:28:22 +01001751
1752class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001753 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1754 self.http_code = http_code
1755 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001756
1757
tiernob24258a2018-10-04 18:39:49 +02001758def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001759 """
tiernocd54a4a2018-09-12 16:40:35 +02001760 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001761 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001762 :param schema_to_use: jsonschema to test
1763 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001764 """
1765 try:
tierno0f98af52018-03-19 10:28:22 +01001766 if schema_to_use:
1767 js_v(indata, schema_to_use)
1768 return None
1769 except js_e.ValidationError as e:
1770 if e.path:
tierno0da52252018-06-27 15:47:22 +02001771 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001772 else:
1773 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001774 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001775 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001776 raise ValidationError(
1777 "Bad json schema {}".format(schema_to_use),
1778 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1779 )
delacruzramoc061f562019-04-05 11:00:02 +02001780
1781
1782def is_valid_uuid(x):
1783 """
1784 Test for a valid UUID
1785 :param x: string to test
1786 :return: True if x is a valid uuid, False otherwise
1787 """
1788 try:
1789 if UUID(x):
1790 return True
tiernobdebce92019-07-01 15:36:49 +00001791 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001792 return False