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