| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| tierno | d125caf | 2018-11-22 16:05:54 +0000 | [diff] [blame] | 3 | # 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 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 16 | from jsonschema import validate as js_v, exceptions as js_e |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 17 | from http import HTTPStatus |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 18 | from copy import deepcopy |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 19 | from uuid import UUID # To test for valid UUID |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 20 | |
| 21 | __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>" |
| 22 | __version__ = "0.1" |
| 23 | version_date = "Mar 2018" |
| 24 | |
| 25 | """ |
| 26 | Validator of input data using JSON schemas for those items that not contains an OSM yang information model |
| 27 | """ |
| 28 | |
| 29 | # Basis schemas |
| 30 | patern_name = "^[ -~]+$" |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 31 | shortname_schema = { |
| 32 | "type": "string", |
| 33 | "minLength": 1, |
| 34 | "maxLength": 60, |
| 35 | "pattern": "^[^,;()\\.\\$'\"]+$", |
| 36 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 37 | passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 38 | name_schema = { |
| 39 | "type": "string", |
| 40 | "minLength": 1, |
| 41 | "maxLength": 255, |
| 42 | "pattern": "^[^,;()'\"]+$", |
| 43 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 44 | string_schema = {"type": "string", "minLength": 1, "maxLength": 255} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 45 | xml_text_schema = { |
| 46 | "type": "string", |
| 47 | "minLength": 1, |
| 48 | "maxLength": 1000, |
| 49 | "pattern": "^[^']+$", |
| 50 | } |
| 51 | description_schema = { |
| 52 | "type": ["string", "null"], |
| 53 | "maxLength": 255, |
| 54 | "pattern": "^[^'\"]+$", |
| 55 | } |
| 56 | long_description_schema = { |
| 57 | "type": ["string", "null"], |
| 58 | "maxLength": 3000, |
| 59 | "pattern": "^[^'\"]+$", |
| 60 | } |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 61 | id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36} |
| 62 | bool_schema = {"type": "boolean"} |
| 63 | null_schema = {"type": "null"} |
| tierno | 2236d20 | 2018-05-16 19:05:16 +0200 | [diff] [blame] | 64 | # "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}$" |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 65 | id_schema = { |
| 66 | "type": "string", |
| 67 | "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$", |
| 68 | } |
| 69 | time_schema = { |
| 70 | "type": "string", |
| 71 | "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}", |
| 72 | } |
| 73 | pci_schema = { |
| 74 | "type": "string", |
| 75 | "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$", |
| 76 | } |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 77 | # allows [] for wildcards. For that reason huge length limit is set |
| 78 | pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\\[\\]]{12,40}$"} |
| K Sai Kiran | 990ac46 | 2020-05-20 12:25:12 +0530 | [diff] [blame] | 79 | http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 80 | bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"} |
| 81 | memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"} |
| 82 | integer0_schema = {"type": "integer", "minimum": 0} |
| 83 | integer1_schema = {"type": "integer", "minimum": 1} |
| tierno | 8700604 | 2018-10-24 12:50:20 +0200 | [diff] [blame] | 84 | path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 85 | vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095} |
| 86 | vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 87 | mac_schema = { |
| 88 | "type": "string", |
| 89 | "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$", |
| 90 | } # must be unicast: LSB bit of MSB byte ==0 |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 91 | dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 92 | # mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 93 | ip_schema = { |
| 94 | "type": "string", |
| 95 | "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]?)$", |
| 96 | } |
| 97 | ip_prefix_schema = { |
| 98 | "type": "string", |
| 99 | "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" |
| 100 | "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$", |
| 101 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 102 | port_schema = {"type": "integer", "minimum": 1, "maximum": 65534} |
| 103 | object_schema = {"type": "object"} |
| 104 | schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2} |
| 105 | # schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 106 | log_level_schema = { |
| 107 | "type": "string", |
| 108 | "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], |
| 109 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 110 | checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"} |
| 111 | size_schema = {"type": "integer", "minimum": 1, "maximum": 100} |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 112 | array_edition_schema = { |
| 113 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 114 | "patternProperties": {"^\\$": {}}, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 115 | "additionalProperties": False, |
| 116 | "minProperties": 1, |
| 117 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 118 | nameshort_list_schema = { |
| 119 | "type": "array", |
| 120 | "minItems": 1, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 121 | "items": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 122 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 123 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 124 | description_list_schema = { |
| 125 | "type": "array", |
| 126 | "minItems": 1, |
| 127 | "items": description_schema, |
| 128 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 129 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 130 | ns_instantiate_vdu = { |
| 131 | "title": "ns action instantiate input schema for vdu", |
| 132 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 133 | "type": "object", |
| 134 | "properties": { |
| 135 | "id": name_schema, |
| 136 | "volume": { |
| 137 | "type": "array", |
| 138 | "minItems": 1, |
| 139 | "items": { |
| 140 | "type": "object", |
| 141 | "properties": { |
| 142 | "name": name_schema, |
| 143 | "vim-volume-id": name_schema, |
| 144 | }, |
| 145 | "required": ["name", "vim-volume-id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 146 | "additionalProperties": False, |
| 147 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 148 | }, |
| 149 | "interface": { |
| 150 | "type": "array", |
| 151 | "minItems": 1, |
| 152 | "items": { |
| 153 | "type": "object", |
| 154 | "properties": { |
| 155 | "name": name_schema, |
| 156 | "ip-address": ip_schema, |
| 157 | "mac-address": mac_schema, |
| 158 | "floating-ip-required": bool_schema, |
| 159 | }, |
| 160 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 161 | "additionalProperties": False, |
| 162 | }, |
| 163 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 164 | }, |
| 165 | "required": ["id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 166 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | ip_profile_dns_schema = { |
| 170 | "type": "array", |
| 171 | "minItems": 1, |
| 172 | "items": { |
| 173 | "type": "object", |
| 174 | "properties": { |
| 175 | "address": ip_schema, |
| 176 | }, |
| 177 | "required": ["address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 178 | "additionalProperties": False, |
| 179 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | ip_profile_dhcp_schema = { |
| 183 | "type": "object", |
| 184 | "properties": { |
| 185 | "enabled": {"type": "boolean"}, |
| 186 | "count": integer1_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 187 | "start-address": ip_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 188 | }, |
| 189 | "additionalProperties": False, |
| 190 | } |
| 191 | |
| 192 | ip_profile_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 193 | "title": "ip profile validation schema", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 194 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 195 | "type": "object", |
| 196 | "properties": { |
| 197 | "ip-version": {"enum": ["ipv4", "ipv6"]}, |
| 198 | "subnet-address": ip_prefix_schema, |
| 199 | "gateway-address": ip_schema, |
| 200 | "dns-server": ip_profile_dns_schema, |
| 201 | "dhcp-params": ip_profile_dhcp_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 202 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | ip_profile_update_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 206 | "title": "ip profile validation schema", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 207 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 208 | "type": "object", |
| 209 | "properties": { |
| 210 | "ip-version": {"enum": ["ipv4", "ipv6"]}, |
| 211 | "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]}, |
| 212 | "gateway-address": {"oneOf": [null_schema, ip_schema]}, |
| 213 | "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 214 | "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]}, |
| 215 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 216 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 217 | } |
| 218 | |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 219 | provider_network_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 220 | "title": "provider network validation schema", |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 221 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 222 | "type": "object", |
| 223 | "properties": { |
| 224 | "physical-network": name_schema, |
| 225 | "segmentation-id": name_schema, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 226 | "sdn-ports": { # external ports to append to the SDN-assist network |
| 227 | "type": "array", |
| 228 | "items": { |
| 229 | "type": "object", |
| 230 | "properties": { |
| 231 | "switch_id": shortname_schema, |
| 232 | "switch_port": shortname_schema, |
| 233 | "mac_address": mac_schema, |
| 234 | "vlan": vlan_schema, |
| 235 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 236 | "additionalProperties": True, |
| 237 | }, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 238 | }, |
| 239 | "network-type": shortname_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 240 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 241 | "additionalProperties": True, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 244 | ns_instantiate_internal_vld = { |
| 245 | "title": "ns action instantiate input schema for vdu", |
| 246 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 247 | "type": "object", |
| 248 | "properties": { |
| 249 | "name": name_schema, |
| 250 | "vim-network-name": name_schema, |
| gcalvino | 17d5b73 | 2018-12-17 16:26:21 +0100 | [diff] [blame] | 251 | "vim-network-id": name_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 252 | "ip-profile": ip_profile_update_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 253 | "provider-network": provider_network_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 254 | "internal-connection-point": { |
| 255 | "type": "array", |
| 256 | "minItems": 1, |
| 257 | "items": { |
| 258 | "type": "object", |
| 259 | "properties": { |
| 260 | "id-ref": name_schema, |
| 261 | "ip-address": ip_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 262 | # "mac-address": mac_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 263 | }, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 264 | "required": ["id-ref"], |
| 265 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 266 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 267 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 268 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 269 | }, |
| 270 | "required": ["name"], |
| 271 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 272 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 273 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 274 | |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 275 | additional_params_for_vnf = { |
| 276 | "type": "array", |
| 277 | "items": { |
| 278 | "type": "object", |
| 279 | "properties": { |
| 280 | "member-vnf-index": name_schema, |
| 281 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 282 | "k8s-namespace": name_schema, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 283 | "config-units": integer1_schema, # number of configuration units of this vnf, by default 1 |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 284 | "additionalParamsForVdu": { |
| 285 | "type": "array", |
| 286 | "items": { |
| 287 | "type": "object", |
| 288 | "properties": { |
| 289 | "vdu_id": name_schema, |
| 290 | "additionalParams": object_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 291 | "config-units": integer1_schema, # number of configuration units of this vdu, by default 1 |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 292 | }, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 293 | "required": ["vdu_id"], |
| 294 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 295 | "additionalProperties": False, |
| 296 | }, |
| 297 | }, |
| 298 | "additionalParamsForKdu": { |
| 299 | "type": "array", |
| 300 | "items": { |
| 301 | "type": "object", |
| 302 | "properties": { |
| 303 | "kdu_name": name_schema, |
| 304 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 305 | "kdu_model": name_schema, |
| 306 | "k8s-namespace": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 307 | "config-units": integer1_schema, # number of configuration units of this knf, by default 1 |
| romeromonser | bfebfc0 | 2021-05-28 10:51:35 +0200 | [diff] [blame] | 308 | "kdu-deployment-name": name_schema, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 309 | }, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 310 | "required": ["kdu_name"], |
| 311 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 312 | "additionalProperties": False, |
| 313 | }, |
| 314 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 315 | }, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 316 | "required": ["member-vnf-index"], |
| 317 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 318 | "additionalProperties": False, |
| 319 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 320 | } |
| 321 | |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 322 | ns_instantiate = { |
| 323 | "title": "ns action instantiate input schema", |
| 324 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 325 | "type": "object", |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 326 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 327 | "lcmOperationType": string_schema, |
| 328 | "nsInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 329 | "netsliceInstanceId": id_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 330 | "nsName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 331 | "nsDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 332 | "nsdId": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 333 | "vcaId": id_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 334 | "vimAccountId": id_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 335 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| magnussonl | f318b30 | 2020-01-20 18:38:18 +0100 | [diff] [blame] | 336 | "placement-engine": string_schema, |
| 337 | "placement-constraints": object_schema, |
| tierno | bee085c | 2018-12-12 17:03:04 +0000 | [diff] [blame] | 338 | "additionalParamsForNs": object_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 339 | "additionalParamsForVnf": additional_params_for_vnf, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 340 | "config-units": integer1_schema, # number of configuration units of this ns, by default 1 |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 341 | "k8s-namespace": name_schema, |
| tierno | fc5089c | 2018-10-31 09:28:11 +0100 | [diff] [blame] | 342 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 343 | "timeout_ns_deploy": integer1_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 344 | "nsr_id": id_schema, |
| tierno | cc10343 | 2018-10-19 14:10:35 +0200 | [diff] [blame] | 345 | "vduImage": name_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 346 | "vnf": { |
| 347 | "type": "array", |
| 348 | "minItems": 1, |
| 349 | "items": { |
| 350 | "type": "object", |
| 351 | "properties": { |
| 352 | "member-vnf-index": name_schema, |
| 353 | "vimAccountId": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 354 | "vcaId": id_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 355 | "vdu": { |
| 356 | "type": "array", |
| 357 | "minItems": 1, |
| 358 | "items": ns_instantiate_vdu, |
| 359 | }, |
| 360 | "internal-vld": { |
| 361 | "type": "array", |
| 362 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 363 | "items": ns_instantiate_internal_vld, |
| 364 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 365 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 366 | "required": ["member-vnf-index"], |
| 367 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 368 | "additionalProperties": False, |
| 369 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 370 | }, |
| 371 | "vld": { |
| 372 | "type": "array", |
| 373 | "minItems": 1, |
| 374 | "items": { |
| 375 | "type": "object", |
| 376 | "properties": { |
| 377 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 378 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 379 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| Felipe Vicens | 09e6542 | 2019-01-22 15:06:46 +0100 | [diff] [blame] | 380 | "ns-net": object_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 381 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 382 | "ip-profile": object_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 383 | "provider-network": provider_network_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 384 | "vnfd-connection-point-ref": { |
| 385 | "type": "array", |
| 386 | "minItems": 1, |
| 387 | "items": { |
| 388 | "type": "object", |
| 389 | "properties": { |
| 390 | "member-vnf-index-ref": name_schema, |
| 391 | "vnfd-connection-point-ref": name_schema, |
| 392 | "ip-address": ip_schema, |
| 393 | # "mac-address": mac_schema, |
| 394 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 395 | "required": [ |
| 396 | "member-vnf-index-ref", |
| 397 | "vnfd-connection-point-ref", |
| 398 | ], |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 399 | "minProperties": 3, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 400 | "additionalProperties": False, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 401 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 402 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 403 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 404 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 405 | "additionalProperties": False, |
| 406 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 407 | }, |
| 408 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 409 | "required": ["nsName", "nsdId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 410 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 411 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 412 | |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 413 | ns_terminate = { |
| 414 | "title": "ns terminate input schema", |
| 415 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 416 | "type": "object", |
| 417 | "properties": { |
| 418 | "lcmOperationType": string_schema, |
| 419 | "nsInstanceId": id_schema, |
| 420 | "autoremove": bool_schema, |
| 421 | "timeout_ns_terminate": integer1_schema, |
| 422 | "skip_terminate_primitives": bool_schema, |
| tierno | 0b8752f | 2020-05-12 09:42:02 +0000 | [diff] [blame] | 423 | "netsliceInstanceId": id_schema, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 424 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 425 | "additionalProperties": False, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 428 | ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 429 | "title": "ns action input schema", |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 430 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 431 | "type": "object", |
| 432 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 433 | "lcmOperationType": string_schema, |
| 434 | "nsInstanceId": id_schema, |
| tierno | f5298be | 2018-05-16 14:43:57 +0200 | [diff] [blame] | 435 | "member_vnf_index": name_schema, |
| 436 | "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future |
| tierno | 7ce1db9 | 2018-07-25 12:50:52 +0200 | [diff] [blame] | 437 | "vdu_id": name_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 438 | "vdu_count_index": integer0_schema, |
| tierno | 9cb7d67 | 2019-10-30 12:13:48 +0000 | [diff] [blame] | 439 | "kdu_name": name_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 440 | "primitive": name_schema, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 441 | "timeout_ns_action": integer1_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 442 | "primitive_params": {"type": "object"}, |
| 443 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 444 | "required": ["primitive", "primitive_params"], # TODO add member_vnf_index |
| 445 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 446 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 447 | ns_scale = { # TODO for the moment it is only VDU-scaling |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 448 | "title": "ns scale input schema", |
| 449 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 450 | "type": "object", |
| 451 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 452 | "lcmOperationType": string_schema, |
| 453 | "nsInstanceId": id_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 454 | "scaleType": {"enum": ["SCALE_VNF"]}, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 455 | "timeout_ns_scale": integer1_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 456 | "scaleVnfData": { |
| 457 | "type": "object", |
| 458 | "properties": { |
| 459 | "vnfInstanceId": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 460 | "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]}, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 461 | "scaleByStepData": { |
| 462 | "type": "object", |
| 463 | "properties": { |
| 464 | "scaling-group-descriptor": name_schema, |
| 465 | "member-vnf-index": name_schema, |
| 466 | "scaling-policy": name_schema, |
| 467 | }, |
| 468 | "required": ["scaling-group-descriptor", "member-vnf-index"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 469 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 470 | }, |
| 471 | }, |
| 472 | "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 473 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 474 | }, |
| 475 | "scaleTime": time_schema, |
| 476 | }, |
| 477 | "required": ["scaleType", "scaleVnfData"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 478 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 479 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 480 | |
| 481 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 482 | schema_version = {"type": "string", "enum": ["1.0"]} |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 483 | schema_type = {"type": "string"} |
| tierno | b3d0a0e | 2019-11-13 15:57:51 +0000 | [diff] [blame] | 484 | vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 485 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 486 | vim_account_edit_schema = { |
| 487 | "title": "vim_account edit input schema", |
| 488 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 489 | "type": "object", |
| 490 | "properties": { |
| 491 | "name": name_schema, |
| 492 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 493 | "vim": name_schema, |
| 494 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 495 | "vim_type": vim_type, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 496 | "vim_url": description_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 497 | # "vim_url_admin": description_schema, |
| 498 | # "vim_tenant": name_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 499 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame^] | 500 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 501 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 502 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 503 | "config": {"type": "object"}, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 504 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 505 | "additionalProperties": False, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 506 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 507 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 508 | vim_account_new_schema = { |
| 509 | "title": "vim_account creation input schema", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 510 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 511 | "type": "object", |
| 512 | "properties": { |
| 513 | "schema_version": schema_version, |
| 514 | "schema_type": schema_type, |
| 515 | "name": name_schema, |
| 516 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 517 | "vim": name_schema, |
| 518 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 519 | "vim_type": vim_type, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 520 | "vim_url": description_schema, |
| 521 | # "vim_url_admin": description_schema, |
| 522 | # "vim_tenant": name_schema, |
| 523 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame^] | 524 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 525 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 526 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 527 | "config": {"type": "object"}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 528 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 529 | "required": [ |
| 530 | "name", |
| 531 | "vim_url", |
| 532 | "vim_type", |
| 533 | "vim_user", |
| 534 | "vim_password", |
| 535 | "vim_tenant_name", |
| 536 | ], |
| 537 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 538 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 539 | |
| tierno | 8580772 | 2019-12-20 14:11:35 +0000 | [diff] [blame] | 540 | wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 541 | |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 542 | wim_account_edit_schema = { |
| 543 | "title": "wim_account edit input schema", |
| 544 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 545 | "type": "object", |
| 546 | "properties": { |
| 547 | "name": name_schema, |
| 548 | "description": description_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 549 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 550 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 551 | "wim_url": description_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 552 | "user": shortname_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 553 | "password": passwd_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 554 | "config": {"type": "object"}, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 555 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 556 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | wim_account_new_schema = { |
| 560 | "title": "wim_account creation input schema", |
| 561 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 562 | "type": "object", |
| 563 | "properties": { |
| 564 | "schema_version": schema_version, |
| 565 | "schema_type": schema_type, |
| 566 | "name": name_schema, |
| 567 | "description": description_schema, |
| 568 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 569 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 570 | "wim_url": description_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 571 | "user": shortname_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 572 | "password": passwd_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 573 | "config": { |
| 574 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 575 | "patternProperties": {".": {"not": {"type": "null"}}}, |
| 576 | }, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 577 | }, |
| 578 | "required": ["name", "wim_url", "wim_type"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 579 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 580 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 581 | |
| 582 | sdn_properties = { |
| 583 | "name": name_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 584 | "type": {"type": "string"}, |
| 585 | "url": {"type": "string"}, |
| 586 | "user": shortname_schema, |
| 587 | "password": passwd_schema, |
| 588 | "config": {"type": "object"}, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 589 | "description": description_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 590 | # The folowing are deprecated. Maintanied for backward compatibility |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 591 | "dpid": dpid_Schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 592 | "ip": ip_schema, |
| 593 | "port": port_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 594 | "version": {"type": "string", "minLength": 1, "maxLength": 12}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 595 | } |
| 596 | sdn_new_schema = { |
| 597 | "title": "sdn controller information schema", |
| 598 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 599 | "type": "object", |
| 600 | "properties": sdn_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 601 | "required": ["name", "type"], |
| 602 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 603 | } |
| 604 | sdn_edit_schema = { |
| 605 | "title": "sdn controller update information schema", |
| 606 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 607 | "type": "object", |
| 608 | "properties": sdn_properties, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 609 | # "required": ["name", "port", 'ip', 'dpid', 'type'], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 610 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 611 | } |
| 612 | sdn_port_mapping_schema = { |
| 613 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 614 | "title": "sdn port mapping information schema", |
| 615 | "type": "array", |
| 616 | "items": { |
| 617 | "type": "object", |
| 618 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 619 | "compute_node": shortname_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 620 | "ports": { |
| 621 | "type": "array", |
| 622 | "items": { |
| 623 | "type": "object", |
| 624 | "properties": { |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 625 | "pci": pci_extended_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 626 | "switch_port": shortname_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 627 | "switch_mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 628 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 629 | "required": ["pci"], |
| 630 | }, |
| 631 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 632 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 633 | "required": ["compute_node", "ports"], |
| 634 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 635 | } |
| 636 | sdn_external_port_schema = { |
| 637 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 638 | "title": "External port information", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 639 | "type": "object", |
| 640 | "properties": { |
| 641 | "port": {"type": "string", "minLength": 1, "maxLength": 60}, |
| 642 | "vlan": vlan_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 643 | "mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 644 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 645 | "required": ["port"], |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 646 | } |
| 647 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 648 | # K8s Clusters |
| 649 | k8scluster_nets_schema = { |
| 650 | "title": "k8scluster nets input schema", |
| 651 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 652 | "type": "object", |
| tierno | 8c81ab0 | 2020-02-07 10:18:30 +0000 | [diff] [blame] | 653 | "patternProperties": {".": {"oneOf": [name_schema, null_schema]}}, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 654 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 655 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 656 | } |
| 657 | k8scluster_new_schema = { |
| 658 | "title": "k8scluster creation input schema", |
| 659 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 660 | "type": "object", |
| 661 | "properties": { |
| 662 | "schema_version": schema_version, |
| 663 | "schema_type": schema_type, |
| 664 | "name": name_schema, |
| 665 | "description": description_schema, |
| 666 | "credentials": object_schema, |
| 667 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 668 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 669 | "k8s_version": string_schema, |
| 670 | "nets": k8scluster_nets_schema, |
| 671 | "namespace": name_schema, |
| 672 | "cni": nameshort_list_schema, |
| 673 | }, |
| 674 | "required": ["name", "credentials", "vim_account", "k8s_version", "nets"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 675 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 676 | } |
| 677 | k8scluster_edit_schema = { |
| 678 | "title": "vim_account edit input schema", |
| 679 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 680 | "type": "object", |
| 681 | "properties": { |
| 682 | "name": name_schema, |
| 683 | "description": description_schema, |
| 684 | "credentials": object_schema, |
| 685 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 686 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 687 | "k8s_version": string_schema, |
| 688 | "nets": k8scluster_nets_schema, |
| 689 | "namespace": name_schema, |
| 690 | "cni": nameshort_list_schema, |
| 691 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 692 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 693 | } |
| 694 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 695 | # VCA |
| 696 | vca_new_schema = { |
| 697 | "title": "vca creation input schema", |
| 698 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 699 | "type": "object", |
| 700 | "properties": { |
| 701 | "schema_version": schema_version, |
| 702 | "schema_type": schema_type, |
| 703 | "name": name_schema, |
| 704 | "description": description_schema, |
| 705 | "endpoints": description_list_schema, |
| 706 | "user": shortname_schema, |
| 707 | "secret": passwd_schema, |
| 708 | "cacert": long_description_schema, |
| 709 | "lxd-cloud": shortname_schema, |
| 710 | "lxd-credentials": shortname_schema, |
| 711 | "k8s-cloud": shortname_schema, |
| 712 | "k8s-credentials": shortname_schema, |
| 713 | "model-config": object_schema, |
| 714 | }, |
| 715 | "required": [ |
| 716 | "name", |
| 717 | "endpoints", |
| 718 | "user", |
| 719 | "secret", |
| 720 | "cacert", |
| 721 | "lxd-cloud", |
| 722 | "lxd-credentials", |
| 723 | "k8s-cloud", |
| 724 | "k8s-credentials", |
| 725 | ], |
| 726 | "additionalProperties": False, |
| 727 | } |
| 728 | vca_edit_schema = { |
| 729 | "title": "vca creation input schema", |
| 730 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 731 | "type": "object", |
| 732 | "properties": { |
| 733 | "name": name_schema, |
| 734 | "description": description_schema, |
| 735 | "endpoints": description_list_schema, |
| 736 | "port": integer1_schema, |
| 737 | "user": shortname_schema, |
| 738 | "secret": passwd_schema, |
| 739 | "cacert": long_description_schema, |
| 740 | "lxd-cloud": shortname_schema, |
| 741 | "lxd-credentials": shortname_schema, |
| 742 | "k8s-cloud": shortname_schema, |
| 743 | "k8s-credentials": shortname_schema, |
| 744 | "model-config": object_schema, |
| 745 | }, |
| 746 | "additionalProperties": False, |
| 747 | } |
| 748 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 749 | # K8s Repos |
| tierno | 332e080 | 2019-12-03 23:50:49 +0000 | [diff] [blame] | 750 | k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]} |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 751 | k8srepo_properties = { |
| 752 | "name": name_schema, |
| 753 | "description": description_schema, |
| 754 | "type": k8srepo_types, |
| 755 | "url": description_schema, |
| 756 | } |
| 757 | k8srepo_new_schema = { |
| 758 | "title": "k8scluster creation input schema", |
| 759 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 760 | "type": "object", |
| 761 | "properties": k8srepo_properties, |
| 762 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 763 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 764 | } |
| 765 | k8srepo_edit_schema = { |
| 766 | "title": "vim_account edit input schema", |
| 767 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 768 | "type": "object", |
| 769 | "properties": k8srepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 770 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 771 | } |
| 772 | |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 773 | # OSM Repos |
| 774 | osmrepo_types = {"enum": ["osm"]} |
| 775 | osmrepo_properties = { |
| 776 | "name": name_schema, |
| 777 | "description": description_schema, |
| 778 | "type": osmrepo_types, |
| 779 | "url": description_schema |
| 780 | # "user": shortname_schema, |
| 781 | # "password": passwd_schema |
| 782 | } |
| 783 | osmrepo_new_schema = { |
| 784 | "title": "osm repo creation input schema", |
| 785 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 786 | "type": "object", |
| 787 | "properties": osmrepo_properties, |
| 788 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 789 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 790 | } |
| 791 | osmrepo_edit_schema = { |
| 792 | "title": "osm repo edit input schema", |
| 793 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 794 | "type": "object", |
| 795 | "properties": osmrepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 796 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 797 | } |
| 798 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 799 | # PDUs |
| 800 | pdu_interface = { |
| 801 | "type": "object", |
| 802 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 803 | "name": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 804 | "mgmt": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 805 | "type": {"enum": ["overlay", "underlay"]}, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 806 | "ip-address": ip_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 807 | # TODO, add user, password, ssh-key |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 808 | "mac-address": mac_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 809 | "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port |
| 810 | "vim-network-id": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 811 | # # provide this in case SDN assist must deal with this interface |
| 812 | # "switch-dpid": dpid_Schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 813 | # "switch-port": shortname_schema, |
| 814 | # "switch-mac": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 815 | # "switch-vlan": vlan_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 816 | }, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 817 | "required": ["name", "mgmt", "ip-address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 818 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 819 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 820 | pdu_new_schema = { |
| 821 | "title": "pdu creation input schema", |
| 822 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 823 | "type": "object", |
| 824 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 825 | "name": shortname_schema, |
| 826 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 827 | "description": description_schema, |
| 828 | "shared": bool_schema, |
| 829 | "vims": nameshort_list_schema, |
| 830 | "vim_accounts": nameshort_list_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 831 | "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 832 | }, |
| 833 | "required": ["name", "type", "interfaces"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 834 | "additionalProperties": False, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 835 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 836 | pdu_edit_schema = { |
| 837 | "title": "pdu edit input schema", |
| 838 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 839 | "type": "object", |
| 840 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 841 | "name": shortname_schema, |
| 842 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 843 | "description": description_schema, |
| 844 | "shared": bool_schema, |
| garciadeblas | 84bdd55 | 2018-11-30 22:59:45 +0100 | [diff] [blame] | 845 | "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| 846 | "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 847 | "interfaces": { |
| 848 | "oneOf": [ |
| 849 | array_edition_schema, |
| 850 | {"type": "array", "items": pdu_interface, "minItems": 1}, |
| 851 | ] |
| 852 | }, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 853 | }, |
| 854 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 855 | "minProperties": 1, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 856 | } |
| 857 | |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 858 | # VNF PKG OPERATIONS |
| 859 | vnfpkgop_new_schema = { |
| 860 | "title": "VNF PKG operation creation input schema", |
| 861 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 862 | "type": "object", |
| 863 | "properties": { |
| 864 | "lcmOperationType": string_schema, |
| 865 | "vnfPkgId": id_schema, |
| 866 | "kdu_name": name_schema, |
| 867 | "primitive": name_schema, |
| 868 | "primitive_params": {"type": "object"}, |
| 869 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 870 | "required": [ |
| 871 | "lcmOperationType", |
| 872 | "vnfPkgId", |
| 873 | "kdu_name", |
| 874 | "primitive", |
| 875 | "primitive_params", |
| 876 | ], |
| 877 | "additionalProperties": False, |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 878 | } |
| 879 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 880 | # USERS |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 881 | project_role_mappings = { |
| 882 | "title": "list pf projects/roles", |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 883 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 884 | "type": "array", |
| 885 | "items": { |
| 886 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 887 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 888 | "required": ["project", "role"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 889 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 890 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 891 | "minItems": 1, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 892 | } |
| 893 | project_role_mappings_optional = { |
| 894 | "title": "list of projects/roles or projects only", |
| 895 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 896 | "type": "array", |
| 897 | "items": { |
| 898 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 899 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 900 | "required": ["project"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 901 | "additionalProperties": False, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 902 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 903 | "minItems": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 904 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 905 | user_new_schema = { |
| 906 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 907 | "title": "New user schema", |
| 908 | "type": "object", |
| 909 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 910 | "username": shortname_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 911 | "domain_name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 912 | "password": passwd_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 913 | "projects": nameshort_list_schema, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 914 | "project_role_mappings": project_role_mappings, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 915 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 916 | "required": ["username", "password"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 917 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 918 | } |
| 919 | user_edit_schema = { |
| 920 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 921 | "title": "User edit schema for administrators", |
| 922 | "type": "object", |
| 923 | "properties": { |
| 924 | "password": passwd_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 925 | "username": shortname_schema, # To allow User Name modification |
| 926 | "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 927 | "project_role_mappings": project_role_mappings, |
| 928 | "add_project_role_mappings": project_role_mappings, |
| 929 | "remove_project_role_mappings": project_role_mappings_optional, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 930 | }, |
| 931 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 932 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | # PROJECTS |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 936 | topics_with_quota = [ |
| 937 | "vnfds", |
| 938 | "nsds", |
| 939 | "slice_templates", |
| 940 | "pduds", |
| 941 | "ns_instances", |
| 942 | "slice_instances", |
| 943 | "vim_accounts", |
| 944 | "wim_accounts", |
| 945 | "sdn_controllers", |
| 946 | "k8sclusters", |
| 947 | "vca", |
| 948 | "k8srepos", |
| 949 | "osmrepos", |
| 950 | "ns_subscriptions", |
| 951 | ] |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 952 | project_new_schema = { |
| 953 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 954 | "title": "New project schema for administrators", |
| 955 | "type": "object", |
| 956 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 957 | "name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 958 | "admin": bool_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 959 | "domain_name": shortname_schema, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 960 | "quotas": { |
| 961 | "type": "object", |
| 962 | "properties": {topic: integer0_schema for topic in topics_with_quota}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 963 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 964 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 965 | }, |
| 966 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 967 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 968 | } |
| 969 | project_edit_schema = { |
| 970 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 971 | "title": "Project edit schema for administrators", |
| 972 | "type": "object", |
| 973 | "properties": { |
| 974 | "admin": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 975 | "name": shortname_schema, # To allow Project Name modification |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 976 | "quotas": { |
| 977 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 978 | "properties": { |
| 979 | topic: {"oneOf": [integer0_schema, null_schema]} |
| 980 | for topic in topics_with_quota |
| 981 | }, |
| 982 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 983 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 984 | }, |
| 985 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 986 | "minProperties": 1, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 987 | } |
| 988 | |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 989 | # ROLES |
| 990 | roles_new_schema = { |
| 991 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 992 | "title": "New role schema for administrators", |
| 993 | "type": "object", |
| 994 | "properties": { |
| 995 | "name": shortname_schema, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 996 | "permissions": { |
| 997 | "type": "object", |
| 998 | "patternProperties": { |
| 999 | ".": bool_schema, |
| 1000 | }, |
| 1001 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1002 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1003 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1004 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1005 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1006 | } |
| 1007 | roles_edit_schema = { |
| 1008 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1009 | "title": "Roles edit schema for administrators", |
| 1010 | "type": "object", |
| 1011 | "properties": { |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1012 | "name": shortname_schema, |
| 1013 | "permissions": { |
| 1014 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1015 | "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}}, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1016 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1017 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1018 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1019 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1020 | "minProperties": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1021 | } |
| 1022 | |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1023 | # GLOBAL SCHEMAS |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1024 | |
| 1025 | nbi_new_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1026 | "users": user_new_schema, |
| 1027 | "projects": project_new_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1028 | "vim_accounts": vim_account_new_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 1029 | "sdns": sdn_new_schema, |
| 1030 | "ns_instantiate": ns_instantiate, |
| 1031 | "ns_action": ns_action, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1032 | "ns_scale": ns_scale, |
| 1033 | "pdus": pdu_new_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | nbi_edit_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1037 | "users": user_edit_schema, |
| 1038 | "projects": project_edit_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1039 | "vim_accounts": vim_account_edit_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1040 | "sdns": sdn_edit_schema, |
| 1041 | "pdus": pdu_edit_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1042 | } |
| 1043 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1044 | # NETSLICE SCHEMAS |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1045 | nsi_subnet_instantiate = deepcopy(ns_instantiate) |
| 1046 | nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema" |
| 1047 | nsi_subnet_instantiate["properties"]["id"] = name_schema |
| 1048 | del nsi_subnet_instantiate["required"] |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1049 | |
| 1050 | nsi_vld_instantiate = { |
| 1051 | "title": "netslice vld instantiation params input schema", |
| 1052 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1053 | "type": "object", |
| 1054 | "properties": { |
| 1055 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 1056 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 1057 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1058 | "ip-profile": object_schema, |
| 1059 | }, |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1060 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1061 | "additionalProperties": False, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1062 | } |
| 1063 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1064 | nsi_instantiate = { |
| 1065 | "title": "netslice action instantiate input schema", |
| 1066 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1067 | "type": "object", |
| 1068 | "properties": { |
| 1069 | "lcmOperationType": string_schema, |
| Felipe Vicens | 126af57 | 2019-06-05 19:13:04 +0200 | [diff] [blame] | 1070 | "netsliceInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1071 | "nsiName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 1072 | "nsiDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 9e5eea3 | 2018-11-29 09:42:09 +0000 | [diff] [blame] | 1073 | "nstId": string_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1074 | "vimAccountId": id_schema, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 1075 | "timeout_nsi_deploy": integer1_schema, |
| Felipe Vicens | 26202bb | 2020-05-24 18:57:33 +0200 | [diff] [blame] | 1076 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1077 | "nsi_id": id_schema, |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1078 | "additionalParamsForNsi": object_schema, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1079 | "netslice-subnet": { |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1080 | "type": "array", |
| 1081 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1082 | "items": nsi_subnet_instantiate, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1083 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1084 | "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1085 | }, |
| Felipe Vicens | c8bbaaa | 2018-12-01 04:42:40 +0100 | [diff] [blame] | 1086 | "required": ["nsiName", "nstId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1087 | "additionalProperties": False, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1088 | } |
| 1089 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1090 | nsi_action = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1091 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1092 | nsi_terminate = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1093 | |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1094 | nsinstancesubscriptionfilter_schema = { |
| 1095 | "title": "instance identifier schema", |
| 1096 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1097 | "type": "object", |
| 1098 | "properties": { |
| 1099 | "nsdIds": {"type": "array"}, |
| 1100 | "vnfdIds": {"type": "array"}, |
| 1101 | "pnfdIds": {"type": "array"}, |
| 1102 | "nsInstanceIds": {"type": "array"}, |
| 1103 | "nsInstanceNames": {"type": "array"}, |
| 1104 | }, |
| 1105 | } |
| 1106 | |
| 1107 | nslcmsub_schema = { |
| 1108 | "title": "nslcmsubscription input schema", |
| 1109 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1110 | "type": "object", |
| 1111 | "properties": { |
| 1112 | "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema, |
| 1113 | "notificationTypes": { |
| 1114 | "type": "array", |
| 1115 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1116 | "enum": [ |
| 1117 | "NsLcmOperationOccurrenceNotification", |
| 1118 | "NsChangeNotification", |
| 1119 | "NsIdentifierCreationNotification", |
| 1120 | "NsIdentifierDeletionNotification", |
| 1121 | ] |
| 1122 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1123 | }, |
| 1124 | "operationTypes": { |
| 1125 | "type": "array", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1126 | "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1127 | }, |
| 1128 | "operationStates": { |
| 1129 | "type": "array", |
| 1130 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1131 | "enum": [ |
| 1132 | "PROCESSING", |
| 1133 | "COMPLETED", |
| 1134 | "PARTIALLY_COMPLETED", |
| 1135 | "FAILED", |
| 1136 | "FAILED_TEMP", |
| 1137 | "ROLLING_BACK", |
| 1138 | "ROLLED_BACK", |
| 1139 | ] |
| 1140 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1141 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1142 | "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1143 | "lcmOpNameImpactingNsComponent": { |
| 1144 | "type": "array", |
| 1145 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1146 | "enum": [ |
| 1147 | "VNF_INSTANTIATE", |
| 1148 | "VNF_SCALE", |
| 1149 | "VNF_SCALE_TO_LEVEL", |
| 1150 | "VNF_CHANGE_FLAVOUR", |
| 1151 | "VNF_TERMINATE", |
| 1152 | "VNF_HEAL", |
| 1153 | "VNF_OPERATE", |
| 1154 | "VNF_CHANGE_EXT_CONN", |
| 1155 | "VNF_MODIFY_INFO", |
| 1156 | "NS_INSTANTIATE", |
| 1157 | "NS_SCALE", |
| 1158 | "NS_UPDATE", |
| 1159 | "NS_TERMINATE", |
| 1160 | "NS_HEAL", |
| 1161 | ] |
| 1162 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1163 | }, |
| 1164 | "lcmOpOccStatusImpactingNsComponent": { |
| 1165 | "type": "array", |
| 1166 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1167 | "enum": [ |
| 1168 | "START", |
| 1169 | "COMPLETED", |
| 1170 | "PARTIALLY_COMPLETED", |
| 1171 | "FAILED", |
| 1172 | "ROLLED_BACK", |
| 1173 | ] |
| 1174 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1175 | }, |
| 1176 | }, |
| 1177 | "allOf": [ |
| 1178 | { |
| 1179 | "if": { |
| 1180 | "properties": { |
| 1181 | "notificationTypes": { |
| 1182 | "contains": {"const": "NsLcmOperationOccurrenceNotification"} |
| 1183 | } |
| 1184 | }, |
| 1185 | }, |
| 1186 | "then": { |
| 1187 | "anyOf": [ |
| 1188 | {"required": ["operationTypes"]}, |
| 1189 | {"required": ["operationStates"]}, |
| 1190 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1191 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1192 | }, |
| 1193 | { |
| 1194 | "if": { |
| 1195 | "properties": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1196 | "notificationTypes": {"contains": {"const": "NsChangeNotification"}} |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1197 | }, |
| 1198 | }, |
| 1199 | "then": { |
| 1200 | "anyOf": [ |
| 1201 | {"required": ["nsComponentTypes"]}, |
| 1202 | {"required": ["lcmOpNameImpactingNsComponent"]}, |
| 1203 | {"required": ["lcmOpOccStatusImpactingNsComponent"]}, |
| 1204 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1205 | }, |
| 1206 | }, |
| 1207 | ], |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | authentication_schema = { |
| 1211 | "title": "authentication schema for subscription", |
| 1212 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1213 | "type": "object", |
| 1214 | "properties": { |
| 1215 | "authType": {"enum": ["basic"]}, |
| 1216 | "paramsBasic": { |
| 1217 | "type": "object", |
| 1218 | "properties": { |
| 1219 | "userName": shortname_schema, |
| 1220 | "password": passwd_schema, |
| 1221 | }, |
| 1222 | }, |
| 1223 | }, |
| 1224 | } |
| 1225 | |
| 1226 | subscription = { |
| 1227 | "title": "subscription input schema", |
| 1228 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1229 | "type": "object", |
| 1230 | "properties": { |
| 1231 | "filter": nslcmsub_schema, |
| 1232 | "CallbackUri": description_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1233 | "authentication": authentication_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1234 | }, |
| 1235 | "required": ["CallbackUri"], |
| 1236 | } |
| 1237 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1238 | |
| 1239 | class ValidationError(Exception): |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1240 | def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY): |
| 1241 | self.http_code = http_code |
| 1242 | Exception.__init__(self, message) |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1243 | |
| 1244 | |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1245 | def validate_input(indata, schema_to_use): |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1246 | """ |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1247 | Validates input data against json schema |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1248 | :param indata: user input data. Should be a dictionary |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1249 | :param schema_to_use: jsonschema to test |
| 1250 | :return: None if ok, raises ValidationError exception on error |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1251 | """ |
| 1252 | try: |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1253 | if schema_to_use: |
| 1254 | js_v(indata, schema_to_use) |
| 1255 | return None |
| 1256 | except js_e.ValidationError as e: |
| 1257 | if e.path: |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 1258 | error_pos = "at '" + ":".join(map(str, e.path)) + "'" |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1259 | else: |
| 1260 | error_pos = "" |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 1261 | raise ValidationError("Format error {} '{}' ".format(error_pos, e.message)) |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1262 | except js_e.SchemaError: |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1263 | raise ValidationError( |
| 1264 | "Bad json schema {}".format(schema_to_use), |
| 1265 | http_code=HTTPStatus.INTERNAL_SERVER_ERROR, |
| 1266 | ) |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1267 | |
| 1268 | |
| 1269 | def is_valid_uuid(x): |
| 1270 | """ |
| 1271 | Test for a valid UUID |
| 1272 | :param x: string to test |
| 1273 | :return: True if x is a valid uuid, False otherwise |
| 1274 | """ |
| 1275 | try: |
| 1276 | if UUID(x): |
| 1277 | return True |
| tierno | bdebce9 | 2019-07-01 15:36:49 +0000 | [diff] [blame] | 1278 | except (TypeError, ValueError, AttributeError): |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1279 | return False |