| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2015 Telefónica Investigación 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 | |
| 34 | path_schema={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"} |
| 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 } #"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}$" |
| 45 | id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"} |
| 46 | pci_schema={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"} |
| 47 | bandwidth_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"} |
| 48 | integer0_schema={"type":"integer","minimum":0} |
| 49 | integer1_schema={"type":"integer","minimum":1} |
| 50 | vlan_schema={"type":"integer","minimum":1,"maximun":4095} |
| 51 | vlan1000_schema={"type":"integer","minimum":1000,"maximun":4095} |
| 52 | mac_schema={"type":"string", "pattern":"^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$"} #must be unicast LSB bit of MSB byte ==0 |
| 53 | net_bind_schema={"oneOf":[{"type":"null"},{"type":"string", "pattern":"^(default|((bridge|macvtap):[0-9a-zA-Z\.\-]{1,50})|openflow:[/0-9a-zA-Z\.\-]{1,50}(:vlan)?)$"}]} |
| 54 | yes_no_schema={"type":"string", "enum":["yes", "no"]} |
| 55 | log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]} |
| 56 | |
| 57 | config_schema = { |
| 58 | "title":"main configuration information schema", |
| 59 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 60 | "type":"object", |
| 61 | "properties":{ |
| 62 | "http_port": port_schema, |
| 63 | "http_admin_port": port_schema, |
| 64 | "http_host": nameshort_schema, |
| 65 | "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 |
| 66 | "db_host": nameshort_schema, |
| 67 | "db_user": nameshort_schema, |
| 68 | "db_passwd": {"type":"string"}, |
| 69 | "db_name": nameshort_schema, |
| 70 | "of_controller_ip": ip_schema, |
| 71 | "of_controller_port": port_schema, |
| 72 | "of_controller_dpid": nameshort_schema, |
| 73 | "of_controller_nets_with_same_vlan": {"type" : "boolean"}, |
| 74 | "of_controller": nameshort_schema, #{"type":"string", "enum":["floodlight", "opendaylight"]}, |
| 75 | "of_controller_module": {"type":"string"}, |
| 76 | #"of_user": nameshort_schema, |
| 77 | #"of_password": nameshort_schema, |
| 78 | "test_mode": {"type": "boolean"}, #leave for backward compatibility |
| 79 | "mode": {"type":"string", "enum":["normal", "host only", "OF only", "development", "test"] }, |
| 80 | "development_bridge": {"type":"string"}, |
| 81 | "tenant_id": {"type" : "string"}, |
| 82 | "image_path": path_schema, |
| 83 | "network_vlan_range_start": vlan_schema, |
| 84 | "network_vlan_range_end": vlan_schema, |
| 85 | "bridge_ifaces": { |
| 86 | "type": "object", |
| 87 | "patternProperties": { |
| 88 | "." : { |
| 89 | "type": "array", |
| 90 | "items": integer0_schema, |
| 91 | "minItems":2, |
| 92 | "maxItems":2, |
| 93 | }, |
| 94 | }, |
| 95 | "minProperties": 2 |
| 96 | }, |
| 97 | "dhcp_server": { |
| 98 | "type": "object", |
| 99 | "properties": { |
| 100 | "host" : name_schema, |
| 101 | "port" : port_schema, |
| 102 | "provider" : {"type": "string", "enum": ["isc-dhcp-server"]}, |
| 103 | "user" : nameshort_schema, |
| 104 | "password" : {"type": "string"}, |
| 105 | "key" : {"type": "string"}, |
| 106 | "bridge_ifaces" :{ |
| 107 | "type": "array", |
| 108 | "items": nameshort_schema, |
| 109 | }, |
| 110 | "nets" :{ |
| 111 | "type": "array", |
| 112 | "items": name_schema, |
| 113 | }, |
| 114 | }, |
| 115 | "required": ['host', 'provider', 'user'] |
| 116 | }, |
| 117 | "log_level": log_level_schema, |
| 118 | "log_level_db": log_level_schema, |
| 119 | "log_level_of": log_level_schema, |
| 120 | }, |
| 121 | "patternProperties": { |
| 122 | "of_*" : {"type": ["string", "integer", "boolean"]} |
| 123 | }, |
| 124 | "required": ['db_host', 'db_user', 'db_passwd', 'db_name', |
| 125 | 'of_controller_ip', 'of_controller_port', 'of_controller_dpid', 'bridge_ifaces', 'of_controller'], |
| 126 | "additionalProperties": False |
| 127 | } |
| 128 | |
| 129 | |
| 130 | |
| 131 | metadata_schema={ |
| 132 | "type":"object", |
| 133 | "properties":{ |
| 134 | "architecture": {"type":"string"}, |
| 135 | "use_incremental": yes_no_schema, |
| 136 | "vpci": pci_schema, |
| 137 | "os_distro": {"type":"string"}, |
| 138 | "os_type": {"type":"string"}, |
| 139 | "os_version": {"type":"string"}, |
| 140 | "bus": {"type":"string"}, |
| 141 | "topology": {"type":"string", "enum": ["oneSocket"]} |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | |
| 146 | |
| 147 | tenant_new_schema = { |
| 148 | "title":"tenant creation information schema", |
| 149 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 150 | "type":"object", |
| 151 | "properties":{ |
| 152 | "tenant":{ |
| 153 | "type":"object", |
| 154 | "properties":{ |
| 155 | "id":id_schema, |
| 156 | "name": nameshort_schema, |
| 157 | "description":description_schema, |
| 158 | "enabled":{"type" : "boolean"} |
| 159 | }, |
| 160 | "required": ["name"] |
| 161 | } |
| 162 | }, |
| 163 | "required": ["tenant"], |
| 164 | "additionalProperties": False |
| 165 | } |
| 166 | tenant_edit_schema = { |
| 167 | "title":"tenant edition information schema", |
| 168 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 169 | "type":"object", |
| 170 | "properties":{ |
| 171 | "tenant":{ |
| 172 | "type":"object", |
| 173 | "minProperties":1, |
| 174 | "properties":{ |
| 175 | "name":nameshort_schema, |
| 176 | "description":description_schema, |
| 177 | "enabled":{"type" : "boolean"} |
| 178 | }, |
| 179 | "additionalProperties": False, |
| 180 | } |
| 181 | }, |
| 182 | "required": ["tenant"], |
| 183 | "additionalProperties": False |
| 184 | } |
| 185 | interfaces_schema={ |
| 186 | "type":"array", |
| 187 | "minItems":0, |
| 188 | "items":{ |
| 189 | "type":"object", |
| 190 | "properties":{ |
| 191 | "name":name_schema, |
| 192 | "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]}, |
| 193 | "bandwidth":bandwidth_schema, |
| 194 | "vpci":pci_schema, |
| 195 | "uuid":id_schema, |
| 196 | "mac_address":mac_schema |
| 197 | }, |
| 198 | "additionalProperties": False, |
| 199 | "required": ["dedicated", "bandwidth"] |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | extended_schema={ |
| 204 | "type":"object", |
| 205 | "properties":{ |
| 206 | "processor_ranking":integer0_schema, |
| 207 | "devices":{ |
| 208 | "type": "array", |
| 209 | "items":{ |
| 210 | "type": "object", |
| 211 | "properties":{ |
| 212 | "type":{"type":"string", "enum":["usb","disk","cdrom","xml"]}, |
| 213 | "vpci":pci_schema, |
| 214 | "imageRef":id_schema, |
| 215 | "xml":xml_text_schema, |
| 216 | "dev":nameshort_schema |
| 217 | }, |
| 218 | "additionalProperties": False, |
| 219 | "required": ["type"] |
| 220 | } |
| 221 | }, |
| 222 | "numas":{ |
| 223 | "type": "array", |
| 224 | "items":{ |
| 225 | "type": "object", |
| 226 | "properties":{ |
| 227 | "memory":integer1_schema, |
| 228 | "cores":integer1_schema, |
| 229 | "paired-threads":integer1_schema, |
| 230 | "threads":integer1_schema, |
| 231 | "cores-id":{"type":"array","items":integer0_schema}, |
| 232 | "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}}, |
| 233 | "threads-id":{"type":"array","items":integer0_schema}, |
| 234 | "interfaces":interfaces_schema |
| 235 | }, |
| 236 | "additionalProperties": False, |
| 237 | "minProperties": 1, |
| 238 | #"required": ["memory"] |
| 239 | } |
| 240 | } |
| 241 | }, |
| 242 | #"additionalProperties": False, |
| 243 | #"required": ["processor_ranking"] |
| 244 | } |
| 245 | |
| 246 | host_data_schema={ |
| 247 | "title":"hosts manual insertion information schema", |
| 248 | "type":"object", |
| 249 | "properties":{ |
| 250 | "ip_name":nameshort_schema, |
| 251 | "name": name_schema, |
| 252 | "description":description_schema, |
| 253 | "user":nameshort_schema, |
| 254 | "password":nameshort_schema, |
| 255 | "features":description_schema, |
| 256 | "ranking":integer0_schema, |
| 257 | "devices":{ |
| 258 | "type": "array", |
| 259 | "items":{ |
| 260 | "type": "object", |
| 261 | "properties":{ |
| 262 | "type":{"type":"string", "enum":["usb","disk"]}, |
| 263 | "vpci":pci_schema |
| 264 | }, |
| 265 | "additionalProperties": False, |
| 266 | "required": ["type"] |
| 267 | } |
| 268 | }, |
| 269 | "numas":{ |
| 270 | "type": "array", |
| 271 | "minItems":1, |
| 272 | "items":{ |
| 273 | "type": "object", |
| 274 | "properties":{ |
| 275 | "admin_state_up":{"type":"boolean"}, |
| 276 | "hugepages":integer1_schema, |
| 277 | "cores":{ |
| 278 | "type": "array", |
| 279 | "minItems":2, |
| 280 | "items":{ |
| 281 | "type": "object", |
| 282 | "properties":{ |
| 283 | "core_id":integer0_schema, |
| 284 | "thread_id":integer0_schema, |
| 285 | "status": {"type":"string", "enum":["noteligible"]} |
| 286 | }, |
| 287 | "additionalProperties": False, |
| 288 | "required": ["core_id","thread_id"] |
| 289 | } |
| 290 | }, |
| 291 | "interfaces":{ |
| 292 | "type": "array", |
| 293 | "minItems":1, |
| 294 | "items":{ |
| 295 | "type": "object", |
| 296 | "properties":{ |
| 297 | "source_name":nameshort_schema, |
| 298 | "mac":mac_schema, |
| 299 | "Mbps":integer0_schema, |
| 300 | "pci":pci_schema, |
| 301 | "sriovs":{ |
| 302 | "type": "array", |
| 303 | "minItems":1, |
| 304 | "items":{ |
| 305 | "type": "object", |
| 306 | "properties":{ |
| 307 | "source_name":{"oneOf":[integer0_schema, nameshort_schema]}, |
| 308 | "mac":mac_schema, |
| 309 | "vlan":integer0_schema, |
| 310 | "pci":pci_schema, |
| 311 | }, |
| 312 | "additionalProperties": False, |
| 313 | "required": ["source_name","mac","pci"] |
| 314 | } |
| 315 | }, |
| 316 | "switch_port": nameshort_schema, |
| 317 | "switch_dpid": nameshort_schema, |
| 318 | }, |
| 319 | "additionalProperties": False, |
| 320 | "required": ["source_name","mac","Mbps","pci"] |
| 321 | } |
| 322 | }, |
| 323 | "numa_socket":integer0_schema, |
| 324 | "memory":integer1_schema |
| 325 | }, |
| 326 | "additionalProperties": False, |
| 327 | "required": ["hugepages","cores","numa_socket"] |
| 328 | } |
| 329 | } |
| 330 | }, |
| 331 | "additionalProperties": False, |
| 332 | "required": ["ranking", "numas","ip_name","user"] |
| 333 | } |
| 334 | |
| 335 | host_edit_schema={ |
| 336 | "title":"hosts creation information schema", |
| 337 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 338 | "type":"object", |
| 339 | "properties":{ |
| 340 | "host":{ |
| 341 | "type":"object", |
| 342 | "properties":{ |
| 343 | "ip_name":nameshort_schema, |
| 344 | "name": name_schema, |
| 345 | "description":description_schema, |
| 346 | "user":nameshort_schema, |
| 347 | "password":nameshort_schema, |
| 348 | "admin_state_up":{"type":"boolean"}, |
| 349 | "numas":{ |
| 350 | "type":"array", |
| 351 | "items":{ |
| 352 | "type": "object", |
| 353 | "properties":{ |
| 354 | "numa_socket": integer0_schema, |
| 355 | "admin_state_up":{"type":"boolean"}, |
| 356 | "interfaces":{ |
| 357 | "type":"array", |
| 358 | "items":{ |
| 359 | "type": "object", |
| 360 | "properties":{ |
| 361 | "source_name": nameshort_schema, |
| 362 | "switch_dpid": nameshort_schema, |
| 363 | "switch_port": nameshort_schema, |
| 364 | }, |
| 365 | "required": ["source_name"], |
| 366 | } |
| 367 | } |
| 368 | }, |
| 369 | "required": ["numa_socket"], |
| 370 | "additionalProperties": False, |
| 371 | } |
| 372 | } |
| 373 | }, |
| 374 | "minProperties": 1, |
| 375 | "additionalProperties": False |
| 376 | }, |
| 377 | }, |
| 378 | "required": ["host"], |
| 379 | "minProperties": 1, |
| 380 | "additionalProperties": False |
| 381 | } |
| 382 | |
| 383 | host_new_schema = { |
| 384 | "title":"hosts creation information schema", |
| 385 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 386 | "type":"object", |
| 387 | "properties":{ |
| 388 | "host":{ |
| 389 | "type":"object", |
| 390 | "properties":{ |
| 391 | "id":id_schema, |
| 392 | "ip_name":nameshort_schema, |
| 393 | "name": name_schema, |
| 394 | "description":description_schema, |
| 395 | "user":nameshort_schema, |
| 396 | "password":nameshort_schema, |
| 397 | "admin_state_up":{"type":"boolean"}, |
| 398 | }, |
| 399 | "required": ["name","ip_name","user"] |
| 400 | }, |
| 401 | "host-data":host_data_schema |
| 402 | }, |
| 403 | "required": ["host"], |
| 404 | "minProperties": 1, |
| 405 | "maxProperties": 2, |
| 406 | "additionalProperties": False |
| 407 | } |
| 408 | |
| 409 | |
| 410 | flavor_new_schema = { |
| 411 | "title":"flavor creation information schema", |
| 412 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 413 | "type":"object", |
| 414 | "properties":{ |
| 415 | "flavor":{ |
| 416 | "type":"object", |
| 417 | "properties":{ |
| 418 | "id":id_schema, |
| 419 | "name":name_schema, |
| 420 | "description":description_schema, |
| 421 | "ram":integer0_schema, |
| 422 | "vcpus":integer0_schema, |
| 423 | "extended": extended_schema, |
| 424 | "public": yes_no_schema |
| 425 | }, |
| 426 | "required": ["name"] |
| 427 | } |
| 428 | }, |
| 429 | "required": ["flavor"], |
| 430 | "additionalProperties": False |
| 431 | } |
| 432 | flavor_update_schema = { |
| 433 | "title":"flavor update information schema", |
| 434 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 435 | "type":"object", |
| 436 | "properties":{ |
| 437 | "flavor":{ |
| 438 | "type":"object", |
| 439 | "properties":{ |
| 440 | "name":name_schema, |
| 441 | "description":description_schema, |
| 442 | "ram":integer0_schema, |
| 443 | "vcpus":integer0_schema, |
| 444 | "extended": extended_schema, |
| 445 | "public": yes_no_schema |
| 446 | }, |
| 447 | "minProperties": 1, |
| 448 | "additionalProperties": False |
| 449 | } |
| 450 | }, |
| 451 | "required": ["flavor"], |
| 452 | "additionalProperties": False |
| 453 | } |
| 454 | |
| 455 | image_new_schema = { |
| 456 | "title":"image creation information schema", |
| 457 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 458 | "type":"object", |
| 459 | "properties":{ |
| 460 | "image":{ |
| 461 | "type":"object", |
| 462 | "properties":{ |
| 463 | "id":id_schema, |
| 464 | "path": {"oneOf": [path_schema, http_schema]}, |
| 465 | "description":description_schema, |
| 466 | "name":name_schema, |
| 467 | "metadata":metadata_schema, |
| 468 | "public": yes_no_schema |
| 469 | }, |
| 470 | "required": ["name","path"] |
| 471 | } |
| 472 | }, |
| 473 | "required": ["image"], |
| 474 | "additionalProperties": False |
| 475 | } |
| 476 | |
| 477 | image_update_schema = { |
| 478 | "title":"image update information schema", |
| 479 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 480 | "type":"object", |
| 481 | "properties":{ |
| 482 | "image":{ |
| 483 | "type":"object", |
| 484 | "properties":{ |
| 485 | "path":{"oneOf": [path_schema, http_schema]}, |
| 486 | "description":description_schema, |
| 487 | "name":name_schema, |
| 488 | "metadata":metadata_schema, |
| 489 | "public": yes_no_schema |
| 490 | }, |
| 491 | "minProperties": 1, |
| 492 | "additionalProperties": False |
| 493 | } |
| 494 | }, |
| 495 | "required": ["image"], |
| 496 | "additionalProperties": False |
| 497 | } |
| 498 | |
| 499 | networks_schema={ |
| 500 | "type":"array", |
| 501 | "items":{ |
| 502 | "type":"object", |
| 503 | "properties":{ |
| 504 | "name":name_schema, |
| 505 | "bandwidth":bandwidth_schema, |
| 506 | "vpci":pci_schema, |
| 507 | "uuid":id_schema, |
| 508 | "mac_address": mac_schema, |
| 509 | "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}, |
| 510 | "type": {"type":"string", "enum":["virtual","PF","VF","VFnotShared"]} |
| 511 | }, |
| 512 | "additionalProperties": False, |
| 513 | "required": ["uuid"] |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | server_new_schema = { |
| 518 | "title":"server creation information schema", |
| 519 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 520 | "type":"object", |
| 521 | "properties":{ |
| 522 | "server":{ |
| 523 | "type":"object", |
| 524 | "properties":{ |
| 525 | "id":id_schema, |
| 526 | "name":name_schema, |
| 527 | "description":description_schema, |
| 528 | "start":{"type":"string", "enum":["yes","no","paused"]}, |
| 529 | "hostId":id_schema, |
| 530 | "flavorRef":id_schema, |
| 531 | "imageRef":id_schema, |
| 532 | "extended": extended_schema, |
| 533 | "networks":networks_schema |
| 534 | }, |
| 535 | "required": ["name","flavorRef","imageRef"] |
| 536 | } |
| 537 | }, |
| 538 | "required": ["server"], |
| 539 | "additionalProperties": False |
| 540 | } |
| 541 | |
| 542 | server_action_schema = { |
| 543 | "title":"server action information schema", |
| 544 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 545 | "type":"object", |
| 546 | "properties":{ |
| 547 | "start":{"oneOf":[{"type": "null"}, {"type":"string", "enum":["rebuild","null"] }]}, |
| 548 | "pause":{"type": "null"}, |
| 549 | "resume":{"type": "null"}, |
| 550 | "shutoff":{"type": "null"}, |
| 551 | "shutdown":{"type": "null"}, |
| 552 | "forceOff":{"type": "null"}, |
| 553 | "terminate":{"type": "null"}, |
| 554 | "createImage":{ |
| 555 | "type":"object", |
| 556 | "properties":{ |
| 557 | "path":path_schema, |
| 558 | "description":description_schema, |
| 559 | "name":name_schema, |
| 560 | "metadata":metadata_schema, |
| 561 | "imageRef": id_schema, |
| 562 | "disk": {"oneOf":[{"type": "null"}, {"type":"string"}] }, |
| 563 | }, |
| 564 | "required": ["name"] |
| 565 | }, |
| 566 | "rebuild":{"type": ["object","null"]}, |
| 567 | "reboot":{ |
| 568 | "type": ["object","null"], |
| 569 | # "properties": { |
| 570 | # "type":{"type":"string", "enum":["SOFT"] } |
| 571 | # }, |
| 572 | # "minProperties": 1, |
| 573 | # "maxProperties": 1, |
| 574 | # "additionalProperties": False |
| 575 | } |
| 576 | }, |
| 577 | "minProperties": 1, |
| 578 | "maxProperties": 1, |
| 579 | "additionalProperties": False |
| 580 | } |
| 581 | |
| 582 | network_new_schema = { |
| 583 | "title":"network creation information schema", |
| 584 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 585 | "type":"object", |
| 586 | "properties":{ |
| 587 | "network":{ |
| 588 | "type":"object", |
| 589 | "properties":{ |
| 590 | "id":id_schema, |
| 591 | "name":name_schema, |
| 592 | "type":{"type":"string", "enum":["bridge_man","bridge_data","data", "ptp"]}, |
| 593 | "shared":{"type":"boolean"}, |
| 594 | "tenant_id":id_schema, |
| 595 | "admin_state_up":{"type":"boolean"}, |
| 596 | "provider:vlan":vlan_schema, |
| 597 | "provider:physical":net_bind_schema, |
| 598 | "cidr":cidr_schema, |
| 599 | "enable_dhcp": {"type":"boolean"}, |
| 600 | "dhcp_first_ip": ip_schema, |
| 601 | "dhcp_last_ip": ip_schema, |
| 602 | "bind_net":name_schema, #can be name, or uuid |
| 603 | "bind_type":{"oneOf":[{"type":"null"},{"type":"string", "pattern":"^vlan:[0-9]{1,4}$"}]} |
| 604 | }, |
| 605 | "required": ["name"] |
| 606 | } |
| 607 | }, |
| 608 | "required": ["network"], |
| 609 | "additionalProperties": False |
| 610 | } |
| 611 | network_update_schema = { |
| 612 | "title":"network update information schema", |
| 613 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 614 | "type":"object", |
| 615 | "properties":{ |
| 616 | "network":{ |
| 617 | "type":"object", |
| 618 | "properties":{ |
| 619 | "name":name_schema, |
| 620 | "type":{"type":"string", "enum":["bridge_man","bridge_data","data", "ptp"]}, |
| 621 | "shared":{"type":"boolean"}, |
| 622 | "tenant_id":id_schema, |
| 623 | "admin_state_up":{"type":"boolean"}, |
| 624 | "provider:vlan":vlan_schema, |
| 625 | "provider:physical":net_bind_schema, |
| 626 | "cidr":cidr_schema, |
| 627 | "enable_dhcp": {"type":"boolean"}, |
| 628 | "dhcp_first_ip": ip_schema, |
| 629 | "dhcp_last_ip": ip_schema, |
| 630 | "bind_net":name_schema, #can be name, or uuid |
| 631 | "bind_type":{"oneOf":[{"type":"null"},{"type":"string", "pattern":"^vlan:[0-9]{1,4}$"}]} |
| 632 | }, |
| 633 | "minProperties": 1, |
| 634 | "additionalProperties": False |
| 635 | } |
| 636 | }, |
| 637 | "required": ["network"], |
| 638 | "additionalProperties": False |
| 639 | } |
| 640 | |
| 641 | |
| 642 | port_new_schema = { |
| 643 | "title":"port creation information schema", |
| 644 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 645 | "type":"object", |
| 646 | "properties":{ |
| 647 | "port":{ |
| 648 | "type":"object", |
| 649 | "properties":{ |
| 650 | "id":id_schema, |
| 651 | "name":nameshort_schema, |
| 652 | "network_id":{"oneOf":[{"type": "null"}, id_schema ]}, |
| 653 | "tenant_id":id_schema, |
| 654 | "mac_address": {"oneOf":[{"type": "null"}, mac_schema] }, |
| 655 | "admin_state_up":{"type":"boolean"}, |
| 656 | "bandwidth":bandwidth_schema, |
| 657 | "binding:switch_port":nameshort_schema, |
| 658 | "binding:vlan": {"oneOf":[{"type": "null"}, vlan_schema ]} |
| 659 | }, |
| 660 | "required": ["name"] |
| 661 | } |
| 662 | }, |
| 663 | "required": ["port"], |
| 664 | "additionalProperties": False |
| 665 | } |
| 666 | |
| 667 | port_update_schema = { |
| 668 | "title":"port update information schema", |
| 669 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 670 | "type":"object", |
| 671 | "properties":{ |
| 672 | "port":{ |
| 673 | "type":"object", |
| 674 | "properties":{ |
| 675 | "name":nameshort_schema, |
| 676 | "network_id":{"anyOf":[{"type":"null"}, id_schema ] } |
| 677 | }, |
| 678 | "minProperties": 1, |
| 679 | "additionalProperties": False |
| 680 | } |
| 681 | }, |
| 682 | "required": ["port"], |
| 683 | "additionalProperties": False |
| 684 | } |
| 685 | |
| 686 | localinfo_schema = { |
| 687 | "title":"localinfo information schema", |
| 688 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 689 | "type":"object", |
| 690 | "properties":{ |
| 691 | "files":{ "type": "object"}, |
| 692 | "inc_files":{ "type": "object"}, |
| 693 | "server_files":{ "type": "object"} |
| 694 | }, |
| 695 | "required": ["files"] |
| 696 | } |
| 697 | |
| 698 | hostinfo_schema = { |
| 699 | "title":"host information schema", |
| 700 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 701 | "type":"object", |
| 702 | "properties":{ |
| 703 | "iface_names":{ |
| 704 | "type":"object", |
| 705 | "patternProperties":{ |
| 706 | ".":{ "type": "string"} |
| 707 | }, |
| 708 | "minProperties": 1 |
| 709 | } |
| 710 | }, |
| 711 | "required": ["iface_names"] |
| 712 | } |