blob: 18d5ff693527a0adc711a6b69b552366a0b84195 [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}
garciadeblas4568a372021-03-24 09:19:48 +010049xml_text_schema = {
50 "type": "string",
51 "minLength": 1,
52 "maxLength": 1000,
53 "pattern": "^[^']+$",
54}
55description_schema = {
56 "type": ["string", "null"],
57 "maxLength": 255,
58 "pattern": "^[^'\"]+$",
59}
60long_description_schema = {
61 "type": ["string", "null"],
62 "maxLength": 3000,
63 "pattern": "^[^'\"]+$",
64}
tierno441dbbf2018-07-10 12:52:48 +020065id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36}
66bool_schema = {"type": "boolean"}
67null_schema = {"type": "null"}
tierno2236d202018-05-16 19:05:16 +020068# "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 +010069id_schema = {
70 "type": "string",
71 "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$",
72}
73time_schema = {
74 "type": "string",
75 "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}",
76}
77pci_schema = {
78 "type": "string",
79 "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$",
80}
tierno42fce592018-11-02 09:23:43 +010081# allows [] for wildcards. For that reason huge length limit is set
82pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\\[\\]]{12,40}$"}
K Sai Kiran990ac462020-05-20 12:25:12 +053083http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"}
tierno0f98af52018-03-19 10:28:22 +010084bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"}
85memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"}
86integer0_schema = {"type": "integer", "minimum": 0}
87integer1_schema = {"type": "integer", "minimum": 1}
tierno87006042018-10-24 12:50:20 +020088path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"}
tierno0f98af52018-03-19 10:28:22 +010089vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095}
90vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095}
garciadeblas4568a372021-03-24 09:19:48 +010091mac_schema = {
92 "type": "string",
93 "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$",
94} # must be unicast: LSB bit of MSB byte ==0
tiernocb83c942018-09-24 17:28:13 +020095dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"}
tierno0f98af52018-03-19 10:28:22 +010096# mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
garciadeblas4568a372021-03-24 09:19:48 +010097ip_schema = {
98 "type": "string",
99 "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]?)$",
100}
garciadeblas1a01e1f2021-10-26 17:27:35 +0200101ipv6_schema = {
102 "type": "string",
garciadeblasf2af4a12023-01-24 16:56:54 +0100103 "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 +0200104}
garciadeblas4568a372021-03-24 09:19:48 +0100105ip_prefix_schema = {
106 "type": "string",
107 "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
108 "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$",
109}
tierno0f98af52018-03-19 10:28:22 +0100110port_schema = {"type": "integer", "minimum": 1, "maximum": 65534}
111object_schema = {"type": "object"}
112schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2}
113# schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
garciadeblas4568a372021-03-24 09:19:48 +0100114log_level_schema = {
115 "type": "string",
116 "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
117}
tierno0f98af52018-03-19 10:28:22 +0100118checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"}
119size_schema = {"type": "integer", "minimum": 1, "maximum": 100}
tiernocd54a4a2018-09-12 16:40:35 +0200120array_edition_schema = {
121 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100122 "patternProperties": {"^\\$": {}},
tiernocd54a4a2018-09-12 16:40:35 +0200123 "additionalProperties": False,
124 "minProperties": 1,
125}
tiernocb83c942018-09-24 17:28:13 +0200126nameshort_list_schema = {
127 "type": "array",
128 "minItems": 1,
tiernofd160572019-01-21 10:41:37 +0000129 "items": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +0200130}
tiernocd54a4a2018-09-12 16:40:35 +0200131
David Garciaecb41322021-03-31 19:10:46 +0200132description_list_schema = {
133 "type": "array",
134 "minItems": 1,
135 "items": description_schema,
136}
tierno0f98af52018-03-19 10:28:22 +0100137
tierno441dbbf2018-07-10 12:52:48 +0200138ns_instantiate_vdu = {
139 "title": "ns action instantiate input schema for vdu",
140 "$schema": "http://json-schema.org/draft-04/schema#",
141 "type": "object",
142 "properties": {
143 "id": name_schema,
Gabriel Cubae88401b2023-04-05 15:24:52 -0500144 "vim-flavor-id": name_schema,
kayal20016a3bce72024-06-27 11:14:59 +0530145 "instance_name": name_schema,
tierno441dbbf2018-07-10 12:52:48 +0200146 "volume": {
147 "type": "array",
148 "minItems": 1,
149 "items": {
150 "type": "object",
151 "properties": {
152 "name": name_schema,
153 "vim-volume-id": name_schema,
154 },
155 "required": ["name", "vim-volume-id"],
garciadeblas4568a372021-03-24 09:19:48 +0100156 "additionalProperties": False,
157 },
tierno441dbbf2018-07-10 12:52:48 +0200158 },
159 "interface": {
160 "type": "array",
161 "minItems": 1,
162 "items": {
163 "type": "object",
164 "properties": {
165 "name": name_schema,
garciadeblas9fb32712022-04-04 16:33:59 +0200166 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200167 "mac-address": mac_schema,
168 "floating-ip-required": bool_schema,
169 },
170 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +0100171 "additionalProperties": False,
172 },
173 },
tierno441dbbf2018-07-10 12:52:48 +0200174 },
175 "required": ["id"],
garciadeblas4568a372021-03-24 09:19:48 +0100176 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200177}
178
179ip_profile_dns_schema = {
180 "type": "array",
181 "minItems": 1,
182 "items": {
183 "type": "object",
184 "properties": {
garciadeblas9fb32712022-04-04 16:33:59 +0200185 "address": {"oneOf": [ip_schema, ipv6_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200186 },
187 "required": ["address"],
garciadeblas4568a372021-03-24 09:19:48 +0100188 "additionalProperties": False,
189 },
tierno441dbbf2018-07-10 12:52:48 +0200190}
191
192ip_profile_dhcp_schema = {
193 "type": "object",
194 "properties": {
195 "enabled": {"type": "boolean"},
196 "count": integer1_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100197 "start-address": ip_schema,
tierno441dbbf2018-07-10 12:52:48 +0200198 },
199 "additionalProperties": False,
200}
201
202ip_profile_schema = {
tierno2a929042020-03-10 16:34:25 +0000203 "title": "ip profile validation schema",
tierno441dbbf2018-07-10 12:52:48 +0200204 "$schema": "http://json-schema.org/draft-04/schema#",
205 "type": "object",
206 "properties": {
207 "ip-version": {"enum": ["ipv4", "ipv6"]},
tierno441dbbf2018-07-10 12:52:48 +0200208 "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]},
209 "gateway-address": {"oneOf": [null_schema, ip_schema]},
210 "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]},
tierno441dbbf2018-07-10 12:52:48 +0200211 "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]},
212 },
garciadeblas4568a372021-03-24 09:19:48 +0100213 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200214}
215
kbsub21f03f52019-10-17 16:26:56 +0000216provider_network_schema = {
tierno2a929042020-03-10 16:34:25 +0000217 "title": "provider network validation schema",
kbsub21f03f52019-10-17 16:26:56 +0000218 "$schema": "http://json-schema.org/draft-04/schema#",
219 "type": "object",
220 "properties": {
221 "physical-network": name_schema,
222 "segmentation-id": name_schema,
tierno2a929042020-03-10 16:34:25 +0000223 "sdn-ports": { # external ports to append to the SDN-assist network
224 "type": "array",
225 "items": {
226 "type": "object",
227 "properties": {
228 "switch_id": shortname_schema,
229 "switch_port": shortname_schema,
230 "mac_address": mac_schema,
231 "vlan": vlan_schema,
232 },
garciadeblas4568a372021-03-24 09:19:48 +0100233 "additionalProperties": True,
234 },
tierno2a929042020-03-10 16:34:25 +0000235 },
236 "network-type": shortname_schema,
kbsub21f03f52019-10-17 16:26:56 +0000237 },
garciadeblas4568a372021-03-24 09:19:48 +0100238 "additionalProperties": True,
kbsub21f03f52019-10-17 16:26:56 +0000239}
240
tierno441dbbf2018-07-10 12:52:48 +0200241ns_instantiate_internal_vld = {
garciadeblas9fb32712022-04-04 16:33:59 +0200242 "title": "ns action instantiate input schema for vld",
tierno441dbbf2018-07-10 12:52:48 +0200243 "$schema": "http://json-schema.org/draft-04/schema#",
244 "type": "object",
245 "properties": {
246 "name": name_schema,
247 "vim-network-name": name_schema,
gcalvino17d5b732018-12-17 16:26:21 +0100248 "vim-network-id": name_schema,
garciadeblas120105b2023-02-22 16:52:24 +0100249 "ip-profile": ip_profile_schema,
kbsub21f03f52019-10-17 16:26:56 +0000250 "provider-network": provider_network_schema,
tierno441dbbf2018-07-10 12:52:48 +0200251 "internal-connection-point": {
252 "type": "array",
253 "minItems": 1,
254 "items": {
255 "type": "object",
256 "properties": {
257 "id-ref": name_schema,
258 "ip-address": ip_schema,
tiernob7c6f2a2018-09-03 14:32:10 +0200259 # "mac-address": mac_schema,
tierno441dbbf2018-07-10 12:52:48 +0200260 },
tiernob7c6f2a2018-09-03 14:32:10 +0200261 "required": ["id-ref"],
262 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100263 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200264 },
garciadeblas4568a372021-03-24 09:19:48 +0100265 },
tierno441dbbf2018-07-10 12:52:48 +0200266 },
267 "required": ["name"],
268 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100269 "additionalProperties": False,
tierno441dbbf2018-07-10 12:52:48 +0200270}
tierno65acb4d2018-04-06 16:42:40 +0200271
tiernofd160572019-01-21 10:41:37 +0000272additional_params_for_vnf = {
273 "type": "array",
274 "items": {
275 "type": "object",
276 "properties": {
277 "member-vnf-index": name_schema,
278 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000279 "k8s-namespace": name_schema,
tiernof62ac6a2020-04-29 13:46:13 +0000280 "config-units": integer1_schema, # number of configuration units of this vnf, by default 1
tierno714954e2019-11-29 13:43:26 +0000281 "additionalParamsForVdu": {
282 "type": "array",
283 "items": {
284 "type": "object",
285 "properties": {
286 "vdu_id": name_schema,
287 "additionalParams": object_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100288 "config-units": integer1_schema, # number of configuration units of this vdu, by default 1
tierno714954e2019-11-29 13:43:26 +0000289 },
tiernof62ac6a2020-04-29 13:46:13 +0000290 "required": ["vdu_id"],
291 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000292 "additionalProperties": False,
293 },
294 },
295 "additionalParamsForKdu": {
296 "type": "array",
297 "items": {
298 "type": "object",
299 "properties": {
300 "kdu_name": name_schema,
301 "additionalParams": object_schema,
tierno54db2e42020-04-06 15:29:42 +0000302 "kdu_model": name_schema,
303 "k8s-namespace": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100304 "config-units": integer1_schema, # number of configuration units of this knf, by default 1
romeromonserbfebfc02021-05-28 10:51:35 +0200305 "kdu-deployment-name": name_schema,
tierno714954e2019-11-29 13:43:26 +0000306 },
tierno54db2e42020-04-06 15:29:42 +0000307 "required": ["kdu_name"],
308 "minProperties": 2,
tierno714954e2019-11-29 13:43:26 +0000309 "additionalProperties": False,
310 },
311 },
Alexis Romeroee31f532022-04-26 19:10:21 +0200312 "affinity-or-anti-affinity-group": {
313 "type": "array",
314 "items": {
315 "type": "object",
316 "properties": {
317 "id": name_schema,
318 "vim-affinity-group-id": name_schema,
319 },
320 "required": ["id"],
321 "minProperties": 2,
322 "additionalProperties": False,
323 },
324 },
tiernofd160572019-01-21 10:41:37 +0000325 },
tierno714954e2019-11-29 13:43:26 +0000326 "required": ["member-vnf-index"],
327 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100328 "additionalProperties": False,
329 },
tiernofd160572019-01-21 10:41:37 +0000330}
331
tierno65acb4d2018-04-06 16:42:40 +0200332ns_instantiate = {
333 "title": "ns action instantiate input schema",
334 "$schema": "http://json-schema.org/draft-04/schema#",
335 "type": "object",
tierno0da52252018-06-27 15:47:22 +0200336 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200337 "lcmOperationType": string_schema,
338 "nsInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +0100339 "netsliceInstanceId": id_schema,
tierno0da52252018-06-27 15:47:22 +0200340 "nsName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +0000341 "nsDescription": {"oneOf": [description_schema, null_schema]},
tierno0da52252018-06-27 15:47:22 +0200342 "nsdId": id_schema,
343 "vimAccountId": id_schema,
tierno195a36c2020-09-18 14:18:55 +0000344 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
magnussonlf318b302020-01-20 18:38:18 +0100345 "placement-engine": string_schema,
346 "placement-constraints": object_schema,
tiernobee085c2018-12-12 17:03:04 +0000347 "additionalParamsForNs": object_schema,
tiernofd160572019-01-21 10:41:37 +0000348 "additionalParamsForVnf": additional_params_for_vnf,
garciadeblas4568a372021-03-24 09:19:48 +0100349 "config-units": integer1_schema, # number of configuration units of this ns, by default 1
tierno54db2e42020-04-06 15:29:42 +0000350 "k8s-namespace": name_schema,
tiernofc5089c2018-10-31 09:28:11 +0100351 "ssh_keys": {"type": "array", "items": {"type": "string"}},
tiernoa8186a52020-01-14 15:54:48 +0000352 "timeout_ns_deploy": integer1_schema,
tierno441dbbf2018-07-10 12:52:48 +0200353 "nsr_id": id_schema,
tiernocc103432018-10-19 14:10:35 +0200354 "vduImage": name_schema,
tierno0da52252018-06-27 15:47:22 +0200355 "vnf": {
356 "type": "array",
357 "minItems": 1,
358 "items": {
359 "type": "object",
360 "properties": {
361 "member-vnf-index": name_schema,
362 "vimAccountId": id_schema,
tierno441dbbf2018-07-10 12:52:48 +0200363 "vdu": {
364 "type": "array",
365 "minItems": 1,
366 "items": ns_instantiate_vdu,
367 },
368 "internal-vld": {
369 "type": "array",
370 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100371 "items": ns_instantiate_internal_vld,
372 },
tierno0da52252018-06-27 15:47:22 +0200373 },
tierno441dbbf2018-07-10 12:52:48 +0200374 "required": ["member-vnf-index"],
375 "minProperties": 2,
garciadeblas4568a372021-03-24 09:19:48 +0100376 "additionalProperties": False,
377 },
tierno0da52252018-06-27 15:47:22 +0200378 },
379 "vld": {
380 "type": "array",
381 "minItems": 1,
382 "items": {
383 "type": "object",
384 "properties": {
385 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +0000386 "vim-network-name": {"oneOf": [string_schema, object_schema]},
387 "vim-network-id": {"oneOf": [string_schema, object_schema]},
Felipe Vicens09e65422019-01-22 15:06:46 +0100388 "ns-net": object_schema,
tierno195a36c2020-09-18 14:18:55 +0000389 "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]},
garciadeblas120105b2023-02-22 16:52:24 +0100390 "ip-profile": ip_profile_schema,
kbsub21f03f52019-10-17 16:26:56 +0000391 "provider-network": provider_network_schema,
tiernob7c6f2a2018-09-03 14:32:10 +0200392 "vnfd-connection-point-ref": {
393 "type": "array",
394 "minItems": 1,
395 "items": {
396 "type": "object",
397 "properties": {
398 "member-vnf-index-ref": name_schema,
399 "vnfd-connection-point-ref": name_schema,
garciadeblas9fb32712022-04-04 16:33:59 +0200400 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernob7c6f2a2018-09-03 14:32:10 +0200401 # "mac-address": mac_schema,
402 },
garciadeblas4568a372021-03-24 09:19:48 +0100403 "required": [
404 "member-vnf-index-ref",
405 "vnfd-connection-point-ref",
406 ],
tiernob7c6f2a2018-09-03 14:32:10 +0200407 "minProperties": 3,
garciadeblas4568a372021-03-24 09:19:48 +0100408 "additionalProperties": False,
tiernob7c6f2a2018-09-03 14:32:10 +0200409 },
garciadeblas4568a372021-03-24 09:19:48 +0100410 },
tierno0da52252018-06-27 15:47:22 +0200411 },
tierno441dbbf2018-07-10 12:52:48 +0200412 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +0100413 "additionalProperties": False,
414 },
tierno0da52252018-06-27 15:47:22 +0200415 },
416 },
tierno441dbbf2018-07-10 12:52:48 +0200417 "required": ["nsName", "nsdId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +0100418 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200419}
tierno0da52252018-06-27 15:47:22 +0200420
tierno1c38f2f2020-03-24 11:51:39 +0000421ns_terminate = {
422 "title": "ns terminate input schema",
423 "$schema": "http://json-schema.org/draft-04/schema#",
424 "type": "object",
425 "properties": {
426 "lcmOperationType": string_schema,
427 "nsInstanceId": id_schema,
428 "autoremove": bool_schema,
429 "timeout_ns_terminate": integer1_schema,
430 "skip_terminate_primitives": bool_schema,
tierno0b8752f2020-05-12 09:42:02 +0000431 "netsliceInstanceId": id_schema,
tierno1c38f2f2020-03-24 11:51:39 +0000432 },
garciadeblas4568a372021-03-24 09:19:48 +0100433 "additionalProperties": False,
tierno1c38f2f2020-03-24 11:51:39 +0000434}
435
aticig544a2ae2022-04-05 09:00:17 +0300436ns_update = {
437 "title": "ns update input schema",
438 "$schema": "http://json-schema.org/draft-04/schema#",
439 "type": "object",
440 "properties": {
441 "lcmOperationType": string_schema,
442 "nsInstanceId": id_schema,
garciadeblaseab15072022-05-19 10:31:52 +0200443 "timeout_ns_update": integer1_schema,
aticig544a2ae2022-04-05 09:00:17 +0300444 "updateType": {
garciadeblasf2af4a12023-01-24 16:56:54 +0100445 "enum": [
446 "CHANGE_VNFPKG",
447 "REMOVE_VNF",
448 "MODIFY_VNF_INFORMATION",
449 "OPERATE_VNF",
Rahul Kumara30391b2024-05-24 14:40:23 +0530450 "VERTICAL_SCALE",
garciadeblasf2af4a12023-01-24 16:56:54 +0100451 ]
aticig544a2ae2022-04-05 09:00:17 +0300452 },
453 "modifyVnfInfoData": {
454 "type": "object",
455 "properties": {
456 "vnfInstanceId": id_schema,
457 "vnfdId": id_schema,
458 },
459 "required": ["vnfInstanceId", "vnfdId"],
460 },
461 "removeVnfInstanceId": id_schema,
462 "changeVnfPackageData": {
463 "type": "object",
464 "properties": {
465 "vnfInstanceId": id_schema,
466 "vnfdId": id_schema,
467 },
468 "required": ["vnfInstanceId", "vnfdId"],
469 },
k4.rahule3dca382022-04-29 12:30:36 +0000470 "operateVnfData": {
471 "type": "object",
472 "properties": {
473 "vnfInstanceId": id_schema,
474 "changeStateTo": name_schema,
475 "additionalParam": {
476 "type": "object",
477 "properties": {
478 "run-day1": bool_schema,
479 "vdu_id": name_schema,
480 "count-index": integer0_schema,
481 },
482 "required": ["vdu_id", "count-index"],
483 "additionalProperties": False,
garciadeblasf2af4a12023-01-24 16:56:54 +0100484 },
k4.rahule3dca382022-04-29 12:30:36 +0000485 },
486 "required": ["vnfInstanceId", "changeStateTo"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100487 },
Rahul Kumara30391b2024-05-24 14:40:23 +0530488 "verticalScaleVnf": {
489 "type": "object",
490 "properties": {
491 "vnfInstanceId": id_schema,
492 "vnfdId": id_schema,
493 "vduId": name_schema,
494 "countIndex": integer0_schema,
495 },
496 "required": ["vnfInstanceId", "vnfdId", "vduId"],
497 },
aticig544a2ae2022-04-05 09:00:17 +0300498 },
499 "required": ["updateType"],
500 "additionalProperties": False,
501}
502
garciadeblas4568a372021-03-24 09:19:48 +0100503ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution
tiernof759d822018-06-11 18:54:54 +0200504 "title": "ns action input schema",
tierno65acb4d2018-04-06 16:42:40 +0200505 "$schema": "http://json-schema.org/draft-04/schema#",
506 "type": "object",
507 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200508 "lcmOperationType": string_schema,
509 "nsInstanceId": id_schema,
tiernof5298be2018-05-16 14:43:57 +0200510 "member_vnf_index": name_schema,
511 "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future
tierno7ce1db92018-07-25 12:50:52 +0200512 "vdu_id": name_schema,
tiernof0637052019-03-07 16:26:47 +0000513 "vdu_count_index": integer0_schema,
tierno9cb7d672019-10-30 12:13:48 +0000514 "kdu_name": name_schema,
tierno65acb4d2018-04-06 16:42:40 +0200515 "primitive": name_schema,
tierno50c8e6e2020-04-02 15:40:12 +0000516 "timeout_ns_action": integer1_schema,
tierno65acb4d2018-04-06 16:42:40 +0200517 "primitive_params": {"type": "object"},
518 },
garciadeblas4568a372021-03-24 09:19:48 +0100519 "required": ["primitive", "primitive_params"], # TODO add member_vnf_index
520 "additionalProperties": False,
tierno65acb4d2018-04-06 16:42:40 +0200521}
garciadeblas0964edf2022-02-11 00:43:44 +0100522
garciadeblas4568a372021-03-24 09:19:48 +0100523ns_scale = { # TODO for the moment it is only VDU-scaling
tiernof759d822018-06-11 18:54:54 +0200524 "title": "ns scale input schema",
525 "$schema": "http://json-schema.org/draft-04/schema#",
526 "type": "object",
527 "properties": {
tiernob24258a2018-10-04 18:39:49 +0200528 "lcmOperationType": string_schema,
529 "nsInstanceId": id_schema,
tiernof759d822018-06-11 18:54:54 +0200530 "scaleType": {"enum": ["SCALE_VNF"]},
tierno50c8e6e2020-04-02 15:40:12 +0000531 "timeout_ns_scale": integer1_schema,
tiernof759d822018-06-11 18:54:54 +0200532 "scaleVnfData": {
533 "type": "object",
534 "properties": {
535 "vnfInstanceId": name_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100536 "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]},
tiernof759d822018-06-11 18:54:54 +0200537 "scaleByStepData": {
538 "type": "object",
539 "properties": {
540 "scaling-group-descriptor": name_schema,
541 "member-vnf-index": name_schema,
542 "scaling-policy": name_schema,
543 },
544 "required": ["scaling-group-descriptor", "member-vnf-index"],
garciadeblas4568a372021-03-24 09:19:48 +0100545 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200546 },
547 },
548 "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId
garciadeblas4568a372021-03-24 09:19:48 +0100549 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200550 },
551 "scaleTime": time_schema,
552 },
553 "required": ["scaleType", "scaleVnfData"],
garciadeblas4568a372021-03-24 09:19:48 +0100554 "additionalProperties": False,
tiernof759d822018-06-11 18:54:54 +0200555}
tierno65acb4d2018-04-06 16:42:40 +0200556
elumalai8e3806c2022-04-28 17:26:24 +0530557ns_migrate = {
558 "title": "ns migrate input schema",
559 "$schema": "http://json-schema.org/draft-04/schema#",
560 "type": "object",
561 "properties": {
562 "lcmOperationType": string_schema,
563 "nsInstanceId": id_schema,
564 "vnfInstanceId": id_schema,
565 "migrateToHost": string_schema,
566 "vdu": {
567 "type": "object",
garciadeblasf2af4a12023-01-24 16:56:54 +0100568 "properties": {
569 "vduId": name_schema,
570 "vduCountIndex": integer0_schema,
571 },
572 "required": ["vduId"],
573 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530574 },
575 },
576 "required": ["vnfInstanceId"],
garciadeblasf2af4a12023-01-24 16:56:54 +0100577 "additionalProperties": False,
elumalai8e3806c2022-04-28 17:26:24 +0530578}
tierno65acb4d2018-04-06 16:42:40 +0200579
garciadeblas0964edf2022-02-11 00:43:44 +0100580ns_heal = {
581 "title": "ns heal input schema",
582 "$schema": "http://json-schema.org/draft-04/schema#",
583 "type": "object",
584 "properties": {
585 "lcmOperationType": string_schema,
586 "nsInstanceId": id_schema,
587 "timeout_ns_heal": integer1_schema,
588 "healVnfData": {
589 "type": "array",
590 "items": {
591 "type": "object",
592 "properties": {
593 "vnfInstanceId": id_schema,
594 "cause": description_schema,
595 "additionalParams": {
596 "type": "object",
597 "properties": {
598 "run-day1": bool_schema,
599 "vdu": {
600 "type": "array",
601 "items": {
602 "type": "object",
603 "properties": {
604 "run-day1": bool_schema,
605 "vdu-id": name_schema,
606 "count-index": integer0_schema,
607 },
608 "required": ["vdu-id"],
609 "additionalProperties": False,
610 },
611 },
612 },
613 "additionalProperties": False,
614 },
615 },
616 "required": ["vnfInstanceId"],
617 "additionalProperties": False,
618 },
619 },
620 },
621 "required": ["healVnfData"],
622 "additionalProperties": False,
623}
624
Gabriel Cuba84a60df2023-10-30 14:01:54 -0500625nslcmop_cancel = {
626 "title": "Cancel nslcmop input schema",
627 "$schema": "http://json-schema.org/draft-04/schema#",
628 "type": "object",
629 "properties": {
630 "nsLcmOpOccId": id_schema,
631 "cancelMode": {
632 "enum": [
633 "GRACEFUL",
634 "FORCEFUL",
635 ]
636 },
637 },
638 "required": ["cancelMode"],
639 "additionalProperties": False,
640}
641
tierno0f98af52018-03-19 10:28:22 +0100642schema_version = {"type": "string", "enum": ["1.0"]}
tierno55ba2e62018-12-11 17:22:22 +0000643schema_type = {"type": "string"}
tiernob3d0a0e2019-11-13 15:57:51 +0000644vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200645
tierno09c073e2018-04-26 13:36:48 +0200646vim_account_edit_schema = {
647 "title": "vim_account edit input schema",
648 "$schema": "http://json-schema.org/draft-04/schema#",
649 "type": "object",
650 "properties": {
651 "name": name_schema,
652 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200653 "vim": name_schema,
654 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200655 "vim_type": vim_type,
tierno09c073e2018-04-26 13:36:48 +0200656 "vim_url": description_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200657 # "vim_url_admin": description_schema,
658 # "vim_tenant": name_schema,
tierno09c073e2018-04-26 13:36:48 +0200659 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200660 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200661 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200662 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100663 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000664 "prometheus-config": {"type": "object"},
tierno09c073e2018-04-26 13:36:48 +0200665 },
garciadeblas4568a372021-03-24 09:19:48 +0100666 "additionalProperties": False,
tierno09c073e2018-04-26 13:36:48 +0200667}
tierno0f98af52018-03-19 10:28:22 +0100668
tierno09c073e2018-04-26 13:36:48 +0200669vim_account_new_schema = {
670 "title": "vim_account creation input schema",
tierno0f98af52018-03-19 10:28:22 +0100671 "$schema": "http://json-schema.org/draft-04/schema#",
672 "type": "object",
673 "properties": {
674 "schema_version": schema_version,
675 "schema_type": schema_type,
676 "name": name_schema,
677 "description": description_schema,
tierno09c073e2018-04-26 13:36:48 +0200678 "vim": name_schema,
679 "datacenter": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200680 "vim_type": vim_type,
tierno0f98af52018-03-19 10:28:22 +0100681 "vim_url": description_schema,
682 # "vim_url_admin": description_schema,
683 # "vim_tenant": name_schema,
684 "vim_tenant_name": name_schema,
sousaeduf2feafd2021-07-12 10:21:06 +0200685 "vim_user": string_schema,
tiernocd54a4a2018-09-12 16:40:35 +0200686 "vim_password": passwd_schema,
David Garciaecb41322021-03-31 19:10:46 +0200687 "vca": id_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100688 "config": {"type": "object"},
vegall5c59aab2022-04-27 15:31:49 +0000689 "prometheus-config": {"type": "object"},
tierno0f98af52018-03-19 10:28:22 +0100690 },
garciadeblas4568a372021-03-24 09:19:48 +0100691 "required": [
692 "name",
693 "vim_url",
694 "vim_type",
695 "vim_user",
696 "vim_password",
697 "vim_tenant_name",
698 ],
699 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100700}
tierno0f98af52018-03-19 10:28:22 +0100701
tierno85807722019-12-20 14:11:35 +0000702wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]}
delacruzramo3a144c92019-10-25 09:46:33 +0200703
tierno55ba2e62018-12-11 17:22:22 +0000704wim_account_edit_schema = {
705 "title": "wim_account edit input schema",
706 "$schema": "http://json-schema.org/draft-04/schema#",
707 "type": "object",
708 "properties": {
709 "name": name_schema,
710 "description": description_schema,
tierno55ba2e62018-12-11 17:22:22 +0000711 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200712 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000713 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100714 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000715 "password": passwd_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100716 "config": {"type": "object"},
tierno55ba2e62018-12-11 17:22:22 +0000717 },
garciadeblas4568a372021-03-24 09:19:48 +0100718 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000719}
720
721wim_account_new_schema = {
722 "title": "wim_account creation input schema",
723 "$schema": "http://json-schema.org/draft-04/schema#",
724 "type": "object",
725 "properties": {
726 "schema_version": schema_version,
727 "schema_type": schema_type,
728 "name": name_schema,
729 "description": description_schema,
730 "wim": name_schema,
delacruzramo3a144c92019-10-25 09:46:33 +0200731 "wim_type": wim_type,
tierno55ba2e62018-12-11 17:22:22 +0000732 "wim_url": description_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100733 "user": string_schema,
tierno55ba2e62018-12-11 17:22:22 +0000734 "password": passwd_schema,
tiernof0637052019-03-07 16:26:47 +0000735 "config": {
736 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +0100737 "patternProperties": {".": {"not": {"type": "null"}}},
738 },
tierno55ba2e62018-12-11 17:22:22 +0000739 },
740 "required": ["name", "wim_url", "wim_type"],
garciadeblas4568a372021-03-24 09:19:48 +0100741 "additionalProperties": False,
tierno55ba2e62018-12-11 17:22:22 +0000742}
tierno0f98af52018-03-19 10:28:22 +0100743
744sdn_properties = {
745 "name": name_schema,
tierno7adaeb02019-12-17 16:46:12 +0000746 "type": {"type": "string"},
747 "url": {"type": "string"},
sousaedu80b6fed2021-10-07 15:17:32 +0100748 "user": string_schema,
tierno7adaeb02019-12-17 16:46:12 +0000749 "password": passwd_schema,
750 "config": {"type": "object"},
tiernocfb07c62018-05-10 18:30:51 +0200751 "description": description_schema,
tierno7adaeb02019-12-17 16:46:12 +0000752 # The folowing are deprecated. Maintanied for backward compatibility
tiernocb83c942018-09-24 17:28:13 +0200753 "dpid": dpid_Schema,
tierno0f98af52018-03-19 10:28:22 +0100754 "ip": ip_schema,
755 "port": port_schema,
tierno0f98af52018-03-19 10:28:22 +0100756 "version": {"type": "string", "minLength": 1, "maxLength": 12},
tierno0f98af52018-03-19 10:28:22 +0100757}
758sdn_new_schema = {
759 "title": "sdn controller information schema",
760 "$schema": "http://json-schema.org/draft-04/schema#",
761 "type": "object",
762 "properties": sdn_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100763 "required": ["name", "type"],
764 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100765}
766sdn_edit_schema = {
767 "title": "sdn controller update information schema",
768 "$schema": "http://json-schema.org/draft-04/schema#",
769 "type": "object",
770 "properties": sdn_properties,
tiernocfb07c62018-05-10 18:30:51 +0200771 # "required": ["name", "port", 'ip', 'dpid', 'type'],
garciadeblas4568a372021-03-24 09:19:48 +0100772 "additionalProperties": False,
tierno0f98af52018-03-19 10:28:22 +0100773}
774sdn_port_mapping_schema = {
775 "$schema": "http://json-schema.org/draft-04/schema#",
776 "title": "sdn port mapping information schema",
777 "type": "array",
778 "items": {
779 "type": "object",
780 "properties": {
tiernofd160572019-01-21 10:41:37 +0000781 "compute_node": shortname_schema,
tierno0f98af52018-03-19 10:28:22 +0100782 "ports": {
783 "type": "array",
784 "items": {
785 "type": "object",
786 "properties": {
tierno42fce592018-11-02 09:23:43 +0100787 "pci": pci_extended_schema,
tiernofd160572019-01-21 10:41:37 +0000788 "switch_port": shortname_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100789 "switch_mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100790 },
garciadeblas4568a372021-03-24 09:19:48 +0100791 "required": ["pci"],
792 },
793 },
tierno0f98af52018-03-19 10:28:22 +0100794 },
garciadeblas4568a372021-03-24 09:19:48 +0100795 "required": ["compute_node", "ports"],
796 },
tierno0f98af52018-03-19 10:28:22 +0100797}
798sdn_external_port_schema = {
799 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocd54a4a2018-09-12 16:40:35 +0200800 "title": "External port information",
tierno0f98af52018-03-19 10:28:22 +0100801 "type": "object",
802 "properties": {
803 "port": {"type": "string", "minLength": 1, "maxLength": 60},
804 "vlan": vlan_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100805 "mac": mac_schema,
tierno0f98af52018-03-19 10:28:22 +0100806 },
garciadeblas4568a372021-03-24 09:19:48 +0100807 "required": ["port"],
tierno0f98af52018-03-19 10:28:22 +0100808}
809
delacruzramofe598fe2019-10-23 18:25:11 +0200810# K8s Clusters
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500811k8scluster_deploy_method_schema = {
812 "$schema": "http://json-schema.org/draft-04/schema#",
813 "title": "Deployment methods for K8s cluster",
814 "type": "object",
815 "properties": {
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500816 "juju-bundle": {"type": "boolean"},
817 "helm-chart-v3": {"type": "boolean"},
818 },
819 "additionalProperties": False,
Luis Vega0a1efed2023-11-28 16:44:30 +0000820 "minProperties": 2,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500821}
delacruzramofe598fe2019-10-23 18:25:11 +0200822k8scluster_nets_schema = {
823 "title": "k8scluster nets input schema",
824 "$schema": "http://json-schema.org/draft-04/schema#",
825 "type": "object",
tierno8c81ab02020-02-07 10:18:30 +0000826 "patternProperties": {".": {"oneOf": [name_schema, null_schema]}},
delacruzramofe598fe2019-10-23 18:25:11 +0200827 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +0100828 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200829}
830k8scluster_new_schema = {
831 "title": "k8scluster creation input schema",
832 "$schema": "http://json-schema.org/draft-04/schema#",
833 "type": "object",
834 "properties": {
835 "schema_version": schema_version,
836 "schema_type": schema_type,
837 "name": name_schema,
838 "description": description_schema,
839 "credentials": object_schema,
840 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200841 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200842 "k8s_version": string_schema,
843 "nets": k8scluster_nets_schema,
Gabriel Cuba50e815b2022-03-22 14:01:26 -0500844 "deployment_methods": k8scluster_deploy_method_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200845 "namespace": name_schema,
846 "cni": nameshort_list_schema,
847 },
848 "required": ["name", "credentials", "vim_account", "k8s_version", "nets"],
garciadeblas4568a372021-03-24 09:19:48 +0100849 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200850}
851k8scluster_edit_schema = {
852 "title": "vim_account edit input schema",
853 "$schema": "http://json-schema.org/draft-04/schema#",
854 "type": "object",
855 "properties": {
856 "name": name_schema,
857 "description": description_schema,
858 "credentials": object_schema,
859 "vim_account": id_schema,
David Garciaecb41322021-03-31 19:10:46 +0200860 "vca_id": id_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200861 "k8s_version": string_schema,
862 "nets": k8scluster_nets_schema,
863 "namespace": name_schema,
864 "cni": nameshort_list_schema,
865 },
garciadeblas4568a372021-03-24 09:19:48 +0100866 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200867}
868
David Garciaecb41322021-03-31 19:10:46 +0200869# VCA
870vca_new_schema = {
871 "title": "vca creation input schema",
872 "$schema": "http://json-schema.org/draft-04/schema#",
873 "type": "object",
874 "properties": {
875 "schema_version": schema_version,
876 "schema_type": schema_type,
877 "name": name_schema,
878 "description": description_schema,
879 "endpoints": description_list_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100880 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200881 "secret": passwd_schema,
882 "cacert": long_description_schema,
883 "lxd-cloud": shortname_schema,
884 "lxd-credentials": shortname_schema,
885 "k8s-cloud": shortname_schema,
886 "k8s-credentials": shortname_schema,
887 "model-config": object_schema,
888 },
889 "required": [
890 "name",
891 "endpoints",
892 "user",
893 "secret",
894 "cacert",
895 "lxd-cloud",
896 "lxd-credentials",
897 "k8s-cloud",
898 "k8s-credentials",
899 ],
900 "additionalProperties": False,
901}
902vca_edit_schema = {
903 "title": "vca creation input schema",
904 "$schema": "http://json-schema.org/draft-04/schema#",
905 "type": "object",
906 "properties": {
907 "name": name_schema,
908 "description": description_schema,
909 "endpoints": description_list_schema,
910 "port": integer1_schema,
sousaedu80b6fed2021-10-07 15:17:32 +0100911 "user": string_schema,
David Garciaecb41322021-03-31 19:10:46 +0200912 "secret": passwd_schema,
913 "cacert": long_description_schema,
914 "lxd-cloud": shortname_schema,
915 "lxd-credentials": shortname_schema,
916 "k8s-cloud": shortname_schema,
917 "k8s-credentials": shortname_schema,
918 "model-config": object_schema,
919 },
920 "additionalProperties": False,
921}
922
delacruzramofe598fe2019-10-23 18:25:11 +0200923# K8s Repos
tierno332e0802019-12-03 23:50:49 +0000924k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]}
delacruzramofe598fe2019-10-23 18:25:11 +0200925k8srepo_properties = {
926 "name": name_schema,
927 "description": description_schema,
928 "type": k8srepo_types,
929 "url": description_schema,
Luis Vegaf6574e32023-07-11 18:47:22 +0000930 "cacert": long_description_schema,
931 "user": string_schema,
932 "password": passwd_schema,
garciadeblasf3543892023-10-20 11:53:51 +0200933 "oci": bool_schema,
delacruzramofe598fe2019-10-23 18:25:11 +0200934}
935k8srepo_new_schema = {
936 "title": "k8scluster creation input schema",
937 "$schema": "http://json-schema.org/draft-04/schema#",
938 "type": "object",
939 "properties": k8srepo_properties,
940 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100941 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200942}
943k8srepo_edit_schema = {
944 "title": "vim_account edit input schema",
945 "$schema": "http://json-schema.org/draft-04/schema#",
946 "type": "object",
947 "properties": k8srepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100948 "additionalProperties": False,
delacruzramofe598fe2019-10-23 18:25:11 +0200949}
950
Felipe Vicensb66b0412020-05-06 10:11:00 +0200951# OSM Repos
952osmrepo_types = {"enum": ["osm"]}
953osmrepo_properties = {
954 "name": name_schema,
955 "description": description_schema,
956 "type": osmrepo_types,
957 "url": description_schema
sousaedu80b6fed2021-10-07 15:17:32 +0100958 # "user": string_schema,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200959 # "password": passwd_schema
960}
961osmrepo_new_schema = {
962 "title": "osm repo creation input schema",
963 "$schema": "http://json-schema.org/draft-04/schema#",
964 "type": "object",
965 "properties": osmrepo_properties,
966 "required": ["name", "type", "url"],
garciadeblas4568a372021-03-24 09:19:48 +0100967 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200968}
969osmrepo_edit_schema = {
970 "title": "osm repo edit input schema",
971 "$schema": "http://json-schema.org/draft-04/schema#",
972 "type": "object",
973 "properties": osmrepo_properties,
garciadeblas4568a372021-03-24 09:19:48 +0100974 "additionalProperties": False,
Felipe Vicensb66b0412020-05-06 10:11:00 +0200975}
976
tiernocb83c942018-09-24 17:28:13 +0200977# PDUs
978pdu_interface = {
979 "type": "object",
980 "properties": {
tiernofd160572019-01-21 10:41:37 +0000981 "name": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +0200982 "mgmt": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +0100983 "type": {"enum": ["overlay", "underlay"]},
garciadeblas1a01e1f2021-10-26 17:27:35 +0200984 "ip-address": {"oneOf": [ip_schema, ipv6_schema]},
tiernocb83c942018-09-24 17:28:13 +0200985 # TODO, add user, password, ssh-key
tierno36ec8602018-11-02 17:27:11 +0100986 "mac-address": mac_schema,
tiernofd160572019-01-21 10:41:37 +0000987 "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port
988 "vim-network-id": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +0100989 # # provide this in case SDN assist must deal with this interface
990 # "switch-dpid": dpid_Schema,
tiernofd160572019-01-21 10:41:37 +0000991 # "switch-port": shortname_schema,
992 # "switch-mac": shortname_schema,
tierno36ec8602018-11-02 17:27:11 +0100993 # "switch-vlan": vlan_schema,
tiernocb83c942018-09-24 17:28:13 +0200994 },
tierno36ec8602018-11-02 17:27:11 +0100995 "required": ["name", "mgmt", "ip-address"],
garciadeblas4568a372021-03-24 09:19:48 +0100996 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +0200997}
tiernocb83c942018-09-24 17:28:13 +0200998pdu_new_schema = {
999 "title": "pdu creation input schema",
1000 "$schema": "http://json-schema.org/draft-04/schema#",
1001 "type": "object",
1002 "properties": {
tiernofd160572019-01-21 10:41:37 +00001003 "name": shortname_schema,
1004 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001005 "description": description_schema,
1006 "shared": bool_schema,
1007 "vims": nameshort_list_schema,
1008 "vim_accounts": nameshort_list_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001009 "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1},
tiernocb83c942018-09-24 17:28:13 +02001010 },
1011 "required": ["name", "type", "interfaces"],
garciadeblas4568a372021-03-24 09:19:48 +01001012 "additionalProperties": False,
tiernocb83c942018-09-24 17:28:13 +02001013}
tiernocb83c942018-09-24 17:28:13 +02001014pdu_edit_schema = {
1015 "title": "pdu edit input schema",
1016 "$schema": "http://json-schema.org/draft-04/schema#",
1017 "type": "object",
1018 "properties": {
tiernofd160572019-01-21 10:41:37 +00001019 "name": shortname_schema,
1020 "type": shortname_schema,
tiernocb83c942018-09-24 17:28:13 +02001021 "description": description_schema,
1022 "shared": bool_schema,
garciadeblas84bdd552018-11-30 22:59:45 +01001023 "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]},
1024 "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]},
garciadeblas4568a372021-03-24 09:19:48 +01001025 "interfaces": {
1026 "oneOf": [
1027 array_edition_schema,
1028 {"type": "array", "items": pdu_interface, "minItems": 1},
1029 ]
1030 },
tiernocb83c942018-09-24 17:28:13 +02001031 },
1032 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001033 "minProperties": 1,
tiernocb83c942018-09-24 17:28:13 +02001034}
1035
delacruzramo271d2002019-12-02 21:00:37 +01001036# VNF PKG OPERATIONS
1037vnfpkgop_new_schema = {
1038 "title": "VNF PKG operation creation input schema",
1039 "$schema": "http://json-schema.org/draft-04/schema#",
1040 "type": "object",
1041 "properties": {
1042 "lcmOperationType": string_schema,
1043 "vnfPkgId": id_schema,
1044 "kdu_name": name_schema,
1045 "primitive": name_schema,
1046 "primitive_params": {"type": "object"},
1047 },
garciadeblas4568a372021-03-24 09:19:48 +01001048 "required": [
1049 "lcmOperationType",
1050 "vnfPkgId",
1051 "kdu_name",
1052 "primitive",
1053 "primitive_params",
1054 ],
1055 "additionalProperties": False,
delacruzramo271d2002019-12-02 21:00:37 +01001056}
1057
tiernocb83c942018-09-24 17:28:13 +02001058# USERS
tiernocf042d32019-06-13 09:06:40 +00001059project_role_mappings = {
1060 "title": "list pf projects/roles",
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001061 "$schema": "http://json-schema.org/draft-04/schema#",
tiernocf042d32019-06-13 09:06:40 +00001062 "type": "array",
1063 "items": {
1064 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001065 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001066 "required": ["project", "role"],
garciadeblas4568a372021-03-24 09:19:48 +01001067 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001068 },
garciadeblas4568a372021-03-24 09:19:48 +01001069 "minItems": 1,
tiernocf042d32019-06-13 09:06:40 +00001070}
1071project_role_mappings_optional = {
1072 "title": "list of projects/roles or projects only",
1073 "$schema": "http://json-schema.org/draft-04/schema#",
1074 "type": "array",
1075 "items": {
1076 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001077 "properties": {"project": shortname_schema, "role": shortname_schema},
tiernocf042d32019-06-13 09:06:40 +00001078 "required": ["project"],
garciadeblas4568a372021-03-24 09:19:48 +01001079 "additionalProperties": False,
tiernocf042d32019-06-13 09:06:40 +00001080 },
garciadeblas4568a372021-03-24 09:19:48 +01001081 "minItems": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001082}
tiernocd54a4a2018-09-12 16:40:35 +02001083user_new_schema = {
1084 "$schema": "http://json-schema.org/draft-04/schema#",
1085 "title": "New user schema",
1086 "type": "object",
1087 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001088 "username": string_schema,
tiernoad6d5332020-02-19 14:29:49 +00001089 "domain_name": shortname_schema,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001090 "password": user_passwd_schema,
tiernocb83c942018-09-24 17:28:13 +02001091 "projects": nameshort_list_schema,
tiernocf042d32019-06-13 09:06:40 +00001092 "project_role_mappings": project_role_mappings,
tiernocd54a4a2018-09-12 16:40:35 +02001093 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001094 "required": ["username", "password"],
garciadeblas4568a372021-03-24 09:19:48 +01001095 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001096}
1097user_edit_schema = {
1098 "$schema": "http://json-schema.org/draft-04/schema#",
1099 "title": "User edit schema for administrators",
1100 "type": "object",
1101 "properties": {
garciadeblas6d83f8f2023-06-19 22:34:49 +02001102 "password": user_passwd_schema,
selvi.ja9a1fc82022-04-04 06:54:30 +00001103 "old_password": passwd_schema,
sousaedu80b6fed2021-10-07 15:17:32 +01001104 "username": string_schema, # To allow User Name modification
garciadeblas4568a372021-03-24 09:19:48 +01001105 "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]},
tiernocf042d32019-06-13 09:06:40 +00001106 "project_role_mappings": project_role_mappings,
1107 "add_project_role_mappings": project_role_mappings,
1108 "remove_project_role_mappings": project_role_mappings_optional,
garciadeblas6d83f8f2023-06-19 22:34:49 +02001109 "system_admin_id": id_schema,
1110 "unlock": bool_schema,
1111 "renew": bool_schema,
tiernocb83c942018-09-24 17:28:13 +02001112 },
1113 "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001114 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001115}
1116
1117# PROJECTS
garciadeblas4568a372021-03-24 09:19:48 +01001118topics_with_quota = [
1119 "vnfds",
1120 "nsds",
1121 "slice_templates",
1122 "pduds",
1123 "ns_instances",
1124 "slice_instances",
1125 "vim_accounts",
1126 "wim_accounts",
1127 "sdn_controllers",
1128 "k8sclusters",
1129 "vca",
1130 "k8srepos",
1131 "osmrepos",
1132 "ns_subscriptions",
1133]
tiernocd54a4a2018-09-12 16:40:35 +02001134project_new_schema = {
1135 "$schema": "http://json-schema.org/draft-04/schema#",
1136 "title": "New project schema for administrators",
1137 "type": "object",
1138 "properties": {
tiernofd160572019-01-21 10:41:37 +00001139 "name": shortname_schema,
tiernocd54a4a2018-09-12 16:40:35 +02001140 "admin": bool_schema,
tiernoad6d5332020-02-19 14:29:49 +00001141 "domain_name": shortname_schema,
delacruzramo32bab472019-09-13 12:24:22 +02001142 "quotas": {
1143 "type": "object",
1144 "properties": {topic: integer0_schema for topic in topics_with_quota},
garciadeblas4568a372021-03-24 09:19:48 +01001145 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001146 },
tiernocd54a4a2018-09-12 16:40:35 +02001147 },
1148 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001149 "additionalProperties": False,
tiernocd54a4a2018-09-12 16:40:35 +02001150}
1151project_edit_schema = {
1152 "$schema": "http://json-schema.org/draft-04/schema#",
1153 "title": "Project edit schema for administrators",
1154 "type": "object",
1155 "properties": {
1156 "admin": bool_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001157 "name": shortname_schema, # To allow Project Name modification
delacruzramo32bab472019-09-13 12:24:22 +02001158 "quotas": {
1159 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001160 "properties": {
1161 topic: {"oneOf": [integer0_schema, null_schema]}
1162 for topic in topics_with_quota
1163 },
1164 "additionalProperties": False,
delacruzramo32bab472019-09-13 12:24:22 +02001165 },
tiernocd54a4a2018-09-12 16:40:35 +02001166 },
1167 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001168 "minProperties": 1,
tiernocd54a4a2018-09-12 16:40:35 +02001169}
1170
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001171# ROLES
1172roles_new_schema = {
1173 "$schema": "http://json-schema.org/draft-04/schema#",
1174 "title": "New role schema for administrators",
1175 "type": "object",
1176 "properties": {
1177 "name": shortname_schema,
tierno1f029d82019-06-13 22:37:04 +00001178 "permissions": {
1179 "type": "object",
1180 "patternProperties": {
1181 ".": bool_schema,
1182 },
1183 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001184 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001185 },
tierno1f029d82019-06-13 22:37:04 +00001186 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001187 "additionalProperties": False,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001188}
1189roles_edit_schema = {
1190 "$schema": "http://json-schema.org/draft-04/schema#",
1191 "title": "Roles edit schema for administrators",
1192 "type": "object",
1193 "properties": {
tierno1f029d82019-06-13 22:37:04 +00001194 "name": shortname_schema,
1195 "permissions": {
1196 "type": "object",
garciadeblas4568a372021-03-24 09:19:48 +01001197 "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}},
tierno1f029d82019-06-13 22:37:04 +00001198 # "minProperties": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001199 },
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001200 },
tierno1f029d82019-06-13 22:37:04 +00001201 "additionalProperties": False,
garciadeblas4568a372021-03-24 09:19:48 +01001202 "minProperties": 1,
Eduardo Sousa5c01e192019-05-08 02:35:47 +01001203}
1204
tiernocd54a4a2018-09-12 16:40:35 +02001205# GLOBAL SCHEMAS
tierno0f98af52018-03-19 10:28:22 +01001206
1207nbi_new_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001208 "users": user_new_schema,
1209 "projects": project_new_schema,
tierno09c073e2018-04-26 13:36:48 +02001210 "vim_accounts": vim_account_new_schema,
tierno65acb4d2018-04-06 16:42:40 +02001211 "sdns": sdn_new_schema,
1212 "ns_instantiate": ns_instantiate,
1213 "ns_action": ns_action,
tiernocb83c942018-09-24 17:28:13 +02001214 "ns_scale": ns_scale,
aticig544a2ae2022-04-05 09:00:17 +03001215 "ns_update": ns_update,
garciadeblas0964edf2022-02-11 00:43:44 +01001216 "ns_heal": ns_heal,
tiernocb83c942018-09-24 17:28:13 +02001217 "pdus": pdu_new_schema,
tierno0f98af52018-03-19 10:28:22 +01001218}
1219
1220nbi_edit_input_schemas = {
tiernocd54a4a2018-09-12 16:40:35 +02001221 "users": user_edit_schema,
1222 "projects": project_edit_schema,
tierno09c073e2018-04-26 13:36:48 +02001223 "vim_accounts": vim_account_edit_schema,
tiernocb83c942018-09-24 17:28:13 +02001224 "sdns": sdn_edit_schema,
1225 "pdus": pdu_edit_schema,
tierno0f98af52018-03-19 10:28:22 +01001226}
1227
Felipe Vicens07f31722018-10-29 15:16:44 +01001228# NETSLICE SCHEMAS
tierno032916c2019-03-22 13:27:12 +00001229nsi_subnet_instantiate = deepcopy(ns_instantiate)
1230nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema"
1231nsi_subnet_instantiate["properties"]["id"] = name_schema
1232del nsi_subnet_instantiate["required"]
garciadeblasdaf8cc52018-11-30 14:17:20 +01001233
1234nsi_vld_instantiate = {
1235 "title": "netslice vld instantiation params input schema",
1236 "$schema": "http://json-schema.org/draft-04/schema#",
1237 "type": "object",
1238 "properties": {
1239 "name": string_schema,
tierno195a36c2020-09-18 14:18:55 +00001240 "vim-network-name": {"oneOf": [string_schema, object_schema]},
1241 "vim-network-id": {"oneOf": [string_schema, object_schema]},
garciadeblasdaf8cc52018-11-30 14:17:20 +01001242 "ip-profile": object_schema,
1243 },
delacruzramoc061f562019-04-05 11:00:02 +02001244 "required": ["name"],
garciadeblas4568a372021-03-24 09:19:48 +01001245 "additionalProperties": False,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001246}
1247
Felipe Vicens07f31722018-10-29 15:16:44 +01001248nsi_instantiate = {
1249 "title": "netslice action instantiate input schema",
1250 "$schema": "http://json-schema.org/draft-04/schema#",
1251 "type": "object",
1252 "properties": {
1253 "lcmOperationType": string_schema,
Felipe Vicens126af572019-06-05 19:13:04 +02001254 "netsliceInstanceId": id_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001255 "nsiName": name_schema,
tierno4f9d4ae2019-03-20 17:24:11 +00001256 "nsiDescription": {"oneOf": [description_schema, null_schema]},
tierno9e5eea32018-11-29 09:42:09 +00001257 "nstId": string_schema,
Felipe Vicens07f31722018-10-29 15:16:44 +01001258 "vimAccountId": id_schema,
tiernoa8186a52020-01-14 15:54:48 +00001259 "timeout_nsi_deploy": integer1_schema,
Felipe Vicens26202bb2020-05-24 18:57:33 +02001260 "ssh_keys": {"type": "array", "items": {"type": "string"}},
Felipe Vicens07f31722018-10-29 15:16:44 +01001261 "nsi_id": id_schema,
tierno032916c2019-03-22 13:27:12 +00001262 "additionalParamsForNsi": object_schema,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001263 "netslice-subnet": {
Felipe Vicens07f31722018-10-29 15:16:44 +01001264 "type": "array",
1265 "minItems": 1,
garciadeblas4568a372021-03-24 09:19:48 +01001266 "items": nsi_subnet_instantiate,
garciadeblasdaf8cc52018-11-30 14:17:20 +01001267 },
garciadeblas4568a372021-03-24 09:19:48 +01001268 "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate},
Felipe Vicens07f31722018-10-29 15:16:44 +01001269 },
Felipe Vicensc8bbaaa2018-12-01 04:42:40 +01001270 "required": ["nsiName", "nstId", "vimAccountId"],
garciadeblas4568a372021-03-24 09:19:48 +01001271 "additionalProperties": False,
Felipe Vicens07f31722018-10-29 15:16:44 +01001272}
1273
garciadeblas4568a372021-03-24 09:19:48 +01001274nsi_action = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001275
garciadeblas4568a372021-03-24 09:19:48 +01001276nsi_terminate = {}
Felipe Vicens07f31722018-10-29 15:16:44 +01001277
preethika.p329b8182020-04-22 12:25:39 +05301278nsinstancesubscriptionfilter_schema = {
1279 "title": "instance identifier schema",
1280 "$schema": "http://json-schema.org/draft-07/schema#",
1281 "type": "object",
1282 "properties": {
1283 "nsdIds": {"type": "array"},
1284 "vnfdIds": {"type": "array"},
1285 "pnfdIds": {"type": "array"},
1286 "nsInstanceIds": {"type": "array"},
1287 "nsInstanceNames": {"type": "array"},
1288 },
1289}
1290
1291nslcmsub_schema = {
1292 "title": "nslcmsubscription input schema",
1293 "$schema": "http://json-schema.org/draft-07/schema#",
1294 "type": "object",
1295 "properties": {
1296 "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema,
1297 "notificationTypes": {
1298 "type": "array",
1299 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001300 "enum": [
1301 "NsLcmOperationOccurrenceNotification",
1302 "NsChangeNotification",
1303 "NsIdentifierCreationNotification",
1304 "NsIdentifierDeletionNotification",
1305 ]
1306 },
preethika.p329b8182020-04-22 12:25:39 +05301307 },
1308 "operationTypes": {
1309 "type": "array",
garciadeblas4568a372021-03-24 09:19:48 +01001310 "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]},
preethika.p329b8182020-04-22 12:25:39 +05301311 },
1312 "operationStates": {
1313 "type": "array",
1314 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001315 "enum": [
1316 "PROCESSING",
1317 "COMPLETED",
1318 "PARTIALLY_COMPLETED",
1319 "FAILED",
1320 "FAILED_TEMP",
1321 "ROLLING_BACK",
1322 "ROLLED_BACK",
1323 ]
1324 },
preethika.p329b8182020-04-22 12:25:39 +05301325 },
garciadeblas4568a372021-03-24 09:19:48 +01001326 "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}},
preethika.p329b8182020-04-22 12:25:39 +05301327 "lcmOpNameImpactingNsComponent": {
1328 "type": "array",
1329 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001330 "enum": [
1331 "VNF_INSTANTIATE",
1332 "VNF_SCALE",
1333 "VNF_SCALE_TO_LEVEL",
1334 "VNF_CHANGE_FLAVOUR",
1335 "VNF_TERMINATE",
1336 "VNF_HEAL",
1337 "VNF_OPERATE",
1338 "VNF_CHANGE_EXT_CONN",
1339 "VNF_MODIFY_INFO",
1340 "NS_INSTANTIATE",
1341 "NS_SCALE",
1342 "NS_UPDATE",
1343 "NS_TERMINATE",
1344 "NS_HEAL",
1345 ]
1346 },
preethika.p329b8182020-04-22 12:25:39 +05301347 },
1348 "lcmOpOccStatusImpactingNsComponent": {
1349 "type": "array",
1350 "items": {
garciadeblas4568a372021-03-24 09:19:48 +01001351 "enum": [
1352 "START",
1353 "COMPLETED",
1354 "PARTIALLY_COMPLETED",
1355 "FAILED",
1356 "ROLLED_BACK",
1357 ]
1358 },
preethika.p329b8182020-04-22 12:25:39 +05301359 },
1360 },
1361 "allOf": [
1362 {
1363 "if": {
1364 "properties": {
1365 "notificationTypes": {
1366 "contains": {"const": "NsLcmOperationOccurrenceNotification"}
1367 }
1368 },
1369 },
1370 "then": {
1371 "anyOf": [
1372 {"required": ["operationTypes"]},
1373 {"required": ["operationStates"]},
1374 ]
garciadeblas4568a372021-03-24 09:19:48 +01001375 },
preethika.p329b8182020-04-22 12:25:39 +05301376 },
1377 {
1378 "if": {
1379 "properties": {
garciadeblas4568a372021-03-24 09:19:48 +01001380 "notificationTypes": {"contains": {"const": "NsChangeNotification"}}
preethika.p329b8182020-04-22 12:25:39 +05301381 },
1382 },
1383 "then": {
1384 "anyOf": [
1385 {"required": ["nsComponentTypes"]},
1386 {"required": ["lcmOpNameImpactingNsComponent"]},
1387 {"required": ["lcmOpOccStatusImpactingNsComponent"]},
1388 ]
garciadeblas4568a372021-03-24 09:19:48 +01001389 },
1390 },
1391 ],
preethika.p329b8182020-04-22 12:25:39 +05301392}
1393
1394authentication_schema = {
1395 "title": "authentication schema for subscription",
1396 "$schema": "http://json-schema.org/draft-07/schema#",
1397 "type": "object",
1398 "properties": {
1399 "authType": {"enum": ["basic"]},
1400 "paramsBasic": {
1401 "type": "object",
1402 "properties": {
sousaedu80b6fed2021-10-07 15:17:32 +01001403 "userName": string_schema,
preethika.p329b8182020-04-22 12:25:39 +05301404 "password": passwd_schema,
1405 },
1406 },
1407 },
1408}
1409
1410subscription = {
1411 "title": "subscription input schema",
1412 "$schema": "http://json-schema.org/draft-07/schema#",
1413 "type": "object",
1414 "properties": {
1415 "filter": nslcmsub_schema,
1416 "CallbackUri": description_schema,
garciadeblas4568a372021-03-24 09:19:48 +01001417 "authentication": authentication_schema,
preethika.p329b8182020-04-22 12:25:39 +05301418 },
1419 "required": ["CallbackUri"],
1420}
1421
selvi.jf1004592022-04-29 05:42:35 +00001422vnflcmsub_schema = {
1423 "title": "vnflcmsubscription input schema",
1424 "$schema": "http://json-schema.org/draft-07/schema#",
1425 "type": "object",
1426 "properties": {
1427 "VnfInstanceSubscriptionFilter": {
1428 "type": "object",
1429 "properties": {
1430 "vnfdIds": {"type": "array"},
1431 "vnfInstanceIds": {"type": "array"},
1432 },
1433 },
1434 "notificationTypes": {
1435 "type": "array",
1436 "items": {
1437 "enum": [
1438 "VnfIdentifierCreationNotification",
1439 "VnfLcmOperationOccurrenceNotification",
garciadeblasf2af4a12023-01-24 16:56:54 +01001440 "VnfIdentifierDeletionNotification",
1441 ]
1442 },
selvi.jf1004592022-04-29 05:42:35 +00001443 },
1444 "operationTypes": {
1445 "type": "array",
1446 "items": {
1447 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001448 "INSTANTIATE",
1449 "SCALE",
1450 "SCALE_TO_LEVEL",
1451 "CHANGE_FLAVOUR",
1452 "TERMINATE",
1453 "HEAL",
1454 "OPERATE",
1455 "CHANGE_EXT_CONN",
1456 "MODIFY_INFO",
1457 "CREATE_SNAPSHOT",
1458 "REVERT_TO_SNAPSHOT",
1459 "CHANGE_VNFPKG",
1460 ]
1461 },
selvi.jf1004592022-04-29 05:42:35 +00001462 },
1463 "operationStates": {
1464 "type": "array",
1465 "items": {
1466 "enum": [
garciadeblasf2af4a12023-01-24 16:56:54 +01001467 "STARTING",
1468 "PROCESSING",
1469 "COMPLETED",
1470 "FAILED_TEMP",
1471 "FAILED",
1472 "ROLLING_BACK",
1473 "ROLLED_BACK",
1474 ]
1475 },
1476 },
selvi.jf1004592022-04-29 05:42:35 +00001477 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001478 "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"],
1479}
selvi.jf1004592022-04-29 05:42:35 +00001480
1481vnf_subscription = {
1482 "title": "vnf subscription input schema",
1483 "$schema": "http://json-schema.org/draft-07/schema#",
1484 "type": "object",
1485 "properties": {
1486 "filter": vnflcmsub_schema,
1487 "CallbackUri": description_schema,
garciadeblasf2af4a12023-01-24 16:56:54 +01001488 "authentication": authentication_schema,
selvi.jf1004592022-04-29 05:42:35 +00001489 },
garciadeblasf2af4a12023-01-24 16:56:54 +01001490 "required": ["filter", "CallbackUri"],
selvi.jf1004592022-04-29 05:42:35 +00001491}
1492
tierno0f98af52018-03-19 10:28:22 +01001493
1494class ValidationError(Exception):
tierno36ec8602018-11-02 17:27:11 +01001495 def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY):
1496 self.http_code = http_code
1497 Exception.__init__(self, message)
tierno0f98af52018-03-19 10:28:22 +01001498
1499
tiernob24258a2018-10-04 18:39:49 +02001500def validate_input(indata, schema_to_use):
tierno0f98af52018-03-19 10:28:22 +01001501 """
tiernocd54a4a2018-09-12 16:40:35 +02001502 Validates input data against json schema
tierno0f98af52018-03-19 10:28:22 +01001503 :param indata: user input data. Should be a dictionary
tiernob24258a2018-10-04 18:39:49 +02001504 :param schema_to_use: jsonschema to test
1505 :return: None if ok, raises ValidationError exception on error
tierno0f98af52018-03-19 10:28:22 +01001506 """
1507 try:
tierno0f98af52018-03-19 10:28:22 +01001508 if schema_to_use:
1509 js_v(indata, schema_to_use)
1510 return None
1511 except js_e.ValidationError as e:
1512 if e.path:
tierno0da52252018-06-27 15:47:22 +02001513 error_pos = "at '" + ":".join(map(str, e.path)) + "'"
tierno0f98af52018-03-19 10:28:22 +01001514 else:
1515 error_pos = ""
tierno441dbbf2018-07-10 12:52:48 +02001516 raise ValidationError("Format error {} '{}' ".format(error_pos, e.message))
tierno36ec8602018-11-02 17:27:11 +01001517 except js_e.SchemaError:
garciadeblas4568a372021-03-24 09:19:48 +01001518 raise ValidationError(
1519 "Bad json schema {}".format(schema_to_use),
1520 http_code=HTTPStatus.INTERNAL_SERVER_ERROR,
1521 )
delacruzramoc061f562019-04-05 11:00:02 +02001522
1523
1524def is_valid_uuid(x):
1525 """
1526 Test for a valid UUID
1527 :param x: string to test
1528 :return: True if x is a valid uuid, False otherwise
1529 """
1530 try:
1531 if UUID(x):
1532 return True
tiernobdebce92019-07-01 15:36:49 +00001533 except (TypeError, ValueError, AttributeError):
delacruzramoc061f562019-04-05 11:00:02 +02001534 return False