blob: 697b4e95bda19662960d2275810953fcae880b75 [file] [log] [blame]
tiernof7aa8c42016-09-06 16:43:04 +02001# -*- coding: utf-8 -*-
2
3##
4# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
tierno9a61c6b2016-09-08 10:57:02 +02005# This file is part of openvim
tiernof7aa8c42016-09-06 16:43:04 +02006# 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
tiernoa6933042017-05-24 16:54:33 +020034path_schema = {"type": "string", "maxLength": 255, "pattern": "^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
tierno338e9982017-09-08 12:44:15 +020035http_schema = {"type": "string", "pattern": "^https?://[^'\"=]+$"}
36port_schema = {"type": "integer","minimum": 1, "maximun": 65534}
37ip_schema = {"type": "string", "pattern": "^([0-9]{1,3}.){3}[0-9]{1,3}$"}
38cidr_schema = {"type": "string", "pattern": "^([0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$"}
39name_schema = {"type": "string", "minLength": 1, "maxLength": 255, "pattern": "^[^,;()'\"]+$"}
40nameshort_schema = {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[^,;()'\"]+$"}
41nametiny_schema = {"type": "string", "minLength": 1, "maxLength": 12, "pattern": "^[^,;()'\"]+$"}
42xml_text_schema = {"type": "string", "minLength": 1, "maxLength": 1000, "pattern": "^[^']+$"}
43description_schema = {"type": ["string", "null"], "maxLength": 255, "pattern": "^[^'\"]+$"}
44id_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}$"
46id_schema = {"type": "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
47pci_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>
49pci_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})?$"}
51bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"}
52integer0_schema = {"type": "integer", "minimum": 0}
53integer1_schema = {"type": "integer", "minimum": 1}
54vlan_schema = {"type": "integer", "minimum": 1, "maximun": 4095}
55vlan1000_schema = {"type": "integer", "minimum": 1000, "maximun": 4095}
56mac_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
58net_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]}
63yes_no_schema = {"type": "string", "enum": ["yes", "no"]}
64log_level_schema = {"type": "string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
tiernof7aa8c42016-09-06 16:43:04 +020065
66config_schema = {
tiernoa6933042017-05-24 16:54:33 +020067 "title": "main configuration information schema",
tiernof7aa8c42016-09-06 16:43:04 +020068 "$schema": "http://json-schema.org/draft-04/schema#",
tiernoa6933042017-05-24 16:54:33 +020069 "type": "object",
tiernof7aa8c42016-09-06 16:43:04 +020070 "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,
tiernoa6933042017-05-24 16:54:33 +020077 "db_passwd": {"type": "string"},
tiernof7aa8c42016-09-06 16:43:04 +020078 "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"},
mirabal580435e2017-03-01 16:17:10 +010085 "of_user": nameshort_schema,
86 "of_password": nameshort_schema,
tiernoa6933042017-05-24 16:54:33 +020087 "test_mode": {"type": "boolean"}, # leave for backward compatibility
tiernof7aa8c42016-09-06 16:43:04 +020088 "mode": {"type":"string", "enum":["normal", "host only", "OF only", "development", "test"] },
89 "development_bridge": {"type":"string"},
90 "tenant_id": {"type" : "string"},
tiernoa6933042017-05-24 16:54:33 +020091 "image_path": path_schema, # leave for backward compatibility
92 "host_image_path": path_schema,
93 "host_ssh_keyfile": path_schema,
tiernof7aa8c42016-09-06 16:43:04 +020094 "network_vlan_range_start": vlan_schema,
95 "network_vlan_range_end": vlan_schema,
96 "bridge_ifaces": {
97 "type": "object",
98 "patternProperties": {
99 "." : {
tiernoa6933042017-05-24 16:54:33 +0200100 "type": "array",
tiernof7aa8c42016-09-06 16:43:04 +0200101 "items": integer0_schema,
102 "minItems":2,
103 "maxItems":2,
104 },
105 },
106 "minProperties": 2
107 },
108 "dhcp_server": {
109 "type": "object",
110 "properties": {
tiernoa6933042017-05-24 16:54:33 +0200111 "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",
tiernof7aa8c42016-09-06 16:43:04 +0200120 "items": nameshort_schema,
121 },
tiernoa6933042017-05-24 16:54:33 +0200122 "nets": {
123 "type": "array",
tiernof7aa8c42016-09-06 16:43:04 +0200124 "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,
Mirabal7256d6b2016-12-15 10:51:19 +0000132 "network_type": {"type": "string", "enum": ["ovs", "bridge"]},
Mirabale9317ff2017-01-18 16:10:58 +0000133 "ovs_controller_file_path": path_schema,
tiernoa6933042017-05-24 16:54:33 +0200134 "ovs_controller_ip": nameshort_schema,
Mirabale9317ff2017-01-18 16:10:58 +0000135 "ovs_controller_user": nameshort_schema,
tiernoa6933042017-05-24 16:54:33 +0200136 "ovs_controller_password": {"type": "string"},
137 "ovs_controller_keyfile": path_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200138 },
139 "patternProperties": {
140 "of_*" : {"type": ["string", "integer", "boolean"]}
141 },
mirabal580435e2017-03-01 16:17:10 +0100142 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
tiernof7aa8c42016-09-06 16:43:04 +0200143 "additionalProperties": False
144}
145
146
147
148metadata_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"},
garciadeblas1dd7eb22017-06-01 11:40:13 +0200158 "topology": {"type":"string", "enum": ["oneSocket", "oneSocket:hyperthreading"]}
tiernof7aa8c42016-09-06 16:43:04 +0200159 }
160}
161
tiernof7aa8c42016-09-06 16:43:04 +0200162tenant_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}
mirabal6045a9d2017-03-06 11:36:55 +0100181
tiernof7aa8c42016-09-06 16:43:04 +0200182tenant_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}
201interfaces_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
219extended_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,
mirabalcaeb2242017-05-31 10:52:22 -0500232 "dev":nameshort_schema,
233 "size":integer1_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200234 },
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
263host_data_schema={
264 "title":"hosts manual insertion information schema",
265 "type":"object",
tiernoa6933042017-05-24 16:54:33 +0200266 "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,
tiernof7aa8c42016-09-06 16:43:04 +0200271 "name": name_schema,
tiernoa6933042017-05-24 16:54:33 +0200272 "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
279 "devices": {
tiernof7aa8c42016-09-06 16:43:04 +0200280 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200281 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200282 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200283 "properties": {
284 "type": {"type": "string", "enum": ["usb", "disk"]},
285 "vpci": pci_schema
tiernof7aa8c42016-09-06 16:43:04 +0200286 },
287 "additionalProperties": False,
288 "required": ["type"]
289 }
290 },
tiernoa6933042017-05-24 16:54:33 +0200291 "numas": {
tiernof7aa8c42016-09-06 16:43:04 +0200292 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200293 "minItems": 1,
294 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200295 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200296 "properties": {
297 "admin_state_up": {"type": "boolean"},
298 "hugepages": integer0_schema,
299 "hugepages_consumed": integer0_schema, # ignored, just for compatibility with host-list
300 "numa_socket": integer0_schema,
301 "memory": integer1_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200302 "cores":{
303 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200304 "minItems": 2,
305 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200306 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200307 "properties": {
308 "core_id": integer0_schema,
309 "thread_id": integer0_schema,
tiernoc67abe22017-07-03 17:04:54 +0200310 "status": {"type": "string", "enum": ["noteligible"]},
311 "instance_id": {"type": "string"}, # ignored, just for compatibility with host-list
312 "v_thread_id": {"type": "integer"} # ignored, just for compatibility with host-list
tiernof7aa8c42016-09-06 16:43:04 +0200313 },
314 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200315 "required": ["core_id", "thread_id"]
tiernof7aa8c42016-09-06 16:43:04 +0200316 }
317 },
tiernoa6933042017-05-24 16:54:33 +0200318 "interfaces": {
tiernof7aa8c42016-09-06 16:43:04 +0200319 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200320 "minItems": 1,
321 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200322 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200323 "properties": {
324 "source_name": nameshort_schema,
325 "mac": mac_schema,
326 "Mbps": integer0_schema,
327 "pci": pci_schema,
328 "sriovs": {
tiernof7aa8c42016-09-06 16:43:04 +0200329 "type": "array",
330 "minItems":1,
tiernoa6933042017-05-24 16:54:33 +0200331 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200332 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200333 "properties": {
334 "source_name": {"oneOf": [integer0_schema, nameshort_schema]},
335 "mac": mac_schema,
336 "vlan": integer0_schema, # ignored, just for backward compatibility
337 "pci": pci_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200338 },
339 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200340 "required": ["source_name", "mac", "pci"]
tiernof7aa8c42016-09-06 16:43:04 +0200341 }
342 },
343 "switch_port": nameshort_schema,
344 "switch_dpid": nameshort_schema,
tiernoa6933042017-05-24 16:54:33 +0200345 "switch_mac": mac_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200346 },
347 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200348 "required": ["source_name", "mac", "Mbps", "pci"]
tiernof7aa8c42016-09-06 16:43:04 +0200349 }
350 },
tiernof7aa8c42016-09-06 16:43:04 +0200351 },
352 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200353 "required": ["cores", "numa_socket"]
tiernof7aa8c42016-09-06 16:43:04 +0200354 }
355 }
356 },
357 "additionalProperties": False,
tiernoc67abe22017-07-03 17:04:54 +0200358 "required": ["name", "user", "ip_name"]
tiernof7aa8c42016-09-06 16:43:04 +0200359}
360
361host_edit_schema={
362 "title":"hosts creation information schema",
363 "$schema": "http://json-schema.org/draft-04/schema#",
364 "type":"object",
365 "properties":{
366 "host":{
367 "type":"object",
368 "properties":{
369 "ip_name":nameshort_schema,
370 "name": name_schema,
371 "description":description_schema,
372 "user":nameshort_schema,
373 "password":nameshort_schema,
374 "admin_state_up":{"type":"boolean"},
375 "numas":{
376 "type":"array",
377 "items":{
378 "type": "object",
379 "properties":{
380 "numa_socket": integer0_schema,
381 "admin_state_up":{"type":"boolean"},
382 "interfaces":{
383 "type":"array",
384 "items":{
385 "type": "object",
386 "properties":{
387 "source_name": nameshort_schema,
388 "switch_dpid": nameshort_schema,
389 "switch_port": nameshort_schema,
390 },
391 "required": ["source_name"],
392 }
393 }
394 },
395 "required": ["numa_socket"],
396 "additionalProperties": False,
397 }
398 }
399 },
400 "minProperties": 1,
401 "additionalProperties": False
402 },
403 },
404 "required": ["host"],
405 "minProperties": 1,
406 "additionalProperties": False
407}
408
409host_new_schema = {
410 "title":"hosts creation information schema",
411 "$schema": "http://json-schema.org/draft-04/schema#",
412 "type":"object",
413 "properties":{
tiernoa6933042017-05-24 16:54:33 +0200414 "host": host_data_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200415 "host-data":host_data_schema
416 },
417 "required": ["host"],
418 "minProperties": 1,
419 "maxProperties": 2,
420 "additionalProperties": False
421}
422
423
424flavor_new_schema = {
425 "title":"flavor creation information schema",
426 "$schema": "http://json-schema.org/draft-04/schema#",
427 "type":"object",
428 "properties":{
429 "flavor":{
430 "type":"object",
431 "properties":{
432 "id":id_schema,
433 "name":name_schema,
434 "description":description_schema,
435 "ram":integer0_schema,
436 "vcpus":integer0_schema,
437 "extended": extended_schema,
438 "public": yes_no_schema
439 },
440 "required": ["name"]
441 }
442 },
443 "required": ["flavor"],
444 "additionalProperties": False
445}
446flavor_update_schema = {
447 "title":"flavor update information schema",
448 "$schema": "http://json-schema.org/draft-04/schema#",
449 "type":"object",
450 "properties":{
451 "flavor":{
452 "type":"object",
453 "properties":{
454 "name":name_schema,
455 "description":description_schema,
456 "ram":integer0_schema,
457 "vcpus":integer0_schema,
458 "extended": extended_schema,
459 "public": yes_no_schema
460 },
461 "minProperties": 1,
462 "additionalProperties": False
463 }
464 },
465 "required": ["flavor"],
466 "additionalProperties": False
467}
468
469image_new_schema = {
470 "title":"image creation information schema",
471 "$schema": "http://json-schema.org/draft-04/schema#",
472 "type":"object",
473 "properties":{
474 "image":{
475 "type":"object",
476 "properties":{
477 "id":id_schema,
478 "path": {"oneOf": [path_schema, http_schema]},
479 "description":description_schema,
480 "name":name_schema,
481 "metadata":metadata_schema,
482 "public": yes_no_schema
483 },
484 "required": ["name","path"]
485 }
486 },
487 "required": ["image"],
488 "additionalProperties": False
489}
490
491image_update_schema = {
492 "title":"image update information schema",
493 "$schema": "http://json-schema.org/draft-04/schema#",
494 "type":"object",
495 "properties":{
496 "image":{
497 "type":"object",
498 "properties":{
499 "path":{"oneOf": [path_schema, http_schema]},
500 "description":description_schema,
501 "name":name_schema,
502 "metadata":metadata_schema,
503 "public": yes_no_schema
504 },
505 "minProperties": 1,
506 "additionalProperties": False
507 }
508 },
509 "required": ["image"],
510 "additionalProperties": False
511}
512
513networks_schema={
514 "type":"array",
515 "items":{
516 "type":"object",
517 "properties":{
518 "name":name_schema,
519 "bandwidth":bandwidth_schema,
520 "vpci":pci_schema,
521 "uuid":id_schema,
522 "mac_address": mac_schema,
523 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]},
524 "type": {"type":"string", "enum":["virtual","PF","VF","VFnotShared"]}
525 },
526 "additionalProperties": False,
527 "required": ["uuid"]
528 }
529}
530
531server_new_schema = {
532 "title":"server creation information schema",
533 "$schema": "http://json-schema.org/draft-04/schema#",
534 "type":"object",
535 "properties":{
536 "server":{
537 "type":"object",
538 "properties":{
539 "id":id_schema,
540 "name":name_schema,
541 "description":description_schema,
542 "start":{"type":"string", "enum":["yes","no","paused"]},
543 "hostId":id_schema,
544 "flavorRef":id_schema,
545 "imageRef":id_schema,
546 "extended": extended_schema,
547 "networks":networks_schema
548 },
549 "required": ["name","flavorRef","imageRef"]
550 }
551 },
552 "required": ["server"],
553 "additionalProperties": False
554}
555
556server_action_schema = {
557 "title":"server action information schema",
558 "$schema": "http://json-schema.org/draft-04/schema#",
559 "type":"object",
560 "properties":{
561 "start":{"oneOf":[{"type": "null"}, {"type":"string", "enum":["rebuild","null"] }]},
562 "pause":{"type": "null"},
563 "resume":{"type": "null"},
564 "shutoff":{"type": "null"},
565 "shutdown":{"type": "null"},
566 "forceOff":{"type": "null"},
567 "terminate":{"type": "null"},
568 "createImage":{
569 "type":"object",
570 "properties":{
571 "path":path_schema,
572 "description":description_schema,
573 "name":name_schema,
574 "metadata":metadata_schema,
575 "imageRef": id_schema,
576 "disk": {"oneOf":[{"type": "null"}, {"type":"string"}] },
577 },
578 "required": ["name"]
579 },
580 "rebuild":{"type": ["object","null"]},
581 "reboot":{
582 "type": ["object","null"],
583# "properties": {
584# "type":{"type":"string", "enum":["SOFT"] }
585# },
586# "minProperties": 1,
587# "maxProperties": 1,
588# "additionalProperties": False
589 }
590 },
591 "minProperties": 1,
592 "maxProperties": 1,
593 "additionalProperties": False
594}
595
596network_new_schema = {
tiernoa290d8f2017-05-03 17:42:52 +0200597 "title": "network creation information schema",
tiernof7aa8c42016-09-06 16:43:04 +0200598 "$schema": "http://json-schema.org/draft-04/schema#",
tiernoa290d8f2017-05-03 17:42:52 +0200599 "type": "object",
600 "properties": {
601 "network": {
602 "type": "object",
tiernof7aa8c42016-09-06 16:43:04 +0200603 "properties":{
tiernoa290d8f2017-05-03 17:42:52 +0200604 "id": id_schema,
605 "name": name_schema,
606 "type": {"type":"string", "enum": ["bridge_man", "bridge_data", "data", "ptp"]},
607 "shared": {"type": "boolean"},
608 "tenant_id": id_schema,
609 "admin_state_up": {"type": "boolean"},
610 "provider:vlan": vlan_schema,
611 "provider:physical": net_bind_schema,
612 "region": nameshort_schema,
613 "cidr": cidr_schema,
614 "enable_dhcp": {"type": "boolean"},
tiernof7aa8c42016-09-06 16:43:04 +0200615 "dhcp_first_ip": ip_schema,
616 "dhcp_last_ip": ip_schema,
mirabal6878e3f2017-06-05 09:19:26 -0500617 "dns": {"type": "array", "items": [ip_schema]},
618 "links": {"type": "array", "items": {"type": "object", "properties": {
619 "nat": cidr_schema,
620 "iface": name_schema,
621 "vlan": vlan_schema},
622 "required": ["iface"],
623 "additionalProperties": False
624 },
625
626 },
627 "routes": {"type": "object", "properties": {"default": ip_schema}, "patternProperties": {
628 "^([0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$": ip_schema,
629 },
630 "additionalProperties": False
631 },
632
tiernoa290d8f2017-05-03 17:42:52 +0200633 "bind_net": name_schema, # can be name, or uuid
634 "bind_type": {"oneOf": [{"type": "null"}, {"type": "string", "pattern": "^vlan:[0-9]{1,4}$"}]}
tiernof7aa8c42016-09-06 16:43:04 +0200635 },
mirabal6878e3f2017-06-05 09:19:26 -0500636 "required": ["name"]
tiernof7aa8c42016-09-06 16:43:04 +0200637 }
638 },
639 "required": ["network"],
640 "additionalProperties": False
641}
mirabal9e194592017-02-17 11:03:25 +0100642
tiernof7aa8c42016-09-06 16:43:04 +0200643network_update_schema = {
644 "title":"network update information schema",
645 "$schema": "http://json-schema.org/draft-04/schema#",
646 "type":"object",
647 "properties":{
648 "network":{
649 "type":"object",
650 "properties":{
651 "name":name_schema,
652 "type":{"type":"string", "enum":["bridge_man","bridge_data","data", "ptp"]},
653 "shared":{"type":"boolean"},
654 "tenant_id":id_schema,
655 "admin_state_up":{"type":"boolean"},
656 "provider:vlan":vlan_schema,
657 "provider:physical":net_bind_schema,
658 "cidr":cidr_schema,
659 "enable_dhcp": {"type":"boolean"},
Mirabale9317ff2017-01-18 16:10:58 +0000660 # "dhcp_first_ip": ip_schema,
661 # "dhcp_last_ip": ip_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200662 "bind_net":name_schema, #can be name, or uuid
663 "bind_type":{"oneOf":[{"type":"null"},{"type":"string", "pattern":"^vlan:[0-9]{1,4}$"}]}
664 },
665 "minProperties": 1,
666 "additionalProperties": False
667 }
668 },
669 "required": ["network"],
670 "additionalProperties": False
671}
672
673
674port_new_schema = {
675 "title":"port creation information schema",
676 "$schema": "http://json-schema.org/draft-04/schema#",
677 "type":"object",
678 "properties":{
679 "port":{
680 "type":"object",
681 "properties":{
682 "id":id_schema,
683 "name":nameshort_schema,
684 "network_id":{"oneOf":[{"type": "null"}, id_schema ]},
685 "tenant_id":id_schema,
686 "mac_address": {"oneOf":[{"type": "null"}, mac_schema] },
687 "admin_state_up":{"type":"boolean"},
688 "bandwidth":bandwidth_schema,
689 "binding:switch_port":nameshort_schema,
690 "binding:vlan": {"oneOf":[{"type": "null"}, vlan_schema ]}
691 },
692 "required": ["name"]
693 }
694 },
695 "required": ["port"],
696 "additionalProperties": False
697}
698
699port_update_schema = {
700 "title":"port update information schema",
701 "$schema": "http://json-schema.org/draft-04/schema#",
702 "type":"object",
703 "properties":{
704 "port":{
705 "type":"object",
706 "properties":{
707 "name":nameshort_schema,
708 "network_id":{"anyOf":[{"type":"null"}, id_schema ] }
709 },
710 "minProperties": 1,
711 "additionalProperties": False
712 }
713 },
714 "required": ["port"],
715 "additionalProperties": False
716}
717
718localinfo_schema = {
719 "title":"localinfo information schema",
720 "$schema": "http://json-schema.org/draft-04/schema#",
721 "type":"object",
722 "properties":{
723 "files":{ "type": "object"},
724 "inc_files":{ "type": "object"},
725 "server_files":{ "type": "object"}
726 },
727 "required": ["files"]
728}
729
730hostinfo_schema = {
731 "title":"host information schema",
732 "$schema": "http://json-schema.org/draft-04/schema#",
733 "type":"object",
734 "properties":{
735 "iface_names":{
736 "type":"object",
737 "patternProperties":{
738 ".":{ "type": "string"}
739 },
740 "minProperties": 1
741 }
742 },
743 "required": ["iface_names"]
744}
mirabal9e194592017-02-17 11:03:25 +0100745
746openflow_controller_schema = {
747 "title": "network creation information schema",
748 "$schema": "http://json-schema.org/draft-04/schema#",
749 "type": "object",
750 "properties": {
751 "ofc": {
752 "type": "object",
753 "properties": {
754 "name": name_schema,
755 "dpid": nameshort_schema,
756 "ip": nameshort_schema,
757 "port": port_schema,
758 "type": nameshort_schema,
759 "version": nametiny_schema,
760 "user": nameshort_schema,
761 "password": nameshort_schema
762 },
763 "required": ["dpid", "type", "ip", "port", "name"]
764 }
765 },
766 "required": ["ofc"],
767 "additionalProperties": False
mirabal6045a9d2017-03-06 11:36:55 +0100768}
769
770of_port_new_schema = {
771 "title": "OF port mapping",
772 "type": "object",
773 "properties": {
774 "ofc_id": id_schema,
775 "region": nameshort_schema,
776 "compute_node": nameshort_schema,
tierno338e9982017-09-08 12:44:15 +0200777 "pci": pci_extended_schema,
mirabal6045a9d2017-03-06 11:36:55 +0100778 "switch_dpid": nameshort_schema,
779 "switch_port": nameshort_schema,
780 "switch_mac": mac_schema
781 },
782 "required": ["region", "compute_node", "pci", "switch_dpid"]
783}
784
785of_port_map_new_schema = {
786 "title": "OF port mapping",
787 "$schema": "http://json-schema.org/draft-04/schema#",
788 "type": "object",
789 "properties": {
790 "of_port_mapings": {"type": "array", "items": of_port_new_schema, "minLenght":1},
791 },
792 "required": ["of_port_mapings"],
793 "additionalProperties": False
794
garciadeblas1dd7eb22017-06-01 11:40:13 +0200795}