blob: 9440872705c77c636b9294f5e189f5f01e98d624 [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}(/[^/\"':{}\(\)]+)+$"}
tiernof7aa8c42016-09-06 16:43:04 +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 } #"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}$"
45id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
46pci_schema={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
47bandwidth_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
48integer0_schema={"type":"integer","minimum":0}
49integer1_schema={"type":"integer","minimum":1}
50vlan_schema={"type":"integer","minimum":1,"maximun":4095}
51vlan1000_schema={"type":"integer","minimum":1000,"maximun":4095}
52mac_schema={"type":"string", "pattern":"^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$"} #must be unicast LSB bit of MSB byte ==0
53net_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)?)$"}]}
54yes_no_schema={"type":"string", "enum":["yes", "no"]}
55log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
56
57config_schema = {
tiernoa6933042017-05-24 16:54:33 +020058 "title": "main configuration information schema",
tiernof7aa8c42016-09-06 16:43:04 +020059 "$schema": "http://json-schema.org/draft-04/schema#",
tiernoa6933042017-05-24 16:54:33 +020060 "type": "object",
tiernof7aa8c42016-09-06 16:43:04 +020061 "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,
tiernoa6933042017-05-24 16:54:33 +020068 "db_passwd": {"type": "string"},
tiernof7aa8c42016-09-06 16:43:04 +020069 "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"},
mirabal580435e2017-03-01 16:17:10 +010076 "of_user": nameshort_schema,
77 "of_password": nameshort_schema,
tiernoa6933042017-05-24 16:54:33 +020078 "test_mode": {"type": "boolean"}, # leave for backward compatibility
tiernof7aa8c42016-09-06 16:43:04 +020079 "mode": {"type":"string", "enum":["normal", "host only", "OF only", "development", "test"] },
80 "development_bridge": {"type":"string"},
81 "tenant_id": {"type" : "string"},
tiernoa6933042017-05-24 16:54:33 +020082 "image_path": path_schema, # leave for backward compatibility
83 "host_image_path": path_schema,
84 "host_ssh_keyfile": path_schema,
tiernof7aa8c42016-09-06 16:43:04 +020085 "network_vlan_range_start": vlan_schema,
86 "network_vlan_range_end": vlan_schema,
87 "bridge_ifaces": {
88 "type": "object",
89 "patternProperties": {
90 "." : {
tiernoa6933042017-05-24 16:54:33 +020091 "type": "array",
tiernof7aa8c42016-09-06 16:43:04 +020092 "items": integer0_schema,
93 "minItems":2,
94 "maxItems":2,
95 },
96 },
97 "minProperties": 2
98 },
99 "dhcp_server": {
100 "type": "object",
101 "properties": {
tiernoa6933042017-05-24 16:54:33 +0200102 "host": name_schema,
103 "port": port_schema,
104 "provider": {"type": "string", "enum": ["isc-dhcp-server"]},
105 "user": nameshort_schema,
106 "password": {"type": "string"},
107 "key": path_schema, # for backward compatibility, use keyfile instead
108 "keyfile": path_schema,
109 "bridge_ifaces": {
110 "type": "array",
tiernof7aa8c42016-09-06 16:43:04 +0200111 "items": nameshort_schema,
112 },
tiernoa6933042017-05-24 16:54:33 +0200113 "nets": {
114 "type": "array",
tiernof7aa8c42016-09-06 16:43:04 +0200115 "items": name_schema,
116 },
117 },
118 "required": ['host', 'provider', 'user']
119 },
120 "log_level": log_level_schema,
121 "log_level_db": log_level_schema,
122 "log_level_of": log_level_schema,
Mirabal7256d6b2016-12-15 10:51:19 +0000123 "network_type": {"type": "string", "enum": ["ovs", "bridge"]},
Mirabale9317ff2017-01-18 16:10:58 +0000124 "ovs_controller_file_path": path_schema,
tiernoa6933042017-05-24 16:54:33 +0200125 "ovs_controller_ip": nameshort_schema,
Mirabale9317ff2017-01-18 16:10:58 +0000126 "ovs_controller_user": nameshort_schema,
tiernoa6933042017-05-24 16:54:33 +0200127 "ovs_controller_password": {"type": "string"},
128 "ovs_controller_keyfile": path_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200129 },
130 "patternProperties": {
131 "of_*" : {"type": ["string", "integer", "boolean"]}
132 },
mirabal580435e2017-03-01 16:17:10 +0100133 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
tiernof7aa8c42016-09-06 16:43:04 +0200134 "additionalProperties": False
135}
136
137
138
139metadata_schema={
140 "type":"object",
141 "properties":{
142 "architecture": {"type":"string"},
143 "use_incremental": yes_no_schema,
144 "vpci": pci_schema,
145 "os_distro": {"type":"string"},
146 "os_type": {"type":"string"},
147 "os_version": {"type":"string"},
148 "bus": {"type":"string"},
garciadeblas1dd7eb22017-06-01 11:40:13 +0200149 "topology": {"type":"string", "enum": ["oneSocket", "oneSocket:hyperthreading"]}
tiernof7aa8c42016-09-06 16:43:04 +0200150 }
151}
152
tiernof7aa8c42016-09-06 16:43:04 +0200153tenant_new_schema = {
154 "title":"tenant creation information schema",
155 "$schema": "http://json-schema.org/draft-04/schema#",
156 "type":"object",
157 "properties":{
158 "tenant":{
159 "type":"object",
160 "properties":{
161 "id":id_schema,
162 "name": nameshort_schema,
163 "description":description_schema,
164 "enabled":{"type" : "boolean"}
165 },
166 "required": ["name"]
167 }
168 },
169 "required": ["tenant"],
170 "additionalProperties": False
171}
mirabal6045a9d2017-03-06 11:36:55 +0100172
tiernof7aa8c42016-09-06 16:43:04 +0200173tenant_edit_schema = {
174 "title":"tenant edition information schema",
175 "$schema": "http://json-schema.org/draft-04/schema#",
176 "type":"object",
177 "properties":{
178 "tenant":{
179 "type":"object",
180 "minProperties":1,
181 "properties":{
182 "name":nameshort_schema,
183 "description":description_schema,
184 "enabled":{"type" : "boolean"}
185 },
186 "additionalProperties": False,
187 }
188 },
189 "required": ["tenant"],
190 "additionalProperties": False
191}
192interfaces_schema={
193 "type":"array",
194 "minItems":0,
195 "items":{
196 "type":"object",
197 "properties":{
198 "name":name_schema,
199 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
200 "bandwidth":bandwidth_schema,
201 "vpci":pci_schema,
202 "uuid":id_schema,
203 "mac_address":mac_schema
204 },
205 "additionalProperties": False,
206 "required": ["dedicated", "bandwidth"]
207 }
208}
209
210extended_schema={
211 "type":"object",
212 "properties":{
213 "processor_ranking":integer0_schema,
214 "devices":{
215 "type": "array",
216 "items":{
217 "type": "object",
218 "properties":{
219 "type":{"type":"string", "enum":["usb","disk","cdrom","xml"]},
220 "vpci":pci_schema,
221 "imageRef":id_schema,
222 "xml":xml_text_schema,
mirabalcaeb2242017-05-31 10:52:22 -0500223 "dev":nameshort_schema,
224 "size":integer1_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200225 },
226 "additionalProperties": False,
227 "required": ["type"]
228 }
229 },
230 "numas":{
231 "type": "array",
232 "items":{
233 "type": "object",
234 "properties":{
235 "memory":integer1_schema,
236 "cores":integer1_schema,
237 "paired-threads":integer1_schema,
238 "threads":integer1_schema,
239 "cores-id":{"type":"array","items":integer0_schema},
240 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
241 "threads-id":{"type":"array","items":integer0_schema},
242 "interfaces":interfaces_schema
243 },
244 "additionalProperties": False,
245 "minProperties": 1,
246 #"required": ["memory"]
247 }
248 }
249 },
250 #"additionalProperties": False,
251 #"required": ["processor_ranking"]
252}
253
254host_data_schema={
255 "title":"hosts manual insertion information schema",
256 "type":"object",
tiernoa6933042017-05-24 16:54:33 +0200257 "properties":{
258 "id": id_schema,
259 "admin_state_up": {"type": "boolean"},
260 "created_at": {"type": "string"}, # ignored, just for compatibility with host-list
261 "ip_name": nameshort_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200262 "name": name_schema,
tiernoa6933042017-05-24 16:54:33 +0200263 "description": description_schema,
264 "user": nameshort_schema,
265 "password": nameshort_schema,
266 "keyfile": path_schema,
267 "features": description_schema,
268 "ranking": integer0_schema,
269 "autodiscover": {"type": "boolean"}, # try to discover host parameters instead of providing in this schema
270 "devices": {
tiernof7aa8c42016-09-06 16:43:04 +0200271 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200272 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200273 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200274 "properties": {
275 "type": {"type": "string", "enum": ["usb", "disk"]},
276 "vpci": pci_schema
tiernof7aa8c42016-09-06 16:43:04 +0200277 },
278 "additionalProperties": False,
279 "required": ["type"]
280 }
281 },
tiernoa6933042017-05-24 16:54:33 +0200282 "numas": {
tiernof7aa8c42016-09-06 16:43:04 +0200283 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200284 "minItems": 1,
285 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200286 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200287 "properties": {
288 "admin_state_up": {"type": "boolean"},
289 "hugepages": integer0_schema,
290 "hugepages_consumed": integer0_schema, # ignored, just for compatibility with host-list
291 "numa_socket": integer0_schema,
292 "memory": integer1_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200293 "cores":{
294 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200295 "minItems": 2,
296 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200297 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200298 "properties": {
299 "core_id": integer0_schema,
300 "thread_id": integer0_schema,
tiernoc67abe22017-07-03 17:04:54 +0200301 "status": {"type": "string", "enum": ["noteligible"]},
302 "instance_id": {"type": "string"}, # ignored, just for compatibility with host-list
303 "v_thread_id": {"type": "integer"} # ignored, just for compatibility with host-list
tiernof7aa8c42016-09-06 16:43:04 +0200304 },
305 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200306 "required": ["core_id", "thread_id"]
tiernof7aa8c42016-09-06 16:43:04 +0200307 }
308 },
tiernoa6933042017-05-24 16:54:33 +0200309 "interfaces": {
tiernof7aa8c42016-09-06 16:43:04 +0200310 "type": "array",
tiernoa6933042017-05-24 16:54:33 +0200311 "minItems": 1,
312 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200313 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200314 "properties": {
315 "source_name": nameshort_schema,
316 "mac": mac_schema,
317 "Mbps": integer0_schema,
318 "pci": pci_schema,
319 "sriovs": {
tiernof7aa8c42016-09-06 16:43:04 +0200320 "type": "array",
321 "minItems":1,
tiernoa6933042017-05-24 16:54:33 +0200322 "items": {
tiernof7aa8c42016-09-06 16:43:04 +0200323 "type": "object",
tiernoa6933042017-05-24 16:54:33 +0200324 "properties": {
325 "source_name": {"oneOf": [integer0_schema, nameshort_schema]},
326 "mac": mac_schema,
327 "vlan": integer0_schema, # ignored, just for backward compatibility
328 "pci": pci_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200329 },
330 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200331 "required": ["source_name", "mac", "pci"]
tiernof7aa8c42016-09-06 16:43:04 +0200332 }
333 },
334 "switch_port": nameshort_schema,
335 "switch_dpid": nameshort_schema,
tiernoa6933042017-05-24 16:54:33 +0200336 "switch_mac": mac_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200337 },
338 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200339 "required": ["source_name", "mac", "Mbps", "pci"]
tiernof7aa8c42016-09-06 16:43:04 +0200340 }
341 },
tiernof7aa8c42016-09-06 16:43:04 +0200342 },
343 "additionalProperties": False,
tiernoa6933042017-05-24 16:54:33 +0200344 "required": ["cores", "numa_socket"]
tiernof7aa8c42016-09-06 16:43:04 +0200345 }
346 }
347 },
348 "additionalProperties": False,
tiernoc67abe22017-07-03 17:04:54 +0200349 "required": ["name", "user", "ip_name"]
tiernof7aa8c42016-09-06 16:43:04 +0200350}
351
352host_edit_schema={
353 "title":"hosts creation information schema",
354 "$schema": "http://json-schema.org/draft-04/schema#",
355 "type":"object",
356 "properties":{
357 "host":{
358 "type":"object",
359 "properties":{
360 "ip_name":nameshort_schema,
361 "name": name_schema,
362 "description":description_schema,
363 "user":nameshort_schema,
364 "password":nameshort_schema,
365 "admin_state_up":{"type":"boolean"},
366 "numas":{
367 "type":"array",
368 "items":{
369 "type": "object",
370 "properties":{
371 "numa_socket": integer0_schema,
372 "admin_state_up":{"type":"boolean"},
373 "interfaces":{
374 "type":"array",
375 "items":{
376 "type": "object",
377 "properties":{
378 "source_name": nameshort_schema,
379 "switch_dpid": nameshort_schema,
380 "switch_port": nameshort_schema,
381 },
382 "required": ["source_name"],
383 }
384 }
385 },
386 "required": ["numa_socket"],
387 "additionalProperties": False,
388 }
389 }
390 },
391 "minProperties": 1,
392 "additionalProperties": False
393 },
394 },
395 "required": ["host"],
396 "minProperties": 1,
397 "additionalProperties": False
398}
399
400host_new_schema = {
401 "title":"hosts creation information schema",
402 "$schema": "http://json-schema.org/draft-04/schema#",
403 "type":"object",
404 "properties":{
tiernoa6933042017-05-24 16:54:33 +0200405 "host": host_data_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200406 "host-data":host_data_schema
407 },
408 "required": ["host"],
409 "minProperties": 1,
410 "maxProperties": 2,
411 "additionalProperties": False
412}
413
414
415flavor_new_schema = {
416 "title":"flavor creation information schema",
417 "$schema": "http://json-schema.org/draft-04/schema#",
418 "type":"object",
419 "properties":{
420 "flavor":{
421 "type":"object",
422 "properties":{
423 "id":id_schema,
424 "name":name_schema,
425 "description":description_schema,
426 "ram":integer0_schema,
427 "vcpus":integer0_schema,
428 "extended": extended_schema,
429 "public": yes_no_schema
430 },
431 "required": ["name"]
432 }
433 },
434 "required": ["flavor"],
435 "additionalProperties": False
436}
437flavor_update_schema = {
438 "title":"flavor update information schema",
439 "$schema": "http://json-schema.org/draft-04/schema#",
440 "type":"object",
441 "properties":{
442 "flavor":{
443 "type":"object",
444 "properties":{
445 "name":name_schema,
446 "description":description_schema,
447 "ram":integer0_schema,
448 "vcpus":integer0_schema,
449 "extended": extended_schema,
450 "public": yes_no_schema
451 },
452 "minProperties": 1,
453 "additionalProperties": False
454 }
455 },
456 "required": ["flavor"],
457 "additionalProperties": False
458}
459
460image_new_schema = {
461 "title":"image creation information schema",
462 "$schema": "http://json-schema.org/draft-04/schema#",
463 "type":"object",
464 "properties":{
465 "image":{
466 "type":"object",
467 "properties":{
468 "id":id_schema,
469 "path": {"oneOf": [path_schema, http_schema]},
470 "description":description_schema,
471 "name":name_schema,
472 "metadata":metadata_schema,
473 "public": yes_no_schema
474 },
475 "required": ["name","path"]
476 }
477 },
478 "required": ["image"],
479 "additionalProperties": False
480}
481
482image_update_schema = {
483 "title":"image update information schema",
484 "$schema": "http://json-schema.org/draft-04/schema#",
485 "type":"object",
486 "properties":{
487 "image":{
488 "type":"object",
489 "properties":{
490 "path":{"oneOf": [path_schema, http_schema]},
491 "description":description_schema,
492 "name":name_schema,
493 "metadata":metadata_schema,
494 "public": yes_no_schema
495 },
496 "minProperties": 1,
497 "additionalProperties": False
498 }
499 },
500 "required": ["image"],
501 "additionalProperties": False
502}
503
504networks_schema={
505 "type":"array",
506 "items":{
507 "type":"object",
508 "properties":{
509 "name":name_schema,
510 "bandwidth":bandwidth_schema,
511 "vpci":pci_schema,
512 "uuid":id_schema,
513 "mac_address": mac_schema,
514 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]},
515 "type": {"type":"string", "enum":["virtual","PF","VF","VFnotShared"]}
516 },
517 "additionalProperties": False,
518 "required": ["uuid"]
519 }
520}
521
522server_new_schema = {
523 "title":"server creation information schema",
524 "$schema": "http://json-schema.org/draft-04/schema#",
525 "type":"object",
526 "properties":{
527 "server":{
528 "type":"object",
529 "properties":{
530 "id":id_schema,
531 "name":name_schema,
532 "description":description_schema,
533 "start":{"type":"string", "enum":["yes","no","paused"]},
534 "hostId":id_schema,
535 "flavorRef":id_schema,
536 "imageRef":id_schema,
537 "extended": extended_schema,
538 "networks":networks_schema
539 },
540 "required": ["name","flavorRef","imageRef"]
541 }
542 },
543 "required": ["server"],
544 "additionalProperties": False
545}
546
547server_action_schema = {
548 "title":"server action information schema",
549 "$schema": "http://json-schema.org/draft-04/schema#",
550 "type":"object",
551 "properties":{
552 "start":{"oneOf":[{"type": "null"}, {"type":"string", "enum":["rebuild","null"] }]},
553 "pause":{"type": "null"},
554 "resume":{"type": "null"},
555 "shutoff":{"type": "null"},
556 "shutdown":{"type": "null"},
557 "forceOff":{"type": "null"},
558 "terminate":{"type": "null"},
559 "createImage":{
560 "type":"object",
561 "properties":{
562 "path":path_schema,
563 "description":description_schema,
564 "name":name_schema,
565 "metadata":metadata_schema,
566 "imageRef": id_schema,
567 "disk": {"oneOf":[{"type": "null"}, {"type":"string"}] },
568 },
569 "required": ["name"]
570 },
571 "rebuild":{"type": ["object","null"]},
572 "reboot":{
573 "type": ["object","null"],
574# "properties": {
575# "type":{"type":"string", "enum":["SOFT"] }
576# },
577# "minProperties": 1,
578# "maxProperties": 1,
579# "additionalProperties": False
580 }
581 },
582 "minProperties": 1,
583 "maxProperties": 1,
584 "additionalProperties": False
585}
586
587network_new_schema = {
tiernoa290d8f2017-05-03 17:42:52 +0200588 "title": "network creation information schema",
tiernof7aa8c42016-09-06 16:43:04 +0200589 "$schema": "http://json-schema.org/draft-04/schema#",
tiernoa290d8f2017-05-03 17:42:52 +0200590 "type": "object",
591 "properties": {
592 "network": {
593 "type": "object",
tiernof7aa8c42016-09-06 16:43:04 +0200594 "properties":{
tiernoa290d8f2017-05-03 17:42:52 +0200595 "id": id_schema,
596 "name": name_schema,
597 "type": {"type":"string", "enum": ["bridge_man", "bridge_data", "data", "ptp"]},
598 "shared": {"type": "boolean"},
599 "tenant_id": id_schema,
600 "admin_state_up": {"type": "boolean"},
601 "provider:vlan": vlan_schema,
602 "provider:physical": net_bind_schema,
603 "region": nameshort_schema,
604 "cidr": cidr_schema,
605 "enable_dhcp": {"type": "boolean"},
tiernof7aa8c42016-09-06 16:43:04 +0200606 "dhcp_first_ip": ip_schema,
607 "dhcp_last_ip": ip_schema,
mirabal6878e3f2017-06-05 09:19:26 -0500608 "dns": {"type": "array", "items": [ip_schema]},
609 "links": {"type": "array", "items": {"type": "object", "properties": {
610 "nat": cidr_schema,
611 "iface": name_schema,
612 "vlan": vlan_schema},
613 "required": ["iface"],
614 "additionalProperties": False
615 },
616
617 },
618 "routes": {"type": "object", "properties": {"default": ip_schema}, "patternProperties": {
619 "^([0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$": ip_schema,
620 },
621 "additionalProperties": False
622 },
623
tiernoa290d8f2017-05-03 17:42:52 +0200624 "bind_net": name_schema, # can be name, or uuid
625 "bind_type": {"oneOf": [{"type": "null"}, {"type": "string", "pattern": "^vlan:[0-9]{1,4}$"}]}
tiernof7aa8c42016-09-06 16:43:04 +0200626 },
mirabal6878e3f2017-06-05 09:19:26 -0500627 "required": ["name"]
tiernof7aa8c42016-09-06 16:43:04 +0200628 }
629 },
630 "required": ["network"],
631 "additionalProperties": False
632}
mirabal9e194592017-02-17 11:03:25 +0100633
tiernof7aa8c42016-09-06 16:43:04 +0200634network_update_schema = {
635 "title":"network update information schema",
636 "$schema": "http://json-schema.org/draft-04/schema#",
637 "type":"object",
638 "properties":{
639 "network":{
640 "type":"object",
641 "properties":{
642 "name":name_schema,
643 "type":{"type":"string", "enum":["bridge_man","bridge_data","data", "ptp"]},
644 "shared":{"type":"boolean"},
645 "tenant_id":id_schema,
646 "admin_state_up":{"type":"boolean"},
647 "provider:vlan":vlan_schema,
648 "provider:physical":net_bind_schema,
649 "cidr":cidr_schema,
650 "enable_dhcp": {"type":"boolean"},
Mirabale9317ff2017-01-18 16:10:58 +0000651 # "dhcp_first_ip": ip_schema,
652 # "dhcp_last_ip": ip_schema,
tiernof7aa8c42016-09-06 16:43:04 +0200653 "bind_net":name_schema, #can be name, or uuid
654 "bind_type":{"oneOf":[{"type":"null"},{"type":"string", "pattern":"^vlan:[0-9]{1,4}$"}]}
655 },
656 "minProperties": 1,
657 "additionalProperties": False
658 }
659 },
660 "required": ["network"],
661 "additionalProperties": False
662}
663
664
665port_new_schema = {
666 "title":"port creation information schema",
667 "$schema": "http://json-schema.org/draft-04/schema#",
668 "type":"object",
669 "properties":{
670 "port":{
671 "type":"object",
672 "properties":{
673 "id":id_schema,
674 "name":nameshort_schema,
675 "network_id":{"oneOf":[{"type": "null"}, id_schema ]},
676 "tenant_id":id_schema,
677 "mac_address": {"oneOf":[{"type": "null"}, mac_schema] },
678 "admin_state_up":{"type":"boolean"},
679 "bandwidth":bandwidth_schema,
680 "binding:switch_port":nameshort_schema,
681 "binding:vlan": {"oneOf":[{"type": "null"}, vlan_schema ]}
682 },
683 "required": ["name"]
684 }
685 },
686 "required": ["port"],
687 "additionalProperties": False
688}
689
690port_update_schema = {
691 "title":"port update information schema",
692 "$schema": "http://json-schema.org/draft-04/schema#",
693 "type":"object",
694 "properties":{
695 "port":{
696 "type":"object",
697 "properties":{
698 "name":nameshort_schema,
699 "network_id":{"anyOf":[{"type":"null"}, id_schema ] }
700 },
701 "minProperties": 1,
702 "additionalProperties": False
703 }
704 },
705 "required": ["port"],
706 "additionalProperties": False
707}
708
709localinfo_schema = {
710 "title":"localinfo information schema",
711 "$schema": "http://json-schema.org/draft-04/schema#",
712 "type":"object",
713 "properties":{
714 "files":{ "type": "object"},
715 "inc_files":{ "type": "object"},
716 "server_files":{ "type": "object"}
717 },
718 "required": ["files"]
719}
720
721hostinfo_schema = {
722 "title":"host information schema",
723 "$schema": "http://json-schema.org/draft-04/schema#",
724 "type":"object",
725 "properties":{
726 "iface_names":{
727 "type":"object",
728 "patternProperties":{
729 ".":{ "type": "string"}
730 },
731 "minProperties": 1
732 }
733 },
734 "required": ["iface_names"]
735}
mirabal9e194592017-02-17 11:03:25 +0100736
737openflow_controller_schema = {
738 "title": "network creation information schema",
739 "$schema": "http://json-schema.org/draft-04/schema#",
740 "type": "object",
741 "properties": {
742 "ofc": {
743 "type": "object",
744 "properties": {
745 "name": name_schema,
746 "dpid": nameshort_schema,
747 "ip": nameshort_schema,
748 "port": port_schema,
749 "type": nameshort_schema,
750 "version": nametiny_schema,
751 "user": nameshort_schema,
752 "password": nameshort_schema
753 },
754 "required": ["dpid", "type", "ip", "port", "name"]
755 }
756 },
757 "required": ["ofc"],
758 "additionalProperties": False
mirabal6045a9d2017-03-06 11:36:55 +0100759}
760
761of_port_new_schema = {
762 "title": "OF port mapping",
763 "type": "object",
764 "properties": {
765 "ofc_id": id_schema,
766 "region": nameshort_schema,
767 "compute_node": nameshort_schema,
768 "pci": pci_schema,
769 "switch_dpid": nameshort_schema,
770 "switch_port": nameshort_schema,
771 "switch_mac": mac_schema
772 },
773 "required": ["region", "compute_node", "pci", "switch_dpid"]
774}
775
776of_port_map_new_schema = {
777 "title": "OF port mapping",
778 "$schema": "http://json-schema.org/draft-04/schema#",
779 "type": "object",
780 "properties": {
781 "of_port_mapings": {"type": "array", "items": of_port_new_schema, "minLenght":1},
782 },
783 "required": ["of_port_mapings"],
784 "additionalProperties": False
785
garciadeblas1dd7eb22017-06-01 11:40:13 +0200786}