| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| tierno | a62249e | 2018-09-17 17:57:30 +0200 | [diff] [blame] | 4 | # Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U. |
| tierno | 9a61c6b | 2016-09-08 10:57:02 +0200 | [diff] [blame] | 5 | # This file is part of openvim |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. You may obtain |
| 10 | # a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | # License for the specific language governing permissions and limitations |
| 18 | # under the License. |
| 19 | # |
| 20 | # For those usages not covered by the Apache License, Version 2.0 please |
| 21 | # contact with: nfvlabs@tid.es |
| 22 | ## |
| 23 | |
| 24 | ''' Definition of dictionaries schemas used by validating input |
| 25 | These dictionaries are validated using jsonschema library |
| 26 | ''' |
| 27 | __author__="Alfonso Tierno" |
| 28 | __date__ ="$10-jul-2014 12:07:15$" |
| 29 | |
| 30 | # |
| 31 | # SCHEMAS to validate input data |
| 32 | # |
| 33 | |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 34 | path_schema = {"type": "string", "maxLength": 255, "pattern": "^(\.){0,2}(/[^/\"':{}\(\)]+)+$"} |
| tierno | 338e998 | 2017-09-08 12:44:15 +0200 | [diff] [blame] | 35 | http_schema = {"type": "string", "pattern": "^https?://[^'\"=]+$"} |
| 36 | port_schema = {"type": "integer","minimum": 1, "maximun": 65534} |
| 37 | ip_schema = {"type": "string", "pattern": "^([0-9]{1,3}.){3}[0-9]{1,3}$"} |
| 38 | cidr_schema = {"type": "string", "pattern": "^([0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$"} |
| 39 | name_schema = {"type": "string", "minLength": 1, "maxLength": 255, "pattern": "^[^,;()'\"]+$"} |
| 40 | nameshort_schema = {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[^,;()'\"]+$"} |
| 41 | nametiny_schema = {"type": "string", "minLength": 1, "maxLength": 12, "pattern": "^[^,;()'\"]+$"} |
| 42 | xml_text_schema = {"type": "string", "minLength": 1, "maxLength": 1000, "pattern": "^[^']+$"} |
| 43 | description_schema = {"type": ["string", "null"], "maxLength": 255, "pattern": "^[^'\"]+$"} |
| 44 | id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36} |
| 45 | # "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}$" |
| 46 | id_schema = {"type": "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"} |
| 47 | pci_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"} |
| 48 | # used by VIO neutron-port-show <host_moid>-<domain>:<bus>:<device>.<function>-<VF-id> |
| 49 | pci_extended_schema = {"type": "string", "pattern": "^([0-9a-fA-F]{4}-)?[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}" |
| 50 | "\.[0-9a-fA-F](-[0-9a-fA-F]{3})?$"} |
| 51 | bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"} |
| 52 | integer0_schema = {"type": "integer", "minimum": 0} |
| 53 | integer1_schema = {"type": "integer", "minimum": 1} |
| 54 | vlan_schema = {"type": "integer", "minimum": 1, "maximun": 4095} |
| 55 | vlan1000_schema = {"type": "integer", "minimum": 1000, "maximun": 4095} |
| 56 | mac_schema = {"type": "string", "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$"} |
| 57 | # must be unicast LSB bit of MSB byte ==0 |
| 58 | net_bind_schema = {"oneOf": [ |
| 59 | {"type": "null"}, |
| 60 | {"type": "string", "pattern": |
| 61 | "^(default|((bridge|macvtap):[0-9a-zA-Z\.\-]{1,50})|openflow:[/0-9a-zA-Z\.\-]{1,50}(:vlan)?)$"} |
| 62 | ]} |
| 63 | yes_no_schema = {"type": "string", "enum": ["yes", "no"]} |
| 64 | log_level_schema = {"type": "string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]} |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 65 | |
| 66 | config_schema = { |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 67 | "title": "main configuration information schema", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 68 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 69 | "type": "object", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 70 | "properties":{ |
| 71 | "http_port": port_schema, |
| 72 | "http_admin_port": port_schema, |
| 73 | "http_host": nameshort_schema, |
| 74 | "http_url_prefix": path_schema, # it does not work yet; it's supposed to be the base path to be used by bottle, but it must be explicitly declared |
| 75 | "db_host": nameshort_schema, |
| 76 | "db_user": nameshort_schema, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 77 | "db_passwd": {"type": "string"}, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 78 | "db_name": nameshort_schema, |
| 79 | "of_controller_ip": ip_schema, |
| 80 | "of_controller_port": port_schema, |
| 81 | "of_controller_dpid": nameshort_schema, |
| 82 | "of_controller_nets_with_same_vlan": {"type" : "boolean"}, |
| 83 | "of_controller": nameshort_schema, #{"type":"string", "enum":["floodlight", "opendaylight"]}, |
| 84 | "of_controller_module": {"type":"string"}, |
| mirabal | 580435e | 2017-03-01 16:17:10 +0100 | [diff] [blame] | 85 | "of_user": nameshort_schema, |
| 86 | "of_password": nameshort_schema, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 87 | "test_mode": {"type": "boolean"}, # leave for backward compatibility |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 88 | "mode": {"type":"string", "enum":["normal", "host only", "OF only", "development", "test"] }, |
| 89 | "development_bridge": {"type":"string"}, |
| 90 | "tenant_id": {"type" : "string"}, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 91 | "image_path": path_schema, # leave for backward compatibility |
| 92 | "host_image_path": path_schema, |
| 93 | "host_ssh_keyfile": path_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 94 | "network_vlan_range_start": vlan_schema, |
| 95 | "network_vlan_range_end": vlan_schema, |
| 96 | "bridge_ifaces": { |
| 97 | "type": "object", |
| 98 | "patternProperties": { |
| 99 | "." : { |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 100 | "type": "array", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 101 | "items": integer0_schema, |
| 102 | "minItems":2, |
| 103 | "maxItems":2, |
| 104 | }, |
| 105 | }, |
| 106 | "minProperties": 2 |
| 107 | }, |
| 108 | "dhcp_server": { |
| 109 | "type": "object", |
| 110 | "properties": { |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 111 | "host": name_schema, |
| 112 | "port": port_schema, |
| 113 | "provider": {"type": "string", "enum": ["isc-dhcp-server"]}, |
| 114 | "user": nameshort_schema, |
| 115 | "password": {"type": "string"}, |
| 116 | "key": path_schema, # for backward compatibility, use keyfile instead |
| 117 | "keyfile": path_schema, |
| 118 | "bridge_ifaces": { |
| 119 | "type": "array", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 120 | "items": nameshort_schema, |
| 121 | }, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 122 | "nets": { |
| 123 | "type": "array", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 124 | "items": name_schema, |
| 125 | }, |
| 126 | }, |
| 127 | "required": ['host', 'provider', 'user'] |
| 128 | }, |
| 129 | "log_level": log_level_schema, |
| 130 | "log_level_db": log_level_schema, |
| 131 | "log_level_of": log_level_schema, |
| Mirabal | 7256d6b | 2016-12-15 10:51:19 +0000 | [diff] [blame] | 132 | "network_type": {"type": "string", "enum": ["ovs", "bridge"]}, |
| Mirabal | e9317ff | 2017-01-18 16:10:58 +0000 | [diff] [blame] | 133 | "ovs_controller_file_path": path_schema, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 134 | "ovs_controller_ip": nameshort_schema, |
| Mirabal | e9317ff | 2017-01-18 16:10:58 +0000 | [diff] [blame] | 135 | "ovs_controller_user": nameshort_schema, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 136 | "ovs_controller_password": {"type": "string"}, |
| 137 | "ovs_controller_keyfile": path_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 138 | }, |
| 139 | "patternProperties": { |
| 140 | "of_*" : {"type": ["string", "integer", "boolean"]} |
| 141 | }, |
| mirabal | 580435e | 2017-03-01 16:17:10 +0100 | [diff] [blame] | 142 | "required": ['db_host', 'db_user', 'db_passwd', 'db_name'], |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 143 | "additionalProperties": False |
| 144 | } |
| 145 | |
| 146 | |
| 147 | |
| 148 | metadata_schema={ |
| 149 | "type":"object", |
| 150 | "properties":{ |
| 151 | "architecture": {"type":"string"}, |
| 152 | "use_incremental": yes_no_schema, |
| 153 | "vpci": pci_schema, |
| 154 | "os_distro": {"type":"string"}, |
| 155 | "os_type": {"type":"string"}, |
| 156 | "os_version": {"type":"string"}, |
| 157 | "bus": {"type":"string"}, |
| garciadeblas | 1dd7eb2 | 2017-06-01 11:40:13 +0200 | [diff] [blame] | 158 | "topology": {"type":"string", "enum": ["oneSocket", "oneSocket:hyperthreading"]} |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 162 | tenant_new_schema = { |
| 163 | "title":"tenant creation information schema", |
| 164 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 165 | "type":"object", |
| 166 | "properties":{ |
| 167 | "tenant":{ |
| 168 | "type":"object", |
| 169 | "properties":{ |
| 170 | "id":id_schema, |
| 171 | "name": nameshort_schema, |
| 172 | "description":description_schema, |
| 173 | "enabled":{"type" : "boolean"} |
| 174 | }, |
| 175 | "required": ["name"] |
| 176 | } |
| 177 | }, |
| 178 | "required": ["tenant"], |
| 179 | "additionalProperties": False |
| 180 | } |
| mirabal | 6045a9d | 2017-03-06 11:36:55 +0100 | [diff] [blame] | 181 | |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 182 | tenant_edit_schema = { |
| 183 | "title":"tenant edition information schema", |
| 184 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 185 | "type":"object", |
| 186 | "properties":{ |
| 187 | "tenant":{ |
| 188 | "type":"object", |
| 189 | "minProperties":1, |
| 190 | "properties":{ |
| 191 | "name":nameshort_schema, |
| 192 | "description":description_schema, |
| 193 | "enabled":{"type" : "boolean"} |
| 194 | }, |
| 195 | "additionalProperties": False, |
| 196 | } |
| 197 | }, |
| 198 | "required": ["tenant"], |
| 199 | "additionalProperties": False |
| 200 | } |
| 201 | interfaces_schema={ |
| 202 | "type":"array", |
| 203 | "minItems":0, |
| 204 | "items":{ |
| 205 | "type":"object", |
| 206 | "properties":{ |
| 207 | "name":name_schema, |
| 208 | "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]}, |
| 209 | "bandwidth":bandwidth_schema, |
| 210 | "vpci":pci_schema, |
| 211 | "uuid":id_schema, |
| 212 | "mac_address":mac_schema |
| 213 | }, |
| 214 | "additionalProperties": False, |
| 215 | "required": ["dedicated", "bandwidth"] |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | extended_schema={ |
| 220 | "type":"object", |
| 221 | "properties":{ |
| 222 | "processor_ranking":integer0_schema, |
| 223 | "devices":{ |
| 224 | "type": "array", |
| 225 | "items":{ |
| 226 | "type": "object", |
| 227 | "properties":{ |
| 228 | "type":{"type":"string", "enum":["usb","disk","cdrom","xml"]}, |
| 229 | "vpci":pci_schema, |
| 230 | "imageRef":id_schema, |
| 231 | "xml":xml_text_schema, |
| mirabal | caeb224 | 2017-05-31 10:52:22 -0500 | [diff] [blame] | 232 | "dev":nameshort_schema, |
| 233 | "size":integer1_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 234 | }, |
| 235 | "additionalProperties": False, |
| 236 | "required": ["type"] |
| 237 | } |
| 238 | }, |
| 239 | "numas":{ |
| 240 | "type": "array", |
| 241 | "items":{ |
| 242 | "type": "object", |
| 243 | "properties":{ |
| 244 | "memory":integer1_schema, |
| 245 | "cores":integer1_schema, |
| 246 | "paired-threads":integer1_schema, |
| 247 | "threads":integer1_schema, |
| 248 | "cores-id":{"type":"array","items":integer0_schema}, |
| 249 | "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}}, |
| 250 | "threads-id":{"type":"array","items":integer0_schema}, |
| 251 | "interfaces":interfaces_schema |
| 252 | }, |
| 253 | "additionalProperties": False, |
| 254 | "minProperties": 1, |
| 255 | #"required": ["memory"] |
| 256 | } |
| 257 | } |
| 258 | }, |
| 259 | #"additionalProperties": False, |
| 260 | #"required": ["processor_ranking"] |
| 261 | } |
| 262 | |
| 263 | host_data_schema={ |
| 264 | "title":"hosts manual insertion information schema", |
| 265 | "type":"object", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 266 | "properties":{ |
| 267 | "id": id_schema, |
| 268 | "admin_state_up": {"type": "boolean"}, |
| 269 | "created_at": {"type": "string"}, # ignored, just for compatibility with host-list |
| 270 | "ip_name": nameshort_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 271 | "name": name_schema, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 272 | "description": description_schema, |
| 273 | "user": nameshort_schema, |
| 274 | "password": nameshort_schema, |
| 275 | "keyfile": path_schema, |
| 276 | "features": description_schema, |
| 277 | "ranking": integer0_schema, |
| 278 | "autodiscover": {"type": "boolean"}, # try to discover host parameters instead of providing in this schema |
| Paolo Lungaroni | 423a408 | 2018-02-14 18:05:02 +0100 | [diff] [blame] | 279 | "hypervisors": description_schema, #Unikernels extension |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 280 | "devices": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 281 | "type": "array", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 282 | "items": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 283 | "type": "object", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 284 | "properties": { |
| 285 | "type": {"type": "string", "enum": ["usb", "disk"]}, |
| 286 | "vpci": pci_schema |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 287 | }, |
| 288 | "additionalProperties": False, |
| 289 | "required": ["type"] |
| 290 | } |
| 291 | }, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 292 | "numas": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 293 | "type": "array", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 294 | "minItems": 1, |
| 295 | "items": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 296 | "type": "object", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 297 | "properties": { |
| 298 | "admin_state_up": {"type": "boolean"}, |
| 299 | "hugepages": integer0_schema, |
| 300 | "hugepages_consumed": integer0_schema, # ignored, just for compatibility with host-list |
| 301 | "numa_socket": integer0_schema, |
| 302 | "memory": integer1_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 303 | "cores":{ |
| 304 | "type": "array", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 305 | "minItems": 2, |
| 306 | "items": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 307 | "type": "object", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 308 | "properties": { |
| 309 | "core_id": integer0_schema, |
| 310 | "thread_id": integer0_schema, |
| tierno | c67abe2 | 2017-07-03 17:04:54 +0200 | [diff] [blame] | 311 | "status": {"type": "string", "enum": ["noteligible"]}, |
| 312 | "instance_id": {"type": "string"}, # ignored, just for compatibility with host-list |
| 313 | "v_thread_id": {"type": "integer"} # ignored, just for compatibility with host-list |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 314 | }, |
| 315 | "additionalProperties": False, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 316 | "required": ["core_id", "thread_id"] |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 317 | } |
| 318 | }, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 319 | "interfaces": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 320 | "type": "array", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 321 | "minItems": 1, |
| 322 | "items": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 323 | "type": "object", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 324 | "properties": { |
| 325 | "source_name": nameshort_schema, |
| 326 | "mac": mac_schema, |
| 327 | "Mbps": integer0_schema, |
| 328 | "pci": pci_schema, |
| 329 | "sriovs": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 330 | "type": "array", |
| 331 | "minItems":1, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 332 | "items": { |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 333 | "type": "object", |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 334 | "properties": { |
| 335 | "source_name": {"oneOf": [integer0_schema, nameshort_schema]}, |
| 336 | "mac": mac_schema, |
| 337 | "vlan": integer0_schema, # ignored, just for backward compatibility |
| 338 | "pci": pci_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 339 | }, |
| 340 | "additionalProperties": False, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 341 | "required": ["source_name", "mac", "pci"] |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 342 | } |
| 343 | }, |
| 344 | "switch_port": nameshort_schema, |
| 345 | "switch_dpid": nameshort_schema, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 346 | "switch_mac": mac_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 347 | }, |
| 348 | "additionalProperties": False, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 349 | "required": ["source_name", "mac", "Mbps", "pci"] |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 350 | } |
| 351 | }, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 352 | }, |
| 353 | "additionalProperties": False, |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 354 | "required": ["cores", "numa_socket"] |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | }, |
| 358 | "additionalProperties": False, |
| tierno | c67abe2 | 2017-07-03 17:04:54 +0200 | [diff] [blame] | 359 | "required": ["name", "user", "ip_name"] |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | host_edit_schema={ |
| 363 | "title":"hosts creation information schema", |
| 364 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 365 | "type":"object", |
| 366 | "properties":{ |
| 367 | "host":{ |
| 368 | "type":"object", |
| 369 | "properties":{ |
| 370 | "ip_name":nameshort_schema, |
| 371 | "name": name_schema, |
| 372 | "description":description_schema, |
| 373 | "user":nameshort_schema, |
| 374 | "password":nameshort_schema, |
| 375 | "admin_state_up":{"type":"boolean"}, |
| 376 | "numas":{ |
| 377 | "type":"array", |
| 378 | "items":{ |
| 379 | "type": "object", |
| 380 | "properties":{ |
| 381 | "numa_socket": integer0_schema, |
| 382 | "admin_state_up":{"type":"boolean"}, |
| 383 | "interfaces":{ |
| 384 | "type":"array", |
| 385 | "items":{ |
| 386 | "type": "object", |
| 387 | "properties":{ |
| 388 | "source_name": nameshort_schema, |
| 389 | "switch_dpid": nameshort_schema, |
| 390 | "switch_port": nameshort_schema, |
| 391 | }, |
| 392 | "required": ["source_name"], |
| 393 | } |
| 394 | } |
| 395 | }, |
| 396 | "required": ["numa_socket"], |
| 397 | "additionalProperties": False, |
| 398 | } |
| 399 | } |
| 400 | }, |
| 401 | "minProperties": 1, |
| 402 | "additionalProperties": False |
| 403 | }, |
| 404 | }, |
| 405 | "required": ["host"], |
| 406 | "minProperties": 1, |
| 407 | "additionalProperties": False |
| 408 | } |
| 409 | |
| 410 | host_new_schema = { |
| 411 | "title":"hosts creation information schema", |
| 412 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 413 | "type":"object", |
| 414 | "properties":{ |
| tierno | a693304 | 2017-05-24 16:54:33 +0200 | [diff] [blame] | 415 | "host": host_data_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 416 | "host-data":host_data_schema |
| 417 | }, |
| 418 | "required": ["host"], |
| 419 | "minProperties": 1, |
| 420 | "maxProperties": 2, |
| 421 | "additionalProperties": False |
| 422 | } |
| 423 | |
| 424 | |
| 425 | flavor_new_schema = { |
| 426 | "title":"flavor creation information schema", |
| 427 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 428 | "type":"object", |
| 429 | "properties":{ |
| 430 | "flavor":{ |
| 431 | "type":"object", |
| 432 | "properties":{ |
| 433 | "id":id_schema, |
| 434 | "name":name_schema, |
| 435 | "description":description_schema, |
| 436 | "ram":integer0_schema, |
| 437 | "vcpus":integer0_schema, |
| 438 | "extended": extended_schema, |
| 439 | "public": yes_no_schema |
| 440 | }, |
| 441 | "required": ["name"] |
| 442 | } |
| 443 | }, |
| 444 | "required": ["flavor"], |
| 445 | "additionalProperties": False |
| 446 | } |
| 447 | flavor_update_schema = { |
| 448 | "title":"flavor update information schema", |
| 449 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 450 | "type":"object", |
| 451 | "properties":{ |
| 452 | "flavor":{ |
| 453 | "type":"object", |
| 454 | "properties":{ |
| 455 | "name":name_schema, |
| 456 | "description":description_schema, |
| 457 | "ram":integer0_schema, |
| 458 | "vcpus":integer0_schema, |
| 459 | "extended": extended_schema, |
| 460 | "public": yes_no_schema |
| 461 | }, |
| 462 | "minProperties": 1, |
| 463 | "additionalProperties": False |
| 464 | } |
| 465 | }, |
| 466 | "required": ["flavor"], |
| 467 | "additionalProperties": False |
| 468 | } |
| 469 | |
| 470 | image_new_schema = { |
| 471 | "title":"image creation information schema", |
| 472 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 473 | "type":"object", |
| 474 | "properties":{ |
| 475 | "image":{ |
| 476 | "type":"object", |
| 477 | "properties":{ |
| 478 | "id":id_schema, |
| 479 | "path": {"oneOf": [path_schema, http_schema]}, |
| 480 | "description":description_schema, |
| 481 | "name":name_schema, |
| 482 | "metadata":metadata_schema, |
| 483 | "public": yes_no_schema |
| 484 | }, |
| 485 | "required": ["name","path"] |
| 486 | } |
| 487 | }, |
| 488 | "required": ["image"], |
| 489 | "additionalProperties": False |
| 490 | } |
| 491 | |
| 492 | image_update_schema = { |
| 493 | "title":"image update information schema", |
| 494 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 495 | "type":"object", |
| 496 | "properties":{ |
| 497 | "image":{ |
| 498 | "type":"object", |
| 499 | "properties":{ |
| 500 | "path":{"oneOf": [path_schema, http_schema]}, |
| 501 | "description":description_schema, |
| 502 | "name":name_schema, |
| 503 | "metadata":metadata_schema, |
| 504 | "public": yes_no_schema |
| 505 | }, |
| 506 | "minProperties": 1, |
| 507 | "additionalProperties": False |
| 508 | } |
| 509 | }, |
| 510 | "required": ["image"], |
| 511 | "additionalProperties": False |
| 512 | } |
| 513 | |
| 514 | networks_schema={ |
| 515 | "type":"array", |
| 516 | "items":{ |
| 517 | "type":"object", |
| 518 | "properties":{ |
| 519 | "name":name_schema, |
| 520 | "bandwidth":bandwidth_schema, |
| 521 | "vpci":pci_schema, |
| 522 | "uuid":id_schema, |
| 523 | "mac_address": mac_schema, |
| tierno | 9b5d7f9 | 2018-03-14 15:18:20 +0100 | [diff] [blame] | 524 | "ip_address": ip_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 525 | "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}, |
| 526 | "type": {"type":"string", "enum":["virtual","PF","VF","VFnotShared"]} |
| 527 | }, |
| 528 | "additionalProperties": False, |
| 529 | "required": ["uuid"] |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | server_new_schema = { |
| 534 | "title":"server creation information schema", |
| 535 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 536 | "type":"object", |
| 537 | "properties":{ |
| 538 | "server":{ |
| 539 | "type":"object", |
| 540 | "properties":{ |
| 541 | "id":id_schema, |
| 542 | "name":name_schema, |
| 543 | "description":description_schema, |
| 544 | "start":{"type":"string", "enum":["yes","no","paused"]}, |
| 545 | "hostId":id_schema, |
| 546 | "flavorRef":id_schema, |
| 547 | "imageRef":id_schema, |
| Paolo Lungaroni | 423a408 | 2018-02-14 18:05:02 +0100 | [diff] [blame] | 548 | "hypervisor":{"type":"string", "enum":["kvm","xen-unik","xenhvm"]}, #Unikernels extension |
| 549 | "osImageType":{"type":"string", "enum":["clickos","other"]}, #Unikernels extension |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 550 | "extended": extended_schema, |
| 551 | "networks":networks_schema |
| 552 | }, |
| 553 | "required": ["name","flavorRef","imageRef"] |
| 554 | } |
| 555 | }, |
| 556 | "required": ["server"], |
| 557 | "additionalProperties": False |
| 558 | } |
| 559 | |
| 560 | server_action_schema = { |
| 561 | "title":"server action information schema", |
| 562 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 563 | "type":"object", |
| 564 | "properties":{ |
| 565 | "start":{"oneOf":[{"type": "null"}, {"type":"string", "enum":["rebuild","null"] }]}, |
| 566 | "pause":{"type": "null"}, |
| 567 | "resume":{"type": "null"}, |
| 568 | "shutoff":{"type": "null"}, |
| 569 | "shutdown":{"type": "null"}, |
| 570 | "forceOff":{"type": "null"}, |
| 571 | "terminate":{"type": "null"}, |
| 572 | "createImage":{ |
| 573 | "type":"object", |
| 574 | "properties":{ |
| 575 | "path":path_schema, |
| 576 | "description":description_schema, |
| 577 | "name":name_schema, |
| 578 | "metadata":metadata_schema, |
| 579 | "imageRef": id_schema, |
| 580 | "disk": {"oneOf":[{"type": "null"}, {"type":"string"}] }, |
| 581 | }, |
| 582 | "required": ["name"] |
| 583 | }, |
| 584 | "rebuild":{"type": ["object","null"]}, |
| 585 | "reboot":{ |
| 586 | "type": ["object","null"], |
| 587 | # "properties": { |
| 588 | # "type":{"type":"string", "enum":["SOFT"] } |
| 589 | # }, |
| 590 | # "minProperties": 1, |
| 591 | # "maxProperties": 1, |
| 592 | # "additionalProperties": False |
| 593 | } |
| 594 | }, |
| 595 | "minProperties": 1, |
| 596 | "maxProperties": 1, |
| 597 | "additionalProperties": False |
| 598 | } |
| 599 | |
| 600 | network_new_schema = { |
| tierno | a290d8f | 2017-05-03 17:42:52 +0200 | [diff] [blame] | 601 | "title": "network creation information schema", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 602 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | a290d8f | 2017-05-03 17:42:52 +0200 | [diff] [blame] | 603 | "type": "object", |
| 604 | "properties": { |
| 605 | "network": { |
| 606 | "type": "object", |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 607 | "properties":{ |
| tierno | a290d8f | 2017-05-03 17:42:52 +0200 | [diff] [blame] | 608 | "id": id_schema, |
| 609 | "name": name_schema, |
| 610 | "type": {"type":"string", "enum": ["bridge_man", "bridge_data", "data", "ptp"]}, |
| 611 | "shared": {"type": "boolean"}, |
| 612 | "tenant_id": id_schema, |
| 613 | "admin_state_up": {"type": "boolean"}, |
| 614 | "provider:vlan": vlan_schema, |
| 615 | "provider:physical": net_bind_schema, |
| 616 | "region": nameshort_schema, |
| 617 | "cidr": cidr_schema, |
| 618 | "enable_dhcp": {"type": "boolean"}, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 619 | "dhcp_first_ip": ip_schema, |
| 620 | "dhcp_last_ip": ip_schema, |
| mirabal | 6878e3f | 2017-06-05 09:19:26 -0500 | [diff] [blame] | 621 | "dns": {"type": "array", "items": [ip_schema]}, |
| 622 | "links": {"type": "array", "items": {"type": "object", "properties": { |
| 623 | "nat": cidr_schema, |
| 624 | "iface": name_schema, |
| 625 | "vlan": vlan_schema}, |
| 626 | "required": ["iface"], |
| 627 | "additionalProperties": False |
| 628 | }, |
| 629 | |
| 630 | }, |
| 631 | "routes": {"type": "object", "properties": {"default": ip_schema}, "patternProperties": { |
| 632 | "^([0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$": ip_schema, |
| 633 | }, |
| 634 | "additionalProperties": False |
| 635 | }, |
| 636 | |
| tierno | a290d8f | 2017-05-03 17:42:52 +0200 | [diff] [blame] | 637 | "bind_net": name_schema, # can be name, or uuid |
| 638 | "bind_type": {"oneOf": [{"type": "null"}, {"type": "string", "pattern": "^vlan:[0-9]{1,4}$"}]} |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 639 | }, |
| mirabal | 6878e3f | 2017-06-05 09:19:26 -0500 | [diff] [blame] | 640 | "required": ["name"] |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 641 | } |
| 642 | }, |
| 643 | "required": ["network"], |
| 644 | "additionalProperties": False |
| 645 | } |
| mirabal | 9e19459 | 2017-02-17 11:03:25 +0100 | [diff] [blame] | 646 | |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 647 | network_update_schema = { |
| 648 | "title":"network update information schema", |
| 649 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 650 | "type":"object", |
| 651 | "properties":{ |
| 652 | "network":{ |
| 653 | "type":"object", |
| 654 | "properties":{ |
| 655 | "name":name_schema, |
| 656 | "type":{"type":"string", "enum":["bridge_man","bridge_data","data", "ptp"]}, |
| 657 | "shared":{"type":"boolean"}, |
| 658 | "tenant_id":id_schema, |
| 659 | "admin_state_up":{"type":"boolean"}, |
| 660 | "provider:vlan":vlan_schema, |
| 661 | "provider:physical":net_bind_schema, |
| 662 | "cidr":cidr_schema, |
| 663 | "enable_dhcp": {"type":"boolean"}, |
| Mirabal | e9317ff | 2017-01-18 16:10:58 +0000 | [diff] [blame] | 664 | # "dhcp_first_ip": ip_schema, |
| 665 | # "dhcp_last_ip": ip_schema, |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 666 | "bind_net":name_schema, #can be name, or uuid |
| 667 | "bind_type":{"oneOf":[{"type":"null"},{"type":"string", "pattern":"^vlan:[0-9]{1,4}$"}]} |
| 668 | }, |
| 669 | "minProperties": 1, |
| 670 | "additionalProperties": False |
| 671 | } |
| 672 | }, |
| 673 | "required": ["network"], |
| 674 | "additionalProperties": False |
| 675 | } |
| 676 | |
| 677 | |
| 678 | port_new_schema = { |
| 679 | "title":"port creation information schema", |
| 680 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 681 | "type":"object", |
| 682 | "properties":{ |
| 683 | "port":{ |
| 684 | "type":"object", |
| 685 | "properties":{ |
| 686 | "id":id_schema, |
| 687 | "name":nameshort_schema, |
| 688 | "network_id":{"oneOf":[{"type": "null"}, id_schema ]}, |
| 689 | "tenant_id":id_schema, |
| 690 | "mac_address": {"oneOf":[{"type": "null"}, mac_schema] }, |
| 691 | "admin_state_up":{"type":"boolean"}, |
| 692 | "bandwidth":bandwidth_schema, |
| 693 | "binding:switch_port":nameshort_schema, |
| 694 | "binding:vlan": {"oneOf":[{"type": "null"}, vlan_schema ]} |
| 695 | }, |
| 696 | "required": ["name"] |
| 697 | } |
| 698 | }, |
| 699 | "required": ["port"], |
| 700 | "additionalProperties": False |
| 701 | } |
| 702 | |
| 703 | port_update_schema = { |
| 704 | "title":"port update information schema", |
| 705 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 706 | "type":"object", |
| 707 | "properties":{ |
| 708 | "port":{ |
| 709 | "type":"object", |
| 710 | "properties":{ |
| 711 | "name":nameshort_schema, |
| 712 | "network_id":{"anyOf":[{"type":"null"}, id_schema ] } |
| 713 | }, |
| 714 | "minProperties": 1, |
| 715 | "additionalProperties": False |
| 716 | } |
| 717 | }, |
| 718 | "required": ["port"], |
| 719 | "additionalProperties": False |
| 720 | } |
| 721 | |
| 722 | localinfo_schema = { |
| 723 | "title":"localinfo information schema", |
| 724 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 725 | "type":"object", |
| 726 | "properties":{ |
| 727 | "files":{ "type": "object"}, |
| 728 | "inc_files":{ "type": "object"}, |
| 729 | "server_files":{ "type": "object"} |
| 730 | }, |
| 731 | "required": ["files"] |
| 732 | } |
| 733 | |
| 734 | hostinfo_schema = { |
| 735 | "title":"host information schema", |
| 736 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 737 | "type":"object", |
| 738 | "properties":{ |
| 739 | "iface_names":{ |
| 740 | "type":"object", |
| 741 | "patternProperties":{ |
| 742 | ".":{ "type": "string"} |
| 743 | }, |
| 744 | "minProperties": 1 |
| 745 | } |
| 746 | }, |
| 747 | "required": ["iface_names"] |
| 748 | } |
| mirabal | 9e19459 | 2017-02-17 11:03:25 +0100 | [diff] [blame] | 749 | |
| 750 | openflow_controller_schema = { |
| 751 | "title": "network creation information schema", |
| 752 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 753 | "type": "object", |
| 754 | "properties": { |
| 755 | "ofc": { |
| 756 | "type": "object", |
| 757 | "properties": { |
| 758 | "name": name_schema, |
| 759 | "dpid": nameshort_schema, |
| 760 | "ip": nameshort_schema, |
| 761 | "port": port_schema, |
| 762 | "type": nameshort_schema, |
| 763 | "version": nametiny_schema, |
| 764 | "user": nameshort_schema, |
| 765 | "password": nameshort_schema |
| 766 | }, |
| 767 | "required": ["dpid", "type", "ip", "port", "name"] |
| 768 | } |
| 769 | }, |
| 770 | "required": ["ofc"], |
| 771 | "additionalProperties": False |
| mirabal | 6045a9d | 2017-03-06 11:36:55 +0100 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | of_port_new_schema = { |
| 775 | "title": "OF port mapping", |
| 776 | "type": "object", |
| 777 | "properties": { |
| 778 | "ofc_id": id_schema, |
| 779 | "region": nameshort_schema, |
| 780 | "compute_node": nameshort_schema, |
| tierno | dcbf075 | 2019-01-23 10:22:30 +0000 | [diff] [blame] | 781 | "pci": {"OneOf": [{"type": "null"}, pci_extended_schema]}, |
| mirabal | 6045a9d | 2017-03-06 11:36:55 +0100 | [diff] [blame] | 782 | "switch_dpid": nameshort_schema, |
| 783 | "switch_port": nameshort_schema, |
| 784 | "switch_mac": mac_schema |
| 785 | }, |
| 786 | "required": ["region", "compute_node", "pci", "switch_dpid"] |
| 787 | } |
| 788 | |
| 789 | of_port_map_new_schema = { |
| 790 | "title": "OF port mapping", |
| 791 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 792 | "type": "object", |
| 793 | "properties": { |
| 794 | "of_port_mapings": {"type": "array", "items": of_port_new_schema, "minLenght":1}, |
| 795 | }, |
| 796 | "required": ["of_port_mapings"], |
| 797 | "additionalProperties": False |
| 798 | |
| garciadeblas | 1dd7eb2 | 2017-06-01 11:40:13 +0200 | [diff] [blame] | 799 | } |