| 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 | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 38 | user_passwd_schema = { |
| 39 | "type": "string", |
| 40 | "pattern": "^.*(?=.{8,})((?=.*[!@#$%^&*()\\-_=+{};:,<.>]){1})(?=.*\\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$", |
| 41 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 42 | name_schema = { |
| 43 | "type": "string", |
| 44 | "minLength": 1, |
| 45 | "maxLength": 255, |
| 46 | "pattern": "^[^,;()'\"]+$", |
| 47 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 48 | string_schema = {"type": "string", "minLength": 1, "maxLength": 255} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 49 | xml_text_schema = { |
| 50 | "type": "string", |
| 51 | "minLength": 1, |
| 52 | "maxLength": 1000, |
| 53 | "pattern": "^[^']+$", |
| 54 | } |
| 55 | description_schema = { |
| 56 | "type": ["string", "null"], |
| 57 | "maxLength": 255, |
| 58 | "pattern": "^[^'\"]+$", |
| 59 | } |
| 60 | long_description_schema = { |
| 61 | "type": ["string", "null"], |
| 62 | "maxLength": 3000, |
| 63 | "pattern": "^[^'\"]+$", |
| 64 | } |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 65 | id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36} |
| 66 | bool_schema = {"type": "boolean"} |
| 67 | null_schema = {"type": "null"} |
| tierno | 2236d20 | 2018-05-16 19:05:16 +0200 | [diff] [blame] | 68 | # "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] | 69 | id_schema = { |
| 70 | "type": "string", |
| 71 | "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$", |
| 72 | } |
| 73 | time_schema = { |
| 74 | "type": "string", |
| 75 | "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}", |
| 76 | } |
| 77 | pci_schema = { |
| 78 | "type": "string", |
| 79 | "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$", |
| 80 | } |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 81 | # allows [] for wildcards. For that reason huge length limit is set |
| 82 | 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] | 83 | http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 84 | bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"} |
| 85 | memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"} |
| 86 | integer0_schema = {"type": "integer", "minimum": 0} |
| 87 | integer1_schema = {"type": "integer", "minimum": 1} |
| tierno | 8700604 | 2018-10-24 12:50:20 +0200 | [diff] [blame] | 88 | path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 89 | vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095} |
| 90 | vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 91 | mac_schema = { |
| 92 | "type": "string", |
| 93 | "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$", |
| 94 | } # must be unicast: LSB bit of MSB byte ==0 |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 95 | 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] | 96 | # 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] | 97 | ip_schema = { |
| 98 | "type": "string", |
| 99 | "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", |
| 100 | } |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 101 | ipv6_schema = { |
| 102 | "type": "string", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 103 | "pattern": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))", # noqa: W605 |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 104 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 105 | ip_prefix_schema = { |
| 106 | "type": "string", |
| 107 | "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" |
| 108 | "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$", |
| 109 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 110 | port_schema = {"type": "integer", "minimum": 1, "maximum": 65534} |
| 111 | object_schema = {"type": "object"} |
| 112 | schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2} |
| 113 | # 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] | 114 | log_level_schema = { |
| 115 | "type": "string", |
| 116 | "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], |
| 117 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 118 | checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"} |
| 119 | size_schema = {"type": "integer", "minimum": 1, "maximum": 100} |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 120 | array_edition_schema = { |
| 121 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 122 | "patternProperties": {"^\\$": {}}, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 123 | "additionalProperties": False, |
| 124 | "minProperties": 1, |
| 125 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 126 | nameshort_list_schema = { |
| 127 | "type": "array", |
| 128 | "minItems": 1, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 129 | "items": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 130 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 131 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 132 | description_list_schema = { |
| 133 | "type": "array", |
| 134 | "minItems": 1, |
| 135 | "items": description_schema, |
| 136 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 137 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 138 | ns_instantiate_vdu = { |
| 139 | "title": "ns action instantiate input schema for vdu", |
| 140 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 141 | "type": "object", |
| 142 | "properties": { |
| 143 | "id": name_schema, |
| Gabriel Cuba | e88401b | 2023-04-05 15:24:52 -0500 | [diff] [blame] | 144 | "vim-flavor-id": name_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 145 | "volume": { |
| 146 | "type": "array", |
| 147 | "minItems": 1, |
| 148 | "items": { |
| 149 | "type": "object", |
| 150 | "properties": { |
| 151 | "name": name_schema, |
| 152 | "vim-volume-id": name_schema, |
| 153 | }, |
| 154 | "required": ["name", "vim-volume-id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 155 | "additionalProperties": False, |
| 156 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 157 | }, |
| 158 | "interface": { |
| 159 | "type": "array", |
| 160 | "minItems": 1, |
| 161 | "items": { |
| 162 | "type": "object", |
| 163 | "properties": { |
| 164 | "name": name_schema, |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 165 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 166 | "mac-address": mac_schema, |
| 167 | "floating-ip-required": bool_schema, |
| 168 | }, |
| 169 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 170 | "additionalProperties": False, |
| 171 | }, |
| 172 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 173 | }, |
| 174 | "required": ["id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 175 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | ip_profile_dns_schema = { |
| 179 | "type": "array", |
| 180 | "minItems": 1, |
| 181 | "items": { |
| 182 | "type": "object", |
| 183 | "properties": { |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 184 | "address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 185 | }, |
| 186 | "required": ["address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 187 | "additionalProperties": False, |
| 188 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | ip_profile_dhcp_schema = { |
| 192 | "type": "object", |
| 193 | "properties": { |
| 194 | "enabled": {"type": "boolean"}, |
| 195 | "count": integer1_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 196 | "start-address": ip_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 197 | }, |
| 198 | "additionalProperties": False, |
| 199 | } |
| 200 | |
| 201 | ip_profile_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 202 | "title": "ip profile validation schema", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 203 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 204 | "type": "object", |
| 205 | "properties": { |
| 206 | "ip-version": {"enum": ["ipv4", "ipv6"]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 207 | "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]}, |
| 208 | "gateway-address": {"oneOf": [null_schema, ip_schema]}, |
| 209 | "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 210 | "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]}, |
| 211 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 212 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 213 | } |
| 214 | |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 215 | provider_network_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 216 | "title": "provider network validation schema", |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 217 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 218 | "type": "object", |
| 219 | "properties": { |
| 220 | "physical-network": name_schema, |
| 221 | "segmentation-id": name_schema, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 222 | "sdn-ports": { # external ports to append to the SDN-assist network |
| 223 | "type": "array", |
| 224 | "items": { |
| 225 | "type": "object", |
| 226 | "properties": { |
| 227 | "switch_id": shortname_schema, |
| 228 | "switch_port": shortname_schema, |
| 229 | "mac_address": mac_schema, |
| 230 | "vlan": vlan_schema, |
| 231 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 232 | "additionalProperties": True, |
| 233 | }, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 234 | }, |
| 235 | "network-type": shortname_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 236 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 237 | "additionalProperties": True, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 240 | ns_instantiate_internal_vld = { |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 241 | "title": "ns action instantiate input schema for vld", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 242 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 243 | "type": "object", |
| 244 | "properties": { |
| 245 | "name": name_schema, |
| 246 | "vim-network-name": name_schema, |
| gcalvino | 17d5b73 | 2018-12-17 16:26:21 +0100 | [diff] [blame] | 247 | "vim-network-id": name_schema, |
| garciadeblas | 120105b | 2023-02-22 16:52:24 +0100 | [diff] [blame] | 248 | "ip-profile": ip_profile_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 249 | "provider-network": provider_network_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 250 | "internal-connection-point": { |
| 251 | "type": "array", |
| 252 | "minItems": 1, |
| 253 | "items": { |
| 254 | "type": "object", |
| 255 | "properties": { |
| 256 | "id-ref": name_schema, |
| 257 | "ip-address": ip_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 258 | # "mac-address": mac_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 259 | }, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 260 | "required": ["id-ref"], |
| 261 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 262 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 263 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 264 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 265 | }, |
| 266 | "required": ["name"], |
| 267 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 268 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 269 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 270 | |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 271 | additional_params_for_vnf = { |
| 272 | "type": "array", |
| 273 | "items": { |
| 274 | "type": "object", |
| 275 | "properties": { |
| 276 | "member-vnf-index": name_schema, |
| 277 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 278 | "k8s-namespace": name_schema, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 279 | "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] | 280 | "additionalParamsForVdu": { |
| 281 | "type": "array", |
| 282 | "items": { |
| 283 | "type": "object", |
| 284 | "properties": { |
| 285 | "vdu_id": name_schema, |
| 286 | "additionalParams": object_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 287 | "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] | 288 | }, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 289 | "required": ["vdu_id"], |
| 290 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 291 | "additionalProperties": False, |
| 292 | }, |
| 293 | }, |
| 294 | "additionalParamsForKdu": { |
| 295 | "type": "array", |
| 296 | "items": { |
| 297 | "type": "object", |
| 298 | "properties": { |
| 299 | "kdu_name": name_schema, |
| 300 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 301 | "kdu_model": name_schema, |
| 302 | "k8s-namespace": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 303 | "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] | 304 | "kdu-deployment-name": name_schema, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 305 | }, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 306 | "required": ["kdu_name"], |
| 307 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 308 | "additionalProperties": False, |
| 309 | }, |
| 310 | }, |
| Alexis Romero | ee31f53 | 2022-04-26 19:10:21 +0200 | [diff] [blame] | 311 | "affinity-or-anti-affinity-group": { |
| 312 | "type": "array", |
| 313 | "items": { |
| 314 | "type": "object", |
| 315 | "properties": { |
| 316 | "id": name_schema, |
| 317 | "vim-affinity-group-id": name_schema, |
| 318 | }, |
| 319 | "required": ["id"], |
| 320 | "minProperties": 2, |
| 321 | "additionalProperties": False, |
| 322 | }, |
| 323 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 324 | }, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 325 | "required": ["member-vnf-index"], |
| 326 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 327 | "additionalProperties": False, |
| 328 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 331 | ns_instantiate = { |
| 332 | "title": "ns action instantiate input schema", |
| 333 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 334 | "type": "object", |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 335 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 336 | "lcmOperationType": string_schema, |
| 337 | "nsInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 338 | "netsliceInstanceId": id_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 339 | "nsName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 340 | "nsDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 341 | "nsdId": id_schema, |
| 342 | "vimAccountId": id_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 343 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| magnussonl | f318b30 | 2020-01-20 18:38:18 +0100 | [diff] [blame] | 344 | "placement-engine": string_schema, |
| 345 | "placement-constraints": object_schema, |
| tierno | bee085c | 2018-12-12 17:03:04 +0000 | [diff] [blame] | 346 | "additionalParamsForNs": object_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 347 | "additionalParamsForVnf": additional_params_for_vnf, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 348 | "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] | 349 | "k8s-namespace": name_schema, |
| tierno | fc5089c | 2018-10-31 09:28:11 +0100 | [diff] [blame] | 350 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 351 | "timeout_ns_deploy": integer1_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 352 | "nsr_id": id_schema, |
| tierno | cc10343 | 2018-10-19 14:10:35 +0200 | [diff] [blame] | 353 | "vduImage": name_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 354 | "vnf": { |
| 355 | "type": "array", |
| 356 | "minItems": 1, |
| 357 | "items": { |
| 358 | "type": "object", |
| 359 | "properties": { |
| 360 | "member-vnf-index": name_schema, |
| 361 | "vimAccountId": id_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 362 | "vdu": { |
| 363 | "type": "array", |
| 364 | "minItems": 1, |
| 365 | "items": ns_instantiate_vdu, |
| 366 | }, |
| 367 | "internal-vld": { |
| 368 | "type": "array", |
| 369 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 370 | "items": ns_instantiate_internal_vld, |
| 371 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 372 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 373 | "required": ["member-vnf-index"], |
| 374 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 375 | "additionalProperties": False, |
| 376 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 377 | }, |
| 378 | "vld": { |
| 379 | "type": "array", |
| 380 | "minItems": 1, |
| 381 | "items": { |
| 382 | "type": "object", |
| 383 | "properties": { |
| 384 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 385 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 386 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| Felipe Vicens | 09e6542 | 2019-01-22 15:06:46 +0100 | [diff] [blame] | 387 | "ns-net": object_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 388 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| garciadeblas | 120105b | 2023-02-22 16:52:24 +0100 | [diff] [blame] | 389 | "ip-profile": ip_profile_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 390 | "provider-network": provider_network_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 391 | "vnfd-connection-point-ref": { |
| 392 | "type": "array", |
| 393 | "minItems": 1, |
| 394 | "items": { |
| 395 | "type": "object", |
| 396 | "properties": { |
| 397 | "member-vnf-index-ref": name_schema, |
| 398 | "vnfd-connection-point-ref": name_schema, |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 399 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 400 | # "mac-address": mac_schema, |
| 401 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 402 | "required": [ |
| 403 | "member-vnf-index-ref", |
| 404 | "vnfd-connection-point-ref", |
| 405 | ], |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 406 | "minProperties": 3, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 407 | "additionalProperties": False, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 408 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 409 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 410 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 411 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 412 | "additionalProperties": False, |
| 413 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 414 | }, |
| 415 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 416 | "required": ["nsName", "nsdId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 417 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 418 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 419 | |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 420 | ns_terminate = { |
| 421 | "title": "ns terminate input schema", |
| 422 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 423 | "type": "object", |
| 424 | "properties": { |
| 425 | "lcmOperationType": string_schema, |
| 426 | "nsInstanceId": id_schema, |
| 427 | "autoremove": bool_schema, |
| 428 | "timeout_ns_terminate": integer1_schema, |
| 429 | "skip_terminate_primitives": bool_schema, |
| tierno | 0b8752f | 2020-05-12 09:42:02 +0000 | [diff] [blame] | 430 | "netsliceInstanceId": id_schema, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 431 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 432 | "additionalProperties": False, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 433 | } |
| 434 | |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 435 | ns_update = { |
| 436 | "title": "ns update input schema", |
| 437 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 438 | "type": "object", |
| 439 | "properties": { |
| 440 | "lcmOperationType": string_schema, |
| 441 | "nsInstanceId": id_schema, |
| garciadeblas | eab1507 | 2022-05-19 10:31:52 +0200 | [diff] [blame] | 442 | "timeout_ns_update": integer1_schema, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 443 | "updateType": { |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 444 | "enum": [ |
| 445 | "CHANGE_VNFPKG", |
| 446 | "REMOVE_VNF", |
| 447 | "MODIFY_VNF_INFORMATION", |
| 448 | "OPERATE_VNF", |
| 449 | ] |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 450 | }, |
| 451 | "modifyVnfInfoData": { |
| 452 | "type": "object", |
| 453 | "properties": { |
| 454 | "vnfInstanceId": id_schema, |
| 455 | "vnfdId": id_schema, |
| 456 | }, |
| 457 | "required": ["vnfInstanceId", "vnfdId"], |
| 458 | }, |
| 459 | "removeVnfInstanceId": id_schema, |
| 460 | "changeVnfPackageData": { |
| 461 | "type": "object", |
| 462 | "properties": { |
| 463 | "vnfInstanceId": id_schema, |
| 464 | "vnfdId": id_schema, |
| 465 | }, |
| 466 | "required": ["vnfInstanceId", "vnfdId"], |
| 467 | }, |
| k4.rahul | e3dca38 | 2022-04-29 12:30:36 +0000 | [diff] [blame] | 468 | "operateVnfData": { |
| 469 | "type": "object", |
| 470 | "properties": { |
| 471 | "vnfInstanceId": id_schema, |
| 472 | "changeStateTo": name_schema, |
| 473 | "additionalParam": { |
| 474 | "type": "object", |
| 475 | "properties": { |
| 476 | "run-day1": bool_schema, |
| 477 | "vdu_id": name_schema, |
| 478 | "count-index": integer0_schema, |
| 479 | }, |
| 480 | "required": ["vdu_id", "count-index"], |
| 481 | "additionalProperties": False, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 482 | }, |
| k4.rahul | e3dca38 | 2022-04-29 12:30:36 +0000 | [diff] [blame] | 483 | }, |
| 484 | "required": ["vnfInstanceId", "changeStateTo"], |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 485 | }, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 486 | }, |
| 487 | "required": ["updateType"], |
| 488 | "additionalProperties": False, |
| 489 | } |
| 490 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 491 | 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] | 492 | "title": "ns action input schema", |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 493 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 494 | "type": "object", |
| 495 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 496 | "lcmOperationType": string_schema, |
| 497 | "nsInstanceId": id_schema, |
| tierno | f5298be | 2018-05-16 14:43:57 +0200 | [diff] [blame] | 498 | "member_vnf_index": name_schema, |
| 499 | "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future |
| tierno | 7ce1db9 | 2018-07-25 12:50:52 +0200 | [diff] [blame] | 500 | "vdu_id": name_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 501 | "vdu_count_index": integer0_schema, |
| tierno | 9cb7d67 | 2019-10-30 12:13:48 +0000 | [diff] [blame] | 502 | "kdu_name": name_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 503 | "primitive": name_schema, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 504 | "timeout_ns_action": integer1_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 505 | "primitive_params": {"type": "object"}, |
| 506 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 507 | "required": ["primitive", "primitive_params"], # TODO add member_vnf_index |
| 508 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 509 | } |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 510 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 511 | ns_scale = { # TODO for the moment it is only VDU-scaling |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 512 | "title": "ns scale input schema", |
| 513 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 514 | "type": "object", |
| 515 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 516 | "lcmOperationType": string_schema, |
| 517 | "nsInstanceId": id_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 518 | "scaleType": {"enum": ["SCALE_VNF"]}, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 519 | "timeout_ns_scale": integer1_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 520 | "scaleVnfData": { |
| 521 | "type": "object", |
| 522 | "properties": { |
| 523 | "vnfInstanceId": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 524 | "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]}, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 525 | "scaleByStepData": { |
| 526 | "type": "object", |
| 527 | "properties": { |
| 528 | "scaling-group-descriptor": name_schema, |
| 529 | "member-vnf-index": name_schema, |
| 530 | "scaling-policy": name_schema, |
| 531 | }, |
| 532 | "required": ["scaling-group-descriptor", "member-vnf-index"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 533 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 534 | }, |
| 535 | }, |
| 536 | "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 537 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 538 | }, |
| 539 | "scaleTime": time_schema, |
| 540 | }, |
| 541 | "required": ["scaleType", "scaleVnfData"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 542 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 543 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 544 | |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 545 | ns_migrate = { |
| 546 | "title": "ns migrate input schema", |
| 547 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 548 | "type": "object", |
| 549 | "properties": { |
| 550 | "lcmOperationType": string_schema, |
| 551 | "nsInstanceId": id_schema, |
| 552 | "vnfInstanceId": id_schema, |
| 553 | "migrateToHost": string_schema, |
| 554 | "vdu": { |
| 555 | "type": "object", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 556 | "properties": { |
| 557 | "vduId": name_schema, |
| 558 | "vduCountIndex": integer0_schema, |
| 559 | }, |
| 560 | "required": ["vduId"], |
| 561 | "additionalProperties": False, |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 562 | }, |
| 563 | }, |
| 564 | "required": ["vnfInstanceId"], |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 565 | "additionalProperties": False, |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 566 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 567 | |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 568 | ns_heal = { |
| 569 | "title": "ns heal input schema", |
| 570 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 571 | "type": "object", |
| 572 | "properties": { |
| 573 | "lcmOperationType": string_schema, |
| 574 | "nsInstanceId": id_schema, |
| 575 | "timeout_ns_heal": integer1_schema, |
| 576 | "healVnfData": { |
| 577 | "type": "array", |
| 578 | "items": { |
| 579 | "type": "object", |
| 580 | "properties": { |
| 581 | "vnfInstanceId": id_schema, |
| 582 | "cause": description_schema, |
| 583 | "additionalParams": { |
| 584 | "type": "object", |
| 585 | "properties": { |
| 586 | "run-day1": bool_schema, |
| 587 | "vdu": { |
| 588 | "type": "array", |
| 589 | "items": { |
| 590 | "type": "object", |
| 591 | "properties": { |
| 592 | "run-day1": bool_schema, |
| 593 | "vdu-id": name_schema, |
| 594 | "count-index": integer0_schema, |
| 595 | }, |
| 596 | "required": ["vdu-id"], |
| 597 | "additionalProperties": False, |
| 598 | }, |
| 599 | }, |
| 600 | }, |
| 601 | "additionalProperties": False, |
| 602 | }, |
| 603 | }, |
| 604 | "required": ["vnfInstanceId"], |
| 605 | "additionalProperties": False, |
| 606 | }, |
| 607 | }, |
| 608 | }, |
| 609 | "required": ["healVnfData"], |
| 610 | "additionalProperties": False, |
| 611 | } |
| 612 | |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 613 | ns_verticalscale = { |
| 614 | "title": "vertial scale input schema", |
| 615 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 616 | "type": "object", |
| 617 | "properties": { |
| 618 | "lcmOperationType": string_schema, |
| govindarajul | 69964ec | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 619 | "verticalScale": string_schema, |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 620 | "nsInstanceId": id_schema, |
| govindarajul | 69964ec | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 621 | "changeVnfFlavorData": { |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 622 | "type": "object", |
| govindarajul | 69964ec | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 623 | "properties": { |
| 624 | "vnfInstanceId": id_schema, |
| 625 | "additionalParams": { |
| 626 | "type": "object", |
| 627 | "properties": { |
| 628 | "vduid": string_schema, |
| 629 | "vduCountIndex": integer0_schema, |
| 630 | "virtualMemory": integer1_schema, |
| 631 | "sizeOfStorage": integer0_schema, |
| 632 | "numVirtualCpu": integer1_schema, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 633 | }, |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 634 | }, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 635 | }, |
| govindarajul | 69964ec | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 636 | "required": ["vnfInstanceId", "additionalParams"], |
| 637 | "additionalProperties": False, |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 638 | }, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 639 | }, |
| govindarajul | 69964ec | 2022-07-06 10:24:38 +0000 | [diff] [blame] | 640 | "required": ["lcmOperationType", "verticalScale", "nsInstanceId"], |
| 641 | "additionalProperties": False, |
| govindarajul | 519da48 | 2022-04-29 19:05:22 +0530 | [diff] [blame] | 642 | } |
| 643 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 644 | schema_version = {"type": "string", "enum": ["1.0"]} |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 645 | schema_type = {"type": "string"} |
| tierno | b3d0a0e | 2019-11-13 15:57:51 +0000 | [diff] [blame] | 646 | vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 647 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 648 | vim_account_edit_schema = { |
| 649 | "title": "vim_account edit input schema", |
| 650 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 651 | "type": "object", |
| 652 | "properties": { |
| 653 | "name": name_schema, |
| 654 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 655 | "vim": name_schema, |
| 656 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 657 | "vim_type": vim_type, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 658 | "vim_url": description_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 659 | # "vim_url_admin": description_schema, |
| 660 | # "vim_tenant": name_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 661 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 662 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 663 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 664 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 665 | "config": {"type": "object"}, |
| vegall | 5c59aab | 2022-04-27 15:31:49 +0000 | [diff] [blame] | 666 | "prometheus-config": {"type": "object"}, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 667 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 668 | "additionalProperties": False, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 669 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 670 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 671 | vim_account_new_schema = { |
| 672 | "title": "vim_account creation input schema", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 673 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 674 | "type": "object", |
| 675 | "properties": { |
| 676 | "schema_version": schema_version, |
| 677 | "schema_type": schema_type, |
| 678 | "name": name_schema, |
| 679 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 680 | "vim": name_schema, |
| 681 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 682 | "vim_type": vim_type, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 683 | "vim_url": description_schema, |
| 684 | # "vim_url_admin": description_schema, |
| 685 | # "vim_tenant": name_schema, |
| 686 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 687 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 688 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 689 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 690 | "config": {"type": "object"}, |
| vegall | 5c59aab | 2022-04-27 15:31:49 +0000 | [diff] [blame] | 691 | "prometheus-config": {"type": "object"}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 692 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 693 | "required": [ |
| 694 | "name", |
| 695 | "vim_url", |
| 696 | "vim_type", |
| 697 | "vim_user", |
| 698 | "vim_password", |
| 699 | "vim_tenant_name", |
| 700 | ], |
| 701 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 702 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 703 | |
| tierno | 8580772 | 2019-12-20 14:11:35 +0000 | [diff] [blame] | 704 | wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 705 | |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 706 | wim_account_edit_schema = { |
| 707 | "title": "wim_account edit input schema", |
| 708 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 709 | "type": "object", |
| 710 | "properties": { |
| 711 | "name": name_schema, |
| 712 | "description": description_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 713 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 714 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 715 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 716 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 717 | "password": passwd_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 718 | "config": {"type": "object"}, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 719 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 720 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | wim_account_new_schema = { |
| 724 | "title": "wim_account creation input schema", |
| 725 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 726 | "type": "object", |
| 727 | "properties": { |
| 728 | "schema_version": schema_version, |
| 729 | "schema_type": schema_type, |
| 730 | "name": name_schema, |
| 731 | "description": description_schema, |
| 732 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 733 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 734 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 735 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 736 | "password": passwd_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 737 | "config": { |
| 738 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 739 | "patternProperties": {".": {"not": {"type": "null"}}}, |
| 740 | }, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 741 | }, |
| 742 | "required": ["name", "wim_url", "wim_type"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 743 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 744 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 745 | |
| 746 | sdn_properties = { |
| 747 | "name": name_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 748 | "type": {"type": "string"}, |
| 749 | "url": {"type": "string"}, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 750 | "user": string_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 751 | "password": passwd_schema, |
| 752 | "config": {"type": "object"}, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 753 | "description": description_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 754 | # The folowing are deprecated. Maintanied for backward compatibility |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 755 | "dpid": dpid_Schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 756 | "ip": ip_schema, |
| 757 | "port": port_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 758 | "version": {"type": "string", "minLength": 1, "maxLength": 12}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 759 | } |
| 760 | sdn_new_schema = { |
| 761 | "title": "sdn controller information schema", |
| 762 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 763 | "type": "object", |
| 764 | "properties": sdn_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 765 | "required": ["name", "type"], |
| 766 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 767 | } |
| 768 | sdn_edit_schema = { |
| 769 | "title": "sdn controller update information schema", |
| 770 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 771 | "type": "object", |
| 772 | "properties": sdn_properties, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 773 | # "required": ["name", "port", 'ip', 'dpid', 'type'], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 774 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 775 | } |
| 776 | sdn_port_mapping_schema = { |
| 777 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 778 | "title": "sdn port mapping information schema", |
| 779 | "type": "array", |
| 780 | "items": { |
| 781 | "type": "object", |
| 782 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 783 | "compute_node": shortname_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 784 | "ports": { |
| 785 | "type": "array", |
| 786 | "items": { |
| 787 | "type": "object", |
| 788 | "properties": { |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 789 | "pci": pci_extended_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 790 | "switch_port": shortname_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 791 | "switch_mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 792 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 793 | "required": ["pci"], |
| 794 | }, |
| 795 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 796 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 797 | "required": ["compute_node", "ports"], |
| 798 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 799 | } |
| 800 | sdn_external_port_schema = { |
| 801 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 802 | "title": "External port information", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 803 | "type": "object", |
| 804 | "properties": { |
| 805 | "port": {"type": "string", "minLength": 1, "maxLength": 60}, |
| 806 | "vlan": vlan_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 807 | "mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 808 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 809 | "required": ["port"], |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 810 | } |
| 811 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 812 | # K8s Clusters |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 813 | k8scluster_deploy_method_schema = { |
| 814 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 815 | "title": "Deployment methods for K8s cluster", |
| 816 | "type": "object", |
| 817 | "properties": { |
| 818 | "helm-chart": {"type": "boolean"}, |
| 819 | "juju-bundle": {"type": "boolean"}, |
| 820 | "helm-chart-v3": {"type": "boolean"}, |
| 821 | }, |
| 822 | "additionalProperties": False, |
| 823 | "minProperties": 3, |
| 824 | } |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 825 | k8scluster_nets_schema = { |
| 826 | "title": "k8scluster nets input schema", |
| 827 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 828 | "type": "object", |
| tierno | 8c81ab0 | 2020-02-07 10:18:30 +0000 | [diff] [blame] | 829 | "patternProperties": {".": {"oneOf": [name_schema, null_schema]}}, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 830 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 831 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 832 | } |
| 833 | k8scluster_new_schema = { |
| 834 | "title": "k8scluster creation input schema", |
| 835 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 836 | "type": "object", |
| 837 | "properties": { |
| 838 | "schema_version": schema_version, |
| 839 | "schema_type": schema_type, |
| 840 | "name": name_schema, |
| 841 | "description": description_schema, |
| 842 | "credentials": object_schema, |
| 843 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 844 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 845 | "k8s_version": string_schema, |
| 846 | "nets": k8scluster_nets_schema, |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 847 | "deployment_methods": k8scluster_deploy_method_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 848 | "namespace": name_schema, |
| 849 | "cni": nameshort_list_schema, |
| 850 | }, |
| 851 | "required": ["name", "credentials", "vim_account", "k8s_version", "nets"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 852 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 853 | } |
| 854 | k8scluster_edit_schema = { |
| 855 | "title": "vim_account edit input schema", |
| 856 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 857 | "type": "object", |
| 858 | "properties": { |
| 859 | "name": name_schema, |
| 860 | "description": description_schema, |
| 861 | "credentials": object_schema, |
| 862 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 863 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 864 | "k8s_version": string_schema, |
| 865 | "nets": k8scluster_nets_schema, |
| 866 | "namespace": name_schema, |
| 867 | "cni": nameshort_list_schema, |
| 868 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 869 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 870 | } |
| 871 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 872 | # VCA |
| 873 | vca_new_schema = { |
| 874 | "title": "vca creation input schema", |
| 875 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 876 | "type": "object", |
| 877 | "properties": { |
| 878 | "schema_version": schema_version, |
| 879 | "schema_type": schema_type, |
| 880 | "name": name_schema, |
| 881 | "description": description_schema, |
| 882 | "endpoints": description_list_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 883 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 884 | "secret": passwd_schema, |
| 885 | "cacert": long_description_schema, |
| 886 | "lxd-cloud": shortname_schema, |
| 887 | "lxd-credentials": shortname_schema, |
| 888 | "k8s-cloud": shortname_schema, |
| 889 | "k8s-credentials": shortname_schema, |
| 890 | "model-config": object_schema, |
| 891 | }, |
| 892 | "required": [ |
| 893 | "name", |
| 894 | "endpoints", |
| 895 | "user", |
| 896 | "secret", |
| 897 | "cacert", |
| 898 | "lxd-cloud", |
| 899 | "lxd-credentials", |
| 900 | "k8s-cloud", |
| 901 | "k8s-credentials", |
| 902 | ], |
| 903 | "additionalProperties": False, |
| 904 | } |
| 905 | vca_edit_schema = { |
| 906 | "title": "vca creation input schema", |
| 907 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 908 | "type": "object", |
| 909 | "properties": { |
| 910 | "name": name_schema, |
| 911 | "description": description_schema, |
| 912 | "endpoints": description_list_schema, |
| 913 | "port": integer1_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 914 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 915 | "secret": passwd_schema, |
| 916 | "cacert": long_description_schema, |
| 917 | "lxd-cloud": shortname_schema, |
| 918 | "lxd-credentials": shortname_schema, |
| 919 | "k8s-cloud": shortname_schema, |
| 920 | "k8s-credentials": shortname_schema, |
| 921 | "model-config": object_schema, |
| 922 | }, |
| 923 | "additionalProperties": False, |
| 924 | } |
| 925 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 926 | # K8s Repos |
| tierno | 332e080 | 2019-12-03 23:50:49 +0000 | [diff] [blame] | 927 | k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]} |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 928 | k8srepo_properties = { |
| 929 | "name": name_schema, |
| 930 | "description": description_schema, |
| 931 | "type": k8srepo_types, |
| 932 | "url": description_schema, |
| 933 | } |
| 934 | k8srepo_new_schema = { |
| 935 | "title": "k8scluster creation input schema", |
| 936 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 937 | "type": "object", |
| 938 | "properties": k8srepo_properties, |
| 939 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 940 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 941 | } |
| 942 | k8srepo_edit_schema = { |
| 943 | "title": "vim_account edit input schema", |
| 944 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 945 | "type": "object", |
| 946 | "properties": k8srepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 947 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 948 | } |
| 949 | |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 950 | # OSM Repos |
| 951 | osmrepo_types = {"enum": ["osm"]} |
| 952 | osmrepo_properties = { |
| 953 | "name": name_schema, |
| 954 | "description": description_schema, |
| 955 | "type": osmrepo_types, |
| 956 | "url": description_schema |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 957 | # "user": string_schema, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 958 | # "password": passwd_schema |
| 959 | } |
| 960 | osmrepo_new_schema = { |
| 961 | "title": "osm repo creation input schema", |
| 962 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 963 | "type": "object", |
| 964 | "properties": osmrepo_properties, |
| 965 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 966 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 967 | } |
| 968 | osmrepo_edit_schema = { |
| 969 | "title": "osm repo edit input schema", |
| 970 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 971 | "type": "object", |
| 972 | "properties": osmrepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 973 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 974 | } |
| 975 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 976 | # PDUs |
| 977 | pdu_interface = { |
| 978 | "type": "object", |
| 979 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 980 | "name": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 981 | "mgmt": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 982 | "type": {"enum": ["overlay", "underlay"]}, |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 983 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 984 | # TODO, add user, password, ssh-key |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 985 | "mac-address": mac_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 986 | "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port |
| 987 | "vim-network-id": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 988 | # # provide this in case SDN assist must deal with this interface |
| 989 | # "switch-dpid": dpid_Schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 990 | # "switch-port": shortname_schema, |
| 991 | # "switch-mac": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 992 | # "switch-vlan": vlan_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 993 | }, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 994 | "required": ["name", "mgmt", "ip-address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 995 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 996 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 997 | pdu_new_schema = { |
| 998 | "title": "pdu creation input schema", |
| 999 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1000 | "type": "object", |
| 1001 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1002 | "name": shortname_schema, |
| 1003 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1004 | "description": description_schema, |
| 1005 | "shared": bool_schema, |
| 1006 | "vims": nameshort_list_schema, |
| 1007 | "vim_accounts": nameshort_list_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1008 | "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1009 | }, |
| 1010 | "required": ["name", "type", "interfaces"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1011 | "additionalProperties": False, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1012 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1013 | pdu_edit_schema = { |
| 1014 | "title": "pdu edit input schema", |
| 1015 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1016 | "type": "object", |
| 1017 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1018 | "name": shortname_schema, |
| 1019 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1020 | "description": description_schema, |
| 1021 | "shared": bool_schema, |
| garciadeblas | 84bdd55 | 2018-11-30 22:59:45 +0100 | [diff] [blame] | 1022 | "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| 1023 | "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1024 | "interfaces": { |
| 1025 | "oneOf": [ |
| 1026 | array_edition_schema, |
| 1027 | {"type": "array", "items": pdu_interface, "minItems": 1}, |
| 1028 | ] |
| 1029 | }, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1030 | }, |
| 1031 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1032 | "minProperties": 1, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1033 | } |
| 1034 | |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 1035 | # VNF PKG OPERATIONS |
| 1036 | vnfpkgop_new_schema = { |
| 1037 | "title": "VNF PKG operation creation input schema", |
| 1038 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1039 | "type": "object", |
| 1040 | "properties": { |
| 1041 | "lcmOperationType": string_schema, |
| 1042 | "vnfPkgId": id_schema, |
| 1043 | "kdu_name": name_schema, |
| 1044 | "primitive": name_schema, |
| 1045 | "primitive_params": {"type": "object"}, |
| 1046 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1047 | "required": [ |
| 1048 | "lcmOperationType", |
| 1049 | "vnfPkgId", |
| 1050 | "kdu_name", |
| 1051 | "primitive", |
| 1052 | "primitive_params", |
| 1053 | ], |
| 1054 | "additionalProperties": False, |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 1055 | } |
| 1056 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1057 | # USERS |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1058 | project_role_mappings = { |
| 1059 | "title": "list pf projects/roles", |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1060 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1061 | "type": "array", |
| 1062 | "items": { |
| 1063 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1064 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1065 | "required": ["project", "role"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1066 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1067 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1068 | "minItems": 1, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1069 | } |
| 1070 | project_role_mappings_optional = { |
| 1071 | "title": "list of projects/roles or projects only", |
| 1072 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1073 | "type": "array", |
| 1074 | "items": { |
| 1075 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1076 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1077 | "required": ["project"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1078 | "additionalProperties": False, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1079 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1080 | "minItems": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1081 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1082 | user_new_schema = { |
| 1083 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1084 | "title": "New user schema", |
| 1085 | "type": "object", |
| 1086 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1087 | "username": string_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 1088 | "domain_name": shortname_schema, |
| garciadeblas | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 1089 | "password": user_passwd_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1090 | "projects": nameshort_list_schema, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1091 | "project_role_mappings": project_role_mappings, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1092 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1093 | "required": ["username", "password"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1094 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1095 | } |
| 1096 | user_edit_schema = { |
| 1097 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1098 | "title": "User edit schema for administrators", |
| 1099 | "type": "object", |
| 1100 | "properties": { |
| garciadeblas | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 1101 | "password": user_passwd_schema, |
| selvi.j | a9a1fc8 | 2022-04-04 06:54:30 +0000 | [diff] [blame] | 1102 | "old_password": passwd_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1103 | "username": string_schema, # To allow User Name modification |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1104 | "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1105 | "project_role_mappings": project_role_mappings, |
| 1106 | "add_project_role_mappings": project_role_mappings, |
| 1107 | "remove_project_role_mappings": project_role_mappings_optional, |
| garciadeblas | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 1108 | "system_admin_id": id_schema, |
| 1109 | "unlock": bool_schema, |
| 1110 | "renew": bool_schema, |
| 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", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1439 | "VnfIdentifierDeletionNotification", |
| 1440 | ] |
| 1441 | }, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1442 | }, |
| 1443 | "operationTypes": { |
| 1444 | "type": "array", |
| 1445 | "items": { |
| 1446 | "enum": [ |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1447 | "INSTANTIATE", |
| 1448 | "SCALE", |
| 1449 | "SCALE_TO_LEVEL", |
| 1450 | "CHANGE_FLAVOUR", |
| 1451 | "TERMINATE", |
| 1452 | "HEAL", |
| 1453 | "OPERATE", |
| 1454 | "CHANGE_EXT_CONN", |
| 1455 | "MODIFY_INFO", |
| 1456 | "CREATE_SNAPSHOT", |
| 1457 | "REVERT_TO_SNAPSHOT", |
| 1458 | "CHANGE_VNFPKG", |
| 1459 | ] |
| 1460 | }, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1461 | }, |
| 1462 | "operationStates": { |
| 1463 | "type": "array", |
| 1464 | "items": { |
| 1465 | "enum": [ |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1466 | "STARTING", |
| 1467 | "PROCESSING", |
| 1468 | "COMPLETED", |
| 1469 | "FAILED_TEMP", |
| 1470 | "FAILED", |
| 1471 | "ROLLING_BACK", |
| 1472 | "ROLLED_BACK", |
| 1473 | ] |
| 1474 | }, |
| 1475 | }, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1476 | }, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1477 | "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"], |
| 1478 | } |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1479 | |
| 1480 | vnf_subscription = { |
| 1481 | "title": "vnf subscription input schema", |
| 1482 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1483 | "type": "object", |
| 1484 | "properties": { |
| 1485 | "filter": vnflcmsub_schema, |
| 1486 | "CallbackUri": description_schema, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1487 | "authentication": authentication_schema, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1488 | }, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1489 | "required": ["filter", "CallbackUri"], |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1490 | } |
| 1491 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1492 | |
| 1493 | class ValidationError(Exception): |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1494 | def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY): |
| 1495 | self.http_code = http_code |
| 1496 | Exception.__init__(self, message) |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1497 | |
| 1498 | |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1499 | def validate_input(indata, schema_to_use): |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1500 | """ |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1501 | Validates input data against json schema |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1502 | :param indata: user input data. Should be a dictionary |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1503 | :param schema_to_use: jsonschema to test |
| 1504 | :return: None if ok, raises ValidationError exception on error |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1505 | """ |
| 1506 | try: |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1507 | if schema_to_use: |
| 1508 | js_v(indata, schema_to_use) |
| 1509 | return None |
| 1510 | except js_e.ValidationError as e: |
| 1511 | if e.path: |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 1512 | error_pos = "at '" + ":".join(map(str, e.path)) + "'" |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1513 | else: |
| 1514 | error_pos = "" |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 1515 | raise ValidationError("Format error {} '{}' ".format(error_pos, e.message)) |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1516 | except js_e.SchemaError: |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1517 | raise ValidationError( |
| 1518 | "Bad json schema {}".format(schema_to_use), |
| 1519 | http_code=HTTPStatus.INTERNAL_SERVER_ERROR, |
| 1520 | ) |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1521 | |
| 1522 | |
| 1523 | def is_valid_uuid(x): |
| 1524 | """ |
| 1525 | Test for a valid UUID |
| 1526 | :param x: string to test |
| 1527 | :return: True if x is a valid uuid, False otherwise |
| 1528 | """ |
| 1529 | try: |
| 1530 | if UUID(x): |
| 1531 | return True |
| tierno | bdebce9 | 2019-07-01 15:36:49 +0000 | [diff] [blame] | 1532 | except (TypeError, ValueError, AttributeError): |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1533 | return False |