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