| 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 | |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 443 | ns_update = { |
| 444 | "title": "ns update input schema", |
| 445 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 446 | "type": "object", |
| 447 | "properties": { |
| 448 | "lcmOperationType": string_schema, |
| 449 | "nsInstanceId": id_schema, |
| garciadeblas | eab1507 | 2022-05-19 10:31:52 +0200 | [diff] [blame] | 450 | "timeout_ns_update": integer1_schema, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 451 | "updateType": { |
| k4.rahul | e3dca38 | 2022-04-29 12:30:36 +0000 | [diff] [blame] | 452 | "enum": ["CHANGE_VNFPKG", "REMOVE_VNF", "MODIFY_VNF_INFORMATION", "OPERATE_VNF"] |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 453 | }, |
| 454 | "modifyVnfInfoData": { |
| 455 | "type": "object", |
| 456 | "properties": { |
| 457 | "vnfInstanceId": id_schema, |
| 458 | "vnfdId": id_schema, |
| 459 | }, |
| 460 | "required": ["vnfInstanceId", "vnfdId"], |
| 461 | }, |
| 462 | "removeVnfInstanceId": id_schema, |
| 463 | "changeVnfPackageData": { |
| 464 | "type": "object", |
| 465 | "properties": { |
| 466 | "vnfInstanceId": id_schema, |
| 467 | "vnfdId": id_schema, |
| 468 | }, |
| 469 | "required": ["vnfInstanceId", "vnfdId"], |
| 470 | }, |
| k4.rahul | e3dca38 | 2022-04-29 12:30:36 +0000 | [diff] [blame] | 471 | "operateVnfData": { |
| 472 | "type": "object", |
| 473 | "properties": { |
| 474 | "vnfInstanceId": id_schema, |
| 475 | "changeStateTo": name_schema, |
| 476 | "additionalParam": { |
| 477 | "type": "object", |
| 478 | "properties": { |
| 479 | "run-day1": bool_schema, |
| 480 | "vdu_id": name_schema, |
| 481 | "count-index": integer0_schema, |
| 482 | }, |
| 483 | "required": ["vdu_id", "count-index"], |
| 484 | "additionalProperties": False, |
| 485 | } |
| 486 | }, |
| 487 | "required": ["vnfInstanceId", "changeStateTo"], |
| 488 | } |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 489 | }, |
| 490 | "required": ["updateType"], |
| 491 | "additionalProperties": False, |
| 492 | } |
| 493 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 494 | 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] | 495 | "title": "ns action input schema", |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 496 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 497 | "type": "object", |
| 498 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 499 | "lcmOperationType": string_schema, |
| 500 | "nsInstanceId": id_schema, |
| tierno | f5298be | 2018-05-16 14:43:57 +0200 | [diff] [blame] | 501 | "member_vnf_index": name_schema, |
| 502 | "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future |
| tierno | 7ce1db9 | 2018-07-25 12:50:52 +0200 | [diff] [blame] | 503 | "vdu_id": name_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 504 | "vdu_count_index": integer0_schema, |
| tierno | 9cb7d67 | 2019-10-30 12:13:48 +0000 | [diff] [blame] | 505 | "kdu_name": name_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 506 | "primitive": name_schema, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 507 | "timeout_ns_action": integer1_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 508 | "primitive_params": {"type": "object"}, |
| 509 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 510 | "required": ["primitive", "primitive_params"], # TODO add member_vnf_index |
| 511 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 512 | } |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 513 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 514 | ns_scale = { # TODO for the moment it is only VDU-scaling |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 515 | "title": "ns scale input schema", |
| 516 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 517 | "type": "object", |
| 518 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 519 | "lcmOperationType": string_schema, |
| 520 | "nsInstanceId": id_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 521 | "scaleType": {"enum": ["SCALE_VNF"]}, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 522 | "timeout_ns_scale": integer1_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 523 | "scaleVnfData": { |
| 524 | "type": "object", |
| 525 | "properties": { |
| 526 | "vnfInstanceId": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 527 | "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]}, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 528 | "scaleByStepData": { |
| 529 | "type": "object", |
| 530 | "properties": { |
| 531 | "scaling-group-descriptor": name_schema, |
| 532 | "member-vnf-index": name_schema, |
| 533 | "scaling-policy": name_schema, |
| 534 | }, |
| 535 | "required": ["scaling-group-descriptor", "member-vnf-index"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 536 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 537 | }, |
| 538 | }, |
| 539 | "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 540 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 541 | }, |
| 542 | "scaleTime": time_schema, |
| 543 | }, |
| 544 | "required": ["scaleType", "scaleVnfData"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 545 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 546 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 547 | |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 548 | ns_migrate = { |
| 549 | "title": "ns migrate input schema", |
| 550 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 551 | "type": "object", |
| 552 | "properties": { |
| 553 | "lcmOperationType": string_schema, |
| 554 | "nsInstanceId": id_schema, |
| 555 | "vnfInstanceId": id_schema, |
| 556 | "migrateToHost": string_schema, |
| 557 | "vdu": { |
| 558 | "type": "object", |
| 559 | "properties": { |
| 560 | "vduId": name_schema, |
| 561 | "vduCountIndex": integer0_schema, |
| 562 | }, |
| 563 | "required": ["vduId"], |
| 564 | "additionalProperties": False, |
| 565 | }, |
| 566 | }, |
| 567 | "required": ["vnfInstanceId"], |
| 568 | "additionalProperties": False |
| 569 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 570 | |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 571 | ns_heal = { |
| 572 | "title": "ns heal input schema", |
| 573 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 574 | "type": "object", |
| 575 | "properties": { |
| 576 | "lcmOperationType": string_schema, |
| 577 | "nsInstanceId": id_schema, |
| 578 | "timeout_ns_heal": integer1_schema, |
| 579 | "healVnfData": { |
| 580 | "type": "array", |
| 581 | "items": { |
| 582 | "type": "object", |
| 583 | "properties": { |
| 584 | "vnfInstanceId": id_schema, |
| 585 | "cause": description_schema, |
| 586 | "additionalParams": { |
| 587 | "type": "object", |
| 588 | "properties": { |
| 589 | "run-day1": bool_schema, |
| 590 | "vdu": { |
| 591 | "type": "array", |
| 592 | "items": { |
| 593 | "type": "object", |
| 594 | "properties": { |
| 595 | "run-day1": bool_schema, |
| 596 | "vdu-id": name_schema, |
| 597 | "count-index": integer0_schema, |
| 598 | }, |
| 599 | "required": ["vdu-id"], |
| 600 | "additionalProperties": False, |
| 601 | }, |
| 602 | }, |
| 603 | }, |
| 604 | "additionalProperties": False, |
| 605 | }, |
| 606 | }, |
| 607 | "required": ["vnfInstanceId"], |
| 608 | "additionalProperties": False, |
| 609 | }, |
| 610 | }, |
| 611 | }, |
| 612 | "required": ["healVnfData"], |
| 613 | "additionalProperties": False, |
| 614 | } |
| 615 | |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 616 | ns_verticalscale = { |
| 617 | "title": "vertial scale input schema", |
| 618 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 619 | "type": "object", |
| 620 | "properties": { |
| 621 | "lcmOperationType": string_schema, |
| govindarajul | bf7f196 | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 622 | "verticalScale": string_schema, |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 623 | "nsInstanceId": id_schema, |
| govindarajul | bf7f196 | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 624 | "changeVnfFlavorData": { |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 625 | "type": "object", |
| govindarajul | bf7f196 | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 626 | "properties": { |
| 627 | "vnfInstanceId": id_schema, |
| 628 | "additionalParams": { |
| 629 | "type": "object", |
| 630 | "properties": { |
| 631 | "vduid": string_schema, |
| 632 | "vduCountIndex": integer0_schema, |
| 633 | "virtualMemory": integer1_schema, |
| 634 | "sizeOfStorage": integer0_schema, |
| 635 | "numVirtualCpu": integer1_schema, |
| 636 | }, |
| 637 | } |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 638 | }, |
| govindarajul | bf7f196 | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 639 | "required": ["vnfInstanceId", "additionalParams"], |
| 640 | "additionalProperties": False, |
| 641 | } |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 642 | }, |
| govindarajul | bf7f196 | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 643 | "required": ["lcmOperationType", "verticalScale", "nsInstanceId"], |
| 644 | "additionalProperties": False, |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 645 | } |
| 646 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 647 | schema_version = {"type": "string", "enum": ["1.0"]} |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 648 | schema_type = {"type": "string"} |
| tierno | b3d0a0e | 2019-11-13 15:57:51 +0000 | [diff] [blame] | 649 | vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 650 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 651 | vim_account_edit_schema = { |
| 652 | "title": "vim_account edit input schema", |
| 653 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 654 | "type": "object", |
| 655 | "properties": { |
| 656 | "name": name_schema, |
| 657 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 658 | "vim": name_schema, |
| 659 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 660 | "vim_type": vim_type, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 661 | "vim_url": description_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 662 | # "vim_url_admin": description_schema, |
| 663 | # "vim_tenant": name_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 664 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 665 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 666 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 667 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 668 | "config": {"type": "object"}, |
| vegall | 5c59aab | 2022-04-27 15:31:49 +0000 | [diff] [blame] | 669 | "prometheus-config": {"type": "object"}, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 670 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 671 | "additionalProperties": False, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 672 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 673 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 674 | vim_account_new_schema = { |
| 675 | "title": "vim_account creation input schema", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 676 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 677 | "type": "object", |
| 678 | "properties": { |
| 679 | "schema_version": schema_version, |
| 680 | "schema_type": schema_type, |
| 681 | "name": name_schema, |
| 682 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 683 | "vim": name_schema, |
| 684 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 685 | "vim_type": vim_type, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 686 | "vim_url": description_schema, |
| 687 | # "vim_url_admin": description_schema, |
| 688 | # "vim_tenant": name_schema, |
| 689 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 690 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 691 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 692 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 693 | "config": {"type": "object"}, |
| vegall | 5c59aab | 2022-04-27 15:31:49 +0000 | [diff] [blame] | 694 | "prometheus-config": {"type": "object"}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 695 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 696 | "required": [ |
| 697 | "name", |
| 698 | "vim_url", |
| 699 | "vim_type", |
| 700 | "vim_user", |
| 701 | "vim_password", |
| 702 | "vim_tenant_name", |
| 703 | ], |
| 704 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 705 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 706 | |
| tierno | 8580772 | 2019-12-20 14:11:35 +0000 | [diff] [blame] | 707 | wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 708 | |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 709 | wim_account_edit_schema = { |
| 710 | "title": "wim_account edit input schema", |
| 711 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 712 | "type": "object", |
| 713 | "properties": { |
| 714 | "name": name_schema, |
| 715 | "description": description_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 716 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 717 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 718 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 719 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 720 | "password": passwd_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 721 | "config": {"type": "object"}, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 722 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 723 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | wim_account_new_schema = { |
| 727 | "title": "wim_account creation input schema", |
| 728 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 729 | "type": "object", |
| 730 | "properties": { |
| 731 | "schema_version": schema_version, |
| 732 | "schema_type": schema_type, |
| 733 | "name": name_schema, |
| 734 | "description": description_schema, |
| 735 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 736 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 737 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 738 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 739 | "password": passwd_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 740 | "config": { |
| 741 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 742 | "patternProperties": {".": {"not": {"type": "null"}}}, |
| 743 | }, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 744 | }, |
| 745 | "required": ["name", "wim_url", "wim_type"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 746 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 747 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 748 | |
| 749 | sdn_properties = { |
| 750 | "name": name_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 751 | "type": {"type": "string"}, |
| 752 | "url": {"type": "string"}, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 753 | "user": string_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 754 | "password": passwd_schema, |
| 755 | "config": {"type": "object"}, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 756 | "description": description_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 757 | # The folowing are deprecated. Maintanied for backward compatibility |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 758 | "dpid": dpid_Schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 759 | "ip": ip_schema, |
| 760 | "port": port_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 761 | "version": {"type": "string", "minLength": 1, "maxLength": 12}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 762 | } |
| 763 | sdn_new_schema = { |
| 764 | "title": "sdn controller information schema", |
| 765 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 766 | "type": "object", |
| 767 | "properties": sdn_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 768 | "required": ["name", "type"], |
| 769 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 770 | } |
| 771 | sdn_edit_schema = { |
| 772 | "title": "sdn controller update information schema", |
| 773 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 774 | "type": "object", |
| 775 | "properties": sdn_properties, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 776 | # "required": ["name", "port", 'ip', 'dpid', 'type'], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 777 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 778 | } |
| 779 | sdn_port_mapping_schema = { |
| 780 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 781 | "title": "sdn port mapping information schema", |
| 782 | "type": "array", |
| 783 | "items": { |
| 784 | "type": "object", |
| 785 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 786 | "compute_node": shortname_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 787 | "ports": { |
| 788 | "type": "array", |
| 789 | "items": { |
| 790 | "type": "object", |
| 791 | "properties": { |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 792 | "pci": pci_extended_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 793 | "switch_port": shortname_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 794 | "switch_mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 795 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 796 | "required": ["pci"], |
| 797 | }, |
| 798 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 799 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 800 | "required": ["compute_node", "ports"], |
| 801 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 802 | } |
| 803 | sdn_external_port_schema = { |
| 804 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 805 | "title": "External port information", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 806 | "type": "object", |
| 807 | "properties": { |
| 808 | "port": {"type": "string", "minLength": 1, "maxLength": 60}, |
| 809 | "vlan": vlan_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 810 | "mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 811 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 812 | "required": ["port"], |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 813 | } |
| 814 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 815 | # K8s Clusters |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 816 | k8scluster_deploy_method_schema = { |
| 817 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 818 | "title": "Deployment methods for K8s cluster", |
| 819 | "type": "object", |
| 820 | "properties": { |
| 821 | "helm-chart": {"type": "boolean"}, |
| 822 | "juju-bundle": {"type": "boolean"}, |
| 823 | "helm-chart-v3": {"type": "boolean"}, |
| 824 | }, |
| 825 | "additionalProperties": False, |
| 826 | "minProperties": 3, |
| 827 | } |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 828 | k8scluster_nets_schema = { |
| 829 | "title": "k8scluster nets input schema", |
| 830 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 831 | "type": "object", |
| tierno | 8c81ab0 | 2020-02-07 10:18:30 +0000 | [diff] [blame] | 832 | "patternProperties": {".": {"oneOf": [name_schema, null_schema]}}, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 833 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 834 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 835 | } |
| 836 | k8scluster_new_schema = { |
| 837 | "title": "k8scluster creation input schema", |
| 838 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 839 | "type": "object", |
| 840 | "properties": { |
| 841 | "schema_version": schema_version, |
| 842 | "schema_type": schema_type, |
| 843 | "name": name_schema, |
| 844 | "description": description_schema, |
| 845 | "credentials": object_schema, |
| 846 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 847 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 848 | "k8s_version": string_schema, |
| 849 | "nets": k8scluster_nets_schema, |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 850 | "deployment_methods": k8scluster_deploy_method_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 851 | "namespace": name_schema, |
| 852 | "cni": nameshort_list_schema, |
| 853 | }, |
| 854 | "required": ["name", "credentials", "vim_account", "k8s_version", "nets"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 855 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 856 | } |
| 857 | k8scluster_edit_schema = { |
| 858 | "title": "vim_account edit input schema", |
| 859 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 860 | "type": "object", |
| 861 | "properties": { |
| 862 | "name": name_schema, |
| 863 | "description": description_schema, |
| 864 | "credentials": object_schema, |
| 865 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 866 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 867 | "k8s_version": string_schema, |
| 868 | "nets": k8scluster_nets_schema, |
| 869 | "namespace": name_schema, |
| 870 | "cni": nameshort_list_schema, |
| 871 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 872 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 873 | } |
| 874 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 875 | # VCA |
| 876 | vca_new_schema = { |
| 877 | "title": "vca creation input schema", |
| 878 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 879 | "type": "object", |
| 880 | "properties": { |
| 881 | "schema_version": schema_version, |
| 882 | "schema_type": schema_type, |
| 883 | "name": name_schema, |
| 884 | "description": description_schema, |
| 885 | "endpoints": description_list_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 886 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 887 | "secret": passwd_schema, |
| 888 | "cacert": long_description_schema, |
| 889 | "lxd-cloud": shortname_schema, |
| 890 | "lxd-credentials": shortname_schema, |
| 891 | "k8s-cloud": shortname_schema, |
| 892 | "k8s-credentials": shortname_schema, |
| 893 | "model-config": object_schema, |
| 894 | }, |
| 895 | "required": [ |
| 896 | "name", |
| 897 | "endpoints", |
| 898 | "user", |
| 899 | "secret", |
| 900 | "cacert", |
| 901 | "lxd-cloud", |
| 902 | "lxd-credentials", |
| 903 | "k8s-cloud", |
| 904 | "k8s-credentials", |
| 905 | ], |
| 906 | "additionalProperties": False, |
| 907 | } |
| 908 | vca_edit_schema = { |
| 909 | "title": "vca creation input schema", |
| 910 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 911 | "type": "object", |
| 912 | "properties": { |
| 913 | "name": name_schema, |
| 914 | "description": description_schema, |
| 915 | "endpoints": description_list_schema, |
| 916 | "port": integer1_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 917 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 918 | "secret": passwd_schema, |
| 919 | "cacert": long_description_schema, |
| 920 | "lxd-cloud": shortname_schema, |
| 921 | "lxd-credentials": shortname_schema, |
| 922 | "k8s-cloud": shortname_schema, |
| 923 | "k8s-credentials": shortname_schema, |
| 924 | "model-config": object_schema, |
| 925 | }, |
| 926 | "additionalProperties": False, |
| 927 | } |
| 928 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 929 | # K8s Repos |
| tierno | 332e080 | 2019-12-03 23:50:49 +0000 | [diff] [blame] | 930 | k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]} |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 931 | k8srepo_properties = { |
| 932 | "name": name_schema, |
| 933 | "description": description_schema, |
| 934 | "type": k8srepo_types, |
| 935 | "url": description_schema, |
| 936 | } |
| 937 | k8srepo_new_schema = { |
| 938 | "title": "k8scluster creation input schema", |
| 939 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 940 | "type": "object", |
| 941 | "properties": k8srepo_properties, |
| 942 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 943 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 944 | } |
| 945 | k8srepo_edit_schema = { |
| 946 | "title": "vim_account edit input schema", |
| 947 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 948 | "type": "object", |
| 949 | "properties": k8srepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 950 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 951 | } |
| 952 | |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 953 | # OSM Repos |
| 954 | osmrepo_types = {"enum": ["osm"]} |
| 955 | osmrepo_properties = { |
| 956 | "name": name_schema, |
| 957 | "description": description_schema, |
| 958 | "type": osmrepo_types, |
| 959 | "url": description_schema |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 960 | # "user": string_schema, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 961 | # "password": passwd_schema |
| 962 | } |
| 963 | osmrepo_new_schema = { |
| 964 | "title": "osm repo creation input schema", |
| 965 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 966 | "type": "object", |
| 967 | "properties": osmrepo_properties, |
| 968 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 969 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 970 | } |
| 971 | osmrepo_edit_schema = { |
| 972 | "title": "osm repo edit input schema", |
| 973 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 974 | "type": "object", |
| 975 | "properties": osmrepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 976 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 977 | } |
| 978 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 979 | # PDUs |
| 980 | pdu_interface = { |
| 981 | "type": "object", |
| 982 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 983 | "name": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 984 | "mgmt": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 985 | "type": {"enum": ["overlay", "underlay"]}, |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 986 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 987 | # TODO, add user, password, ssh-key |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 988 | "mac-address": mac_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 989 | "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port |
| 990 | "vim-network-id": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 991 | # # provide this in case SDN assist must deal with this interface |
| 992 | # "switch-dpid": dpid_Schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 993 | # "switch-port": shortname_schema, |
| 994 | # "switch-mac": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 995 | # "switch-vlan": vlan_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 996 | }, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 997 | "required": ["name", "mgmt", "ip-address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 998 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 999 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1000 | pdu_new_schema = { |
| 1001 | "title": "pdu creation input schema", |
| 1002 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1003 | "type": "object", |
| 1004 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1005 | "name": shortname_schema, |
| 1006 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1007 | "description": description_schema, |
| 1008 | "shared": bool_schema, |
| 1009 | "vims": nameshort_list_schema, |
| 1010 | "vim_accounts": nameshort_list_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1011 | "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1012 | }, |
| 1013 | "required": ["name", "type", "interfaces"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1014 | "additionalProperties": False, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1015 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1016 | pdu_edit_schema = { |
| 1017 | "title": "pdu edit input schema", |
| 1018 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1019 | "type": "object", |
| 1020 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1021 | "name": shortname_schema, |
| 1022 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1023 | "description": description_schema, |
| 1024 | "shared": bool_schema, |
| garciadeblas | 84bdd55 | 2018-11-30 22:59:45 +0100 | [diff] [blame] | 1025 | "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| 1026 | "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1027 | "interfaces": { |
| 1028 | "oneOf": [ |
| 1029 | array_edition_schema, |
| 1030 | {"type": "array", "items": pdu_interface, "minItems": 1}, |
| 1031 | ] |
| 1032 | }, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1033 | }, |
| 1034 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1035 | "minProperties": 1, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1036 | } |
| 1037 | |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 1038 | # VNF PKG OPERATIONS |
| 1039 | vnfpkgop_new_schema = { |
| 1040 | "title": "VNF PKG operation creation input schema", |
| 1041 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1042 | "type": "object", |
| 1043 | "properties": { |
| 1044 | "lcmOperationType": string_schema, |
| 1045 | "vnfPkgId": id_schema, |
| 1046 | "kdu_name": name_schema, |
| 1047 | "primitive": name_schema, |
| 1048 | "primitive_params": {"type": "object"}, |
| 1049 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1050 | "required": [ |
| 1051 | "lcmOperationType", |
| 1052 | "vnfPkgId", |
| 1053 | "kdu_name", |
| 1054 | "primitive", |
| 1055 | "primitive_params", |
| 1056 | ], |
| 1057 | "additionalProperties": False, |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 1058 | } |
| 1059 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1060 | # USERS |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1061 | project_role_mappings = { |
| 1062 | "title": "list pf projects/roles", |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1063 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1064 | "type": "array", |
| 1065 | "items": { |
| 1066 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1067 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1068 | "required": ["project", "role"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1069 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1070 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1071 | "minItems": 1, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1072 | } |
| 1073 | project_role_mappings_optional = { |
| 1074 | "title": "list of projects/roles or projects only", |
| 1075 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1076 | "type": "array", |
| 1077 | "items": { |
| 1078 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1079 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1080 | "required": ["project"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1081 | "additionalProperties": False, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1082 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1083 | "minItems": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1084 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1085 | user_new_schema = { |
| 1086 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1087 | "title": "New user schema", |
| 1088 | "type": "object", |
| 1089 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1090 | "username": string_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 1091 | "domain_name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1092 | "password": passwd_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1093 | "projects": nameshort_list_schema, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1094 | "project_role_mappings": project_role_mappings, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1095 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1096 | "required": ["username", "password"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1097 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1098 | } |
| 1099 | user_edit_schema = { |
| 1100 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1101 | "title": "User edit schema for administrators", |
| 1102 | "type": "object", |
| 1103 | "properties": { |
| 1104 | "password": passwd_schema, |
| selvi.j | a9a1fc8 | 2022-04-04 06:54:30 +0000 | [diff] [blame] | 1105 | "old_password": passwd_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1106 | "username": string_schema, # To allow User Name modification |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1107 | "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1108 | "project_role_mappings": project_role_mappings, |
| 1109 | "add_project_role_mappings": project_role_mappings, |
| 1110 | "remove_project_role_mappings": project_role_mappings_optional, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1111 | }, |
| 1112 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1113 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | # PROJECTS |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1117 | topics_with_quota = [ |
| 1118 | "vnfds", |
| 1119 | "nsds", |
| 1120 | "slice_templates", |
| 1121 | "pduds", |
| 1122 | "ns_instances", |
| 1123 | "slice_instances", |
| 1124 | "vim_accounts", |
| 1125 | "wim_accounts", |
| 1126 | "sdn_controllers", |
| 1127 | "k8sclusters", |
| 1128 | "vca", |
| 1129 | "k8srepos", |
| 1130 | "osmrepos", |
| 1131 | "ns_subscriptions", |
| 1132 | ] |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1133 | project_new_schema = { |
| 1134 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1135 | "title": "New project schema for administrators", |
| 1136 | "type": "object", |
| 1137 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1138 | "name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1139 | "admin": bool_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 1140 | "domain_name": shortname_schema, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1141 | "quotas": { |
| 1142 | "type": "object", |
| 1143 | "properties": {topic: integer0_schema for topic in topics_with_quota}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1144 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1145 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1146 | }, |
| 1147 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1148 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1149 | } |
| 1150 | project_edit_schema = { |
| 1151 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1152 | "title": "Project edit schema for administrators", |
| 1153 | "type": "object", |
| 1154 | "properties": { |
| 1155 | "admin": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1156 | "name": shortname_schema, # To allow Project Name modification |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1157 | "quotas": { |
| 1158 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1159 | "properties": { |
| 1160 | topic: {"oneOf": [integer0_schema, null_schema]} |
| 1161 | for topic in topics_with_quota |
| 1162 | }, |
| 1163 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1164 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1165 | }, |
| 1166 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1167 | "minProperties": 1, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1168 | } |
| 1169 | |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1170 | # ROLES |
| 1171 | roles_new_schema = { |
| 1172 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1173 | "title": "New role schema for administrators", |
| 1174 | "type": "object", |
| 1175 | "properties": { |
| 1176 | "name": shortname_schema, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1177 | "permissions": { |
| 1178 | "type": "object", |
| 1179 | "patternProperties": { |
| 1180 | ".": bool_schema, |
| 1181 | }, |
| 1182 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1183 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1184 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1185 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1186 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1187 | } |
| 1188 | roles_edit_schema = { |
| 1189 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1190 | "title": "Roles edit schema for administrators", |
| 1191 | "type": "object", |
| 1192 | "properties": { |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1193 | "name": shortname_schema, |
| 1194 | "permissions": { |
| 1195 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1196 | "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}}, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1197 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1198 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1199 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1200 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1201 | "minProperties": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1202 | } |
| 1203 | |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1204 | # GLOBAL SCHEMAS |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1205 | |
| 1206 | nbi_new_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1207 | "users": user_new_schema, |
| 1208 | "projects": project_new_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1209 | "vim_accounts": vim_account_new_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 1210 | "sdns": sdn_new_schema, |
| 1211 | "ns_instantiate": ns_instantiate, |
| 1212 | "ns_action": ns_action, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1213 | "ns_scale": ns_scale, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 1214 | "ns_update": ns_update, |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 1215 | "ns_heal": ns_heal, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1216 | "pdus": pdu_new_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1217 | } |
| 1218 | |
| 1219 | nbi_edit_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1220 | "users": user_edit_schema, |
| 1221 | "projects": project_edit_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1222 | "vim_accounts": vim_account_edit_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1223 | "sdns": sdn_edit_schema, |
| 1224 | "pdus": pdu_edit_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1225 | } |
| 1226 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1227 | # NETSLICE SCHEMAS |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1228 | nsi_subnet_instantiate = deepcopy(ns_instantiate) |
| 1229 | nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema" |
| 1230 | nsi_subnet_instantiate["properties"]["id"] = name_schema |
| 1231 | del nsi_subnet_instantiate["required"] |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1232 | |
| 1233 | nsi_vld_instantiate = { |
| 1234 | "title": "netslice vld instantiation params input schema", |
| 1235 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1236 | "type": "object", |
| 1237 | "properties": { |
| 1238 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 1239 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 1240 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1241 | "ip-profile": object_schema, |
| 1242 | }, |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1243 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1244 | "additionalProperties": False, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1245 | } |
| 1246 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1247 | nsi_instantiate = { |
| 1248 | "title": "netslice action instantiate input schema", |
| 1249 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1250 | "type": "object", |
| 1251 | "properties": { |
| 1252 | "lcmOperationType": string_schema, |
| Felipe Vicens | 126af57 | 2019-06-05 19:13:04 +0200 | [diff] [blame] | 1253 | "netsliceInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1254 | "nsiName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 1255 | "nsiDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 9e5eea3 | 2018-11-29 09:42:09 +0000 | [diff] [blame] | 1256 | "nstId": string_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1257 | "vimAccountId": id_schema, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 1258 | "timeout_nsi_deploy": integer1_schema, |
| Felipe Vicens | 26202bb | 2020-05-24 18:57:33 +0200 | [diff] [blame] | 1259 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1260 | "nsi_id": id_schema, |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1261 | "additionalParamsForNsi": object_schema, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1262 | "netslice-subnet": { |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1263 | "type": "array", |
| 1264 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1265 | "items": nsi_subnet_instantiate, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1266 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1267 | "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1268 | }, |
| Felipe Vicens | c8bbaaa | 2018-12-01 04:42:40 +0100 | [diff] [blame] | 1269 | "required": ["nsiName", "nstId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1270 | "additionalProperties": False, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1271 | } |
| 1272 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1273 | nsi_action = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1274 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1275 | nsi_terminate = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1276 | |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1277 | nsinstancesubscriptionfilter_schema = { |
| 1278 | "title": "instance identifier schema", |
| 1279 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1280 | "type": "object", |
| 1281 | "properties": { |
| 1282 | "nsdIds": {"type": "array"}, |
| 1283 | "vnfdIds": {"type": "array"}, |
| 1284 | "pnfdIds": {"type": "array"}, |
| 1285 | "nsInstanceIds": {"type": "array"}, |
| 1286 | "nsInstanceNames": {"type": "array"}, |
| 1287 | }, |
| 1288 | } |
| 1289 | |
| 1290 | nslcmsub_schema = { |
| 1291 | "title": "nslcmsubscription input schema", |
| 1292 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1293 | "type": "object", |
| 1294 | "properties": { |
| 1295 | "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema, |
| 1296 | "notificationTypes": { |
| 1297 | "type": "array", |
| 1298 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1299 | "enum": [ |
| 1300 | "NsLcmOperationOccurrenceNotification", |
| 1301 | "NsChangeNotification", |
| 1302 | "NsIdentifierCreationNotification", |
| 1303 | "NsIdentifierDeletionNotification", |
| 1304 | ] |
| 1305 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1306 | }, |
| 1307 | "operationTypes": { |
| 1308 | "type": "array", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1309 | "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1310 | }, |
| 1311 | "operationStates": { |
| 1312 | "type": "array", |
| 1313 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1314 | "enum": [ |
| 1315 | "PROCESSING", |
| 1316 | "COMPLETED", |
| 1317 | "PARTIALLY_COMPLETED", |
| 1318 | "FAILED", |
| 1319 | "FAILED_TEMP", |
| 1320 | "ROLLING_BACK", |
| 1321 | "ROLLED_BACK", |
| 1322 | ] |
| 1323 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1324 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1325 | "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1326 | "lcmOpNameImpactingNsComponent": { |
| 1327 | "type": "array", |
| 1328 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1329 | "enum": [ |
| 1330 | "VNF_INSTANTIATE", |
| 1331 | "VNF_SCALE", |
| 1332 | "VNF_SCALE_TO_LEVEL", |
| 1333 | "VNF_CHANGE_FLAVOUR", |
| 1334 | "VNF_TERMINATE", |
| 1335 | "VNF_HEAL", |
| 1336 | "VNF_OPERATE", |
| 1337 | "VNF_CHANGE_EXT_CONN", |
| 1338 | "VNF_MODIFY_INFO", |
| 1339 | "NS_INSTANTIATE", |
| 1340 | "NS_SCALE", |
| 1341 | "NS_UPDATE", |
| 1342 | "NS_TERMINATE", |
| 1343 | "NS_HEAL", |
| 1344 | ] |
| 1345 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1346 | }, |
| 1347 | "lcmOpOccStatusImpactingNsComponent": { |
| 1348 | "type": "array", |
| 1349 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1350 | "enum": [ |
| 1351 | "START", |
| 1352 | "COMPLETED", |
| 1353 | "PARTIALLY_COMPLETED", |
| 1354 | "FAILED", |
| 1355 | "ROLLED_BACK", |
| 1356 | ] |
| 1357 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1358 | }, |
| 1359 | }, |
| 1360 | "allOf": [ |
| 1361 | { |
| 1362 | "if": { |
| 1363 | "properties": { |
| 1364 | "notificationTypes": { |
| 1365 | "contains": {"const": "NsLcmOperationOccurrenceNotification"} |
| 1366 | } |
| 1367 | }, |
| 1368 | }, |
| 1369 | "then": { |
| 1370 | "anyOf": [ |
| 1371 | {"required": ["operationTypes"]}, |
| 1372 | {"required": ["operationStates"]}, |
| 1373 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1374 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1375 | }, |
| 1376 | { |
| 1377 | "if": { |
| 1378 | "properties": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1379 | "notificationTypes": {"contains": {"const": "NsChangeNotification"}} |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1380 | }, |
| 1381 | }, |
| 1382 | "then": { |
| 1383 | "anyOf": [ |
| 1384 | {"required": ["nsComponentTypes"]}, |
| 1385 | {"required": ["lcmOpNameImpactingNsComponent"]}, |
| 1386 | {"required": ["lcmOpOccStatusImpactingNsComponent"]}, |
| 1387 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1388 | }, |
| 1389 | }, |
| 1390 | ], |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | authentication_schema = { |
| 1394 | "title": "authentication schema for subscription", |
| 1395 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1396 | "type": "object", |
| 1397 | "properties": { |
| 1398 | "authType": {"enum": ["basic"]}, |
| 1399 | "paramsBasic": { |
| 1400 | "type": "object", |
| 1401 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1402 | "userName": string_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1403 | "password": passwd_schema, |
| 1404 | }, |
| 1405 | }, |
| 1406 | }, |
| 1407 | } |
| 1408 | |
| 1409 | subscription = { |
| 1410 | "title": "subscription input schema", |
| 1411 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1412 | "type": "object", |
| 1413 | "properties": { |
| 1414 | "filter": nslcmsub_schema, |
| 1415 | "CallbackUri": description_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1416 | "authentication": authentication_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1417 | }, |
| 1418 | "required": ["CallbackUri"], |
| 1419 | } |
| 1420 | |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1421 | vnflcmsub_schema = { |
| 1422 | "title": "vnflcmsubscription input schema", |
| 1423 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1424 | "type": "object", |
| 1425 | "properties": { |
| 1426 | "VnfInstanceSubscriptionFilter": { |
| 1427 | "type": "object", |
| 1428 | "properties": { |
| 1429 | "vnfdIds": {"type": "array"}, |
| 1430 | "vnfInstanceIds": {"type": "array"}, |
| 1431 | }, |
| 1432 | }, |
| 1433 | "notificationTypes": { |
| 1434 | "type": "array", |
| 1435 | "items": { |
| 1436 | "enum": [ |
| 1437 | "VnfIdentifierCreationNotification", |
| 1438 | "VnfLcmOperationOccurrenceNotification", |
| 1439 | "VnfIdentifierDeletionNotification" |
| 1440 | ] |
| 1441 | } |
| 1442 | }, |
| 1443 | "operationTypes": { |
| 1444 | "type": "array", |
| 1445 | "items": { |
| 1446 | "enum": [ |
| 1447 | "INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", |
| 1448 | "HEAL", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO", "CREATE_SNAPSHOT", |
| 1449 | "REVERT_TO_SNAPSHOT", "CHANGE_VNFPKG" |
| 1450 | ] |
| 1451 | } |
| 1452 | }, |
| 1453 | "operationStates": { |
| 1454 | "type": "array", |
| 1455 | "items": { |
| 1456 | "enum": [ |
| 1457 | "STARTING", "PROCESSING", "COMPLETED", "FAILED_TEMP", "FAILED", |
| 1458 | "ROLLING_BACK", "ROLLED_BACK" |
| 1459 | ] |
| 1460 | } |
| 1461 | } |
| 1462 | }, |
| 1463 | "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"] |
| 1464 | } |
| 1465 | |
| 1466 | vnf_subscription = { |
| 1467 | "title": "vnf subscription input schema", |
| 1468 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1469 | "type": "object", |
| 1470 | "properties": { |
| 1471 | "filter": vnflcmsub_schema, |
| 1472 | "CallbackUri": description_schema, |
| 1473 | "authentication": authentication_schema |
| 1474 | }, |
| 1475 | "required": ["filter", "CallbackUri"] |
| 1476 | } |
| 1477 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1478 | |
| 1479 | class ValidationError(Exception): |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1480 | def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY): |
| 1481 | self.http_code = http_code |
| 1482 | Exception.__init__(self, message) |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1483 | |
| 1484 | |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1485 | def validate_input(indata, schema_to_use): |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1486 | """ |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1487 | Validates input data against json schema |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1488 | :param indata: user input data. Should be a dictionary |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1489 | :param schema_to_use: jsonschema to test |
| 1490 | :return: None if ok, raises ValidationError exception on error |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1491 | """ |
| 1492 | try: |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1493 | if schema_to_use: |
| 1494 | js_v(indata, schema_to_use) |
| 1495 | return None |
| 1496 | except js_e.ValidationError as e: |
| 1497 | if e.path: |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 1498 | error_pos = "at '" + ":".join(map(str, e.path)) + "'" |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1499 | else: |
| 1500 | error_pos = "" |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 1501 | raise ValidationError("Format error {} '{}' ".format(error_pos, e.message)) |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1502 | except js_e.SchemaError: |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1503 | raise ValidationError( |
| 1504 | "Bad json schema {}".format(schema_to_use), |
| 1505 | http_code=HTTPStatus.INTERNAL_SERVER_ERROR, |
| 1506 | ) |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1507 | |
| 1508 | |
| 1509 | def is_valid_uuid(x): |
| 1510 | """ |
| 1511 | Test for a valid UUID |
| 1512 | :param x: string to test |
| 1513 | :return: True if x is a valid uuid, False otherwise |
| 1514 | """ |
| 1515 | try: |
| 1516 | if UUID(x): |
| 1517 | return True |
| tierno | bdebce9 | 2019-07-01 15:36:49 +0000 | [diff] [blame] | 1518 | except (TypeError, ValueError, AttributeError): |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1519 | return False |