blob: e2923a4a77b6fda21b75c92744089fa45240e0b8 [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,
1092 "description": string_schema,
1093 "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,
1099 },
1100 "required": [
1101 "name",
1102 "vim_account",
1103 "k8s_version",
1104 "node_size",
1105 "node_count",
1106 "description",
1107 ],
1108 "additionalProperties": False,
1109}
1110
1111infra_controller_profile_create_new_schema = {
1112 "title": "infra profile creation operation input schema",
1113 "$schema": "http://json-schema.org/draft-04/schema#",
1114 "type": "object",
1115 "properties": {
1116 "name": name_schema,
1117 "description": string_schema,
1118 },
1119 "additionalProperties": False,
1120}
1121
1122infra_controller_profile_create_edit_schema = {
1123 "title": "infra profile creation operation input schema",
1124 "$schema": "http://json-schema.org/draft-04/schema#",
1125 "type": "object",
1126 "properties": {
1127 "name": name_schema,
1128 "description": string_schema,
1129 },
1130 "additionalProperties": False,
1131}
1132
1133infra_config_profile_create_new_schema = {
1134 "title": "infra profile creation operation input schema",
1135 "$schema": "http://json-schema.org/draft-04/schema#",
1136 "type": "object",
1137 "properties": {
1138 "name": name_schema,
1139 "description": string_schema,
1140 },
1141 "additionalProperties": False,
1142}
1143
1144infra_config_profile_create_edit_schema = {
1145 "title": "infra profile creation operation input schema",
1146 "$schema": "http://json-schema.org/draft-04/schema#",
1147 "type": "object",
1148 "properties": {
1149 "name": name_schema,
1150 "description": string_schema,
1151 },
1152 "additionalProperties": False,
1153}
1154
1155app_profile_create_new_schema = {
1156 "title": "app 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}
1165app_profile_create_edit_schema = {
1166 "title": "app profile creation operation input schema",
1167 "$schema": "http://json-schema.org/draft-04/schema#",
1168 "type": "object",
1169 "properties": {
1170 "name": name_schema,
1171 "description": string_schema,
1172 },
1173 "additionalProperties": False,
1174}
1175
1176resource_profile_create_new_schema = {
1177 "title": "resource profile creation operation input schema",
1178 "$schema": "http://json-schema.org/draft-04/schema#",
1179 "type": "object",
1180 "properties": {
1181 "name": name_schema,
1182 "description": string_schema,
1183 },
1184 "additionalProperties": False,
1185}
1186resource_profile_create_edit_schema = {
1187 "title": "resource profile creation operation input schema",
1188 "$schema": "http://json-schema.org/draft-04/schema#",
1189 "type": "object",
1190 "properties": {
1191 "name": name_schema,
1192 "description": string_schema,
1193 },
1194 "additionalProperties": False,
1195}
1196
1197attach_profile = {
1198 "type": "array",
1199 "items": {
1200 "type": "object",
1201 "properties": {"id": id_schema},
1202 "additionalProperties": False,
1203 },
1204}
1205remove_profile = {
1206 "type": "array",
1207 "items": {
1208 "type": "object",
1209 "properties": {"id": id_schema},
1210 "additionalProperties": False,
1211 },
1212}
1213attach_dettach_profile_schema = {
1214 "title": "attach/dettach profiles",
1215 "$schema": "http://json-schema.org/draft-04/schema#",
1216 "type": "object",
1217 "properties": {
1218 "add_profile": attach_profile,
1219 "remove_profile": remove_profile,
1220 },
1221 "additionalProperties": False,
1222}
tiernocb83c942018-09-24 17:28:13 +02001223# USERS
tiernocf042d32019-06-13 09:06:40 +00001224project_role_mappings = {
1225 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001226 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001227 "type": "array",
1228 "items": {
1229 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001230 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001231 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001232 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001233 },
garciadeblas4568a372021-03-24 09:19:48 +01001234 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001235}
rshri2d386cb2024-07-05 14:35:51 +00001236
tiernocf042d32019-06-13 09:06:40 +00001237project_role_mappings_optional = {
1238 "title": "list of projects/roles or projects only",
1239 "$schema": "http://json-schema.org/draft-04/schema#",
1240 "type": "array",
1241 "items": {
1242 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001243 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001244 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001245 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001246 },
garciadeblas4568a372021-03-24 09:19:48 +01001247 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001248}
rshri2d386cb2024-07-05 14:35:51 +00001249
tiernocd54a4a2018-09-12 16:40:35 +02001250user_new_schema = {
1251 "$schema": "http://json-schema.org/draft-04/schema#",
1252 "title": "New user schema",
1253 "type": "object",
1254 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001255 "username": string_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001256 "email_id": email_schema,
tiernoad6d5332020-02-19 14:29:49 +00001257 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001258 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001259 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001260 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001261 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001262 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001263 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001264}
1265user_edit_schema = {
1266 "$schema": "http://json-schema.org/draft-04/schema#",
1267 "title": "User edit schema for administrators",
1268 "type": "object",
1269 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001270 "password": user_passwd_schema,
jeganbe1a3df2024-06-04 12:05:19 +00001271 "email_id": email_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001272 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001273 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001274 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001275 "project_role_mappings": project_role_mappings,
1276 "add_project_role_mappings": project_role_mappings,
1277 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001278 "system_admin_id": id_schema,
1279 "unlock": bool_schema,
1280 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001281 },
1282 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001283 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001284}
1285
1286# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001287topics_with_quota = [
1288 "vnfds",
1289 "nsds",
1290 "slice_templates",
1291 "pduds",
1292 "ns_instances",
1293 "slice_instances",
1294 "vim_accounts",
1295 "wim_accounts",
1296 "sdn_controllers",
1297 "k8sclusters",
1298 "vca",
1299 "k8srepos",
1300 "osmrepos",
1301 "ns_subscriptions",
1302]
tiernocd54a4a2018-09-12 16:40:35 +02001303project_new_schema = {
1304 "$schema": "http://json-schema.org/draft-04/schema#",
1305 "title": "New project schema for administrators",
1306 "type": "object",
1307 "properties": {
tiernofd160572019-01-21 10:41:37 +00001308 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001309 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001310 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001311 "quotas": {
1312 "type": "object",
1313 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001314 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001315 },
tiernocd54a4a2018-09-12 16:40:35 +02001316 },
1317 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001318 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001319}
1320project_edit_schema = {
1321 "$schema": "http://json-schema.org/draft-04/schema#",
1322 "title": "Project edit schema for administrators",
1323 "type": "object",
1324 "properties": {
1325 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001326 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001327 "quotas": {
1328 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001329 "properties": {
1330 topic: {"oneOf": [integer0_schema, null_schema]}
1331 for topic in topics_with_quota
1332 },
1333 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001334 },
tiernocd54a4a2018-09-12 16:40:35 +02001335 },
1336 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001337 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001338}
1339
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001340# ROLES
1341roles_new_schema = {
1342 "$schema": "http://json-schema.org/draft-04/schema#",
1343 "title": "New role schema for administrators",
1344 "type": "object",
1345 "properties": {
1346 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001347 "permissions": {
1348 "type": "object",
1349 "patternProperties": {
1350 ".": bool_schema,
1351 },
1352 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001353 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001354 },
tierno1f029d82019-06-13 22:37:04 +00001355 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001356 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001357}
1358roles_edit_schema = {
1359 "$schema": "http://json-schema.org/draft-04/schema#",
1360 "title": "Roles edit schema for administrators",
1361 "type": "object",
1362 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001363 "name": shortname_schema,
1364 "permissions": {
1365 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001366 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001367 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001368 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001369 },
tierno1f029d82019-06-13 22:37:04 +00001370 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001371 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001372}
1373
tiernocd54a4a2018-09-12 16:40:35 +02001374# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001375
1376nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001377 "users": user_new_schema,
1378 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001379 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001380 "sdns": sdn_new_schema,
1381 "ns_instantiate": ns_instantiate,
1382 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001383 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001384 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001385 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001386 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001387}
1388
1389nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001390 "users": user_edit_schema,
1391 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001392 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001393 "sdns": sdn_edit_schema,
1394 "pdus": pdu_edit_schema,
kayal2001f71c2e82024-06-25 15:26:24 +05301395 "vnf": vnf_schema,
1396 "vld": vld_schema,
1397 "additionalParamsForVnf": additional_params_for_vnf,
tierno0f98af52018-03-19 10:28:22 +01001398}
1399
Felipe Vicens07f31722018-10-29 15:16:44 +01001400# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001401nsi_subnet_instantiate = deepcopy(ns_instantiate)
1402nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1403nsi_subnet_instantiate["properties"]["id"] = name_schema
1404del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001405
1406nsi_vld_instantiate = {
1407 "title": "netslice vld instantiation params input schema",
1408 "$schema": "http://json-schema.org/draft-04/schema#",
1409 "type": "object",
1410 "properties": {
1411 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001412 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1413 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001414 "ip-profile": object_schema,
1415 },
delacruzramoc061f562019-04-05 11:00:02 +02001416 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001417 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001418}
1419
Felipe Vicens07f31722018-10-29 15:16:44 +01001420nsi_instantiate = {
1421 "title": "netslice action instantiate input schema",
1422 "$schema": "http://json-schema.org/draft-04/schema#",
1423 "type": "object",
1424 "properties": {
1425 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001426 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001427 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001428 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001429 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001430 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001431 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001432 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001433 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001434 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001435 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001436 "type": "array",
1437 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001438 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001439 },
garciadeblas4568a372021-03-24 09:19:48 +01001440 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001441 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001442 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001443 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001444}
1445
garciadeblas4568a372021-03-24 09:19:48 +01001446nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001447
garciadeblas4568a372021-03-24 09:19:48 +01001448nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001449
preethika.p329b8182020-04-22 12:25:39 +05301450nsinstancesubscriptionfilter_schema = {
1451 "title": "instance identifier schema",
1452 "$schema": "http://json-schema.org/draft-07/schema#",
1453 "type": "object",
1454 "properties": {
1455 "nsdIds": {"type": "array"},
1456 "vnfdIds": {"type": "array"},
1457 "pnfdIds": {"type": "array"},
1458 "nsInstanceIds": {"type": "array"},
1459 "nsInstanceNames": {"type": "array"},
1460 },
1461}
1462
1463nslcmsub_schema = {
1464 "title": "nslcmsubscription input schema",
1465 "$schema": "http://json-schema.org/draft-07/schema#",
1466 "type": "object",
1467 "properties": {
1468 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1469 "notificationTypes": {
1470 "type": "array",
1471 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001472 "enum": [
1473 "NsLcmOperationOccurrenceNotification",
1474 "NsChangeNotification",
1475 "NsIdentifierCreationNotification",
1476 "NsIdentifierDeletionNotification",
1477 ]
1478 },
preethika.p329b8182020-04-22 12:25:39 +05301479 },
1480 "operationTypes": {
1481 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001482 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301483 },
1484 "operationStates": {
1485 "type": "array",
1486 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001487 "enum": [
1488 "PROCESSING",
1489 "COMPLETED",
1490 "PARTIALLY_COMPLETED",
1491 "FAILED",
1492 "FAILED_TEMP",
1493 "ROLLING_BACK",
1494 "ROLLED_BACK",
1495 ]
1496 },
preethika.p329b8182020-04-22 12:25:39 +05301497 },
garciadeblas4568a372021-03-24 09:19:48 +01001498 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301499 "lcmOpNameImpactingNsComponent": {
1500 "type": "array",
1501 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001502 "enum": [
1503 "VNF_INSTANTIATE",
1504 "VNF_SCALE",
1505 "VNF_SCALE_TO_LEVEL",
1506 "VNF_CHANGE_FLAVOUR",
1507 "VNF_TERMINATE",
1508 "VNF_HEAL",
1509 "VNF_OPERATE",
1510 "VNF_CHANGE_EXT_CONN",
1511 "VNF_MODIFY_INFO",
1512 "NS_INSTANTIATE",
1513 "NS_SCALE",
1514 "NS_UPDATE",
1515 "NS_TERMINATE",
1516 "NS_HEAL",
1517 ]
1518 },
preethika.p329b8182020-04-22 12:25:39 +05301519 },
1520 "lcmOpOccStatusImpactingNsComponent": {
1521 "type": "array",
1522 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001523 "enum": [
1524 "START",
1525 "COMPLETED",
1526 "PARTIALLY_COMPLETED",
1527 "FAILED",
1528 "ROLLED_BACK",
1529 ]
1530 },
preethika.p329b8182020-04-22 12:25:39 +05301531 },
1532 },
1533 "allOf": [
1534 {
1535 "if": {
1536 "properties": {
1537 "notificationTypes": {
1538 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1539 }
1540 },
1541 },
1542 "then": {
1543 "anyOf": [
1544 {"required": ["operationTypes"]},
1545 {"required": ["operationStates"]},
1546 ]
garciadeblas4568a372021-03-24 09:19:48 +01001547 },
preethika.p329b8182020-04-22 12:25:39 +05301548 },
1549 {
1550 "if": {
1551 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001552 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301553 },
1554 },
1555 "then": {
1556 "anyOf": [
1557 {"required": ["nsComponentTypes"]},
1558 {"required": ["lcmOpNameImpactingNsComponent"]},
1559 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1560 ]
garciadeblas4568a372021-03-24 09:19:48 +01001561 },
1562 },
1563 ],
preethika.p329b8182020-04-22 12:25:39 +05301564}
1565
1566authentication_schema = {
1567 "title": "authentication schema for subscription",
1568 "$schema": "http://json-schema.org/draft-07/schema#",
1569 "type": "object",
1570 "properties": {
1571 "authType": {"enum": ["basic"]},
1572 "paramsBasic": {
1573 "type": "object",
1574 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001575 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301576 "password": passwd_schema,
1577 },
1578 },
1579 },
1580}
1581
1582subscription = {
1583 "title": "subscription input schema",
1584 "$schema": "http://json-schema.org/draft-07/schema#",
1585 "type": "object",
1586 "properties": {
1587 "filter": nslcmsub_schema,
1588 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001589 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301590 },
1591 "required": ["CallbackUri"],
1592}
1593
selvi.jf1004592022-04-29 05:42:35 +00001594vnflcmsub_schema = {
1595 "title": "vnflcmsubscription input schema",
1596 "$schema": "http://json-schema.org/draft-07/schema#",
1597 "type": "object",
1598 "properties": {
1599 "VnfInstanceSubscriptionFilter": {
1600 "type": "object",
1601 "properties": {
1602 "vnfdIds": {"type": "array"},
1603 "vnfInstanceIds": {"type": "array"},
1604 },
1605 },
1606 "notificationTypes": {
1607 "type": "array",
1608 "items": {
1609 "enum": [
1610 "VnfIdentifierCreationNotification",
1611 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001612 "VnfIdentifierDeletionNotification",
1613 ]
1614 },
selvi.jf1004592022-04-29 05:42:35 +00001615 },
1616 "operationTypes": {
1617 "type": "array",
1618 "items": {
1619 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001620 "INSTANTIATE",
1621 "SCALE",
1622 "SCALE_TO_LEVEL",
1623 "CHANGE_FLAVOUR",
1624 "TERMINATE",
1625 "HEAL",
1626 "OPERATE",
1627 "CHANGE_EXT_CONN",
1628 "MODIFY_INFO",
1629 "CREATE_SNAPSHOT",
1630 "REVERT_TO_SNAPSHOT",
1631 "CHANGE_VNFPKG",
1632 ]
1633 },
selvi.jf1004592022-04-29 05:42:35 +00001634 },
1635 "operationStates": {
1636 "type": "array",
1637 "items": {
1638 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001639 "STARTING",
1640 "PROCESSING",
1641 "COMPLETED",
1642 "FAILED_TEMP",
1643 "FAILED",
1644 "ROLLING_BACK",
1645 "ROLLED_BACK",
1646 ]
1647 },
1648 },
selvi.jf1004592022-04-29 05:42:35 +00001649 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001650 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1651}
selvi.jf1004592022-04-29 05:42:35 +00001652
1653vnf_subscription = {
1654 "title": "vnf subscription input schema",
1655 "$schema": "http://json-schema.org/draft-07/schema#",
1656 "type": "object",
1657 "properties": {
1658 "filter": vnflcmsub_schema,
1659 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001660 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001661 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001662 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001663}
1664
yshah53cc9eb2024-07-05 13:06:31 +00001665oka_schema = {
1666 "title": "Create OKA package input schema",
1667 "$schema": "http://json-schema.org/draft-07/schema#",
1668 "type": "object",
1669 "properties": {
1670 "name": name_schema,
1671 "description": description_schema,
1672 },
1673 "additionalProperties": False,
1674}
1675
1676ksu_schema = {
1677 "title": "ksu schema",
1678 "$schema": "http://json-schema.org/draft-07/schema#",
1679 "type": "object",
1680 "properties": {
1681 "name": name_schema,
1682 "description": description_schema,
1683 "profile": {
1684 "type": "object",
1685 "properties": {
1686 "profile_type": string_schema,
1687 "_id": id_schema,
1688 },
1689 "additionalProperties": False,
1690 },
1691 "oka": {
1692 "type": "array",
1693 "items": {
1694 "type": "object",
1695 "properties": {
1696 "_id": id_schema,
1697 "sw_catalog_path": string_schema,
1698 "transformation": object_schema,
1699 },
1700 "additionalProperties": False,
1701 },
1702 },
1703 },
1704 "additionalProperties": False,
1705}
1706
tierno0f98af52018-03-19 10:28:22 +01001707
1708class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001709 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1710 self.http_code = http_code
1711 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001712
1713
tiernob24258a2018-10-04 18:39:49 +02001714def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001715 """
tiernocd54a4a2018-09-12 16:40:35 +02001716 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001717 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001718 :param schema_to_use: jsonschema to test
1719 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001720 """
1721 try:
tierno0f98af52018-03-19 10:28:22 +01001722 if schema_to_use:
1723 js_v(indata, schema_to_use)
1724 return None
1725 except js_e.ValidationError as e:
1726 if e.path:
tierno0da52252018-06-27 15:47:22 +02001727 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001728 else:
1729 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001730 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001731 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001732 raise ValidationError(
1733 "Bad json schema {}".format(schema_to_use),
1734 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1735 )
delacruzramoc061f562019-04-05 11:00:02 +02001736
1737
1738def is_valid_uuid(x):
1739 """
1740 Test for a valid UUID
1741 :param x: string to test
1742 :return: True if x is a valid uuid, False otherwise
1743 """
1744 try:
1745 if UUID(x):
1746 return True
tiernobdebce92019-07-01 15:36:49 +00001747 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001748 return False