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