allow pci null for op_port_mapping to be used as external port for SDN-assist
[osm/openvim.git] / osm_openvim / vim_schema.py
1 # -*- coding: utf-8 -*-
2
3 ##
4 # Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U.
5 # This file is part of openvim
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", "maxLength": 255, "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}
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"]}
65
66 config_schema = {
67 "title": "main configuration information schema",
68 "$schema": "http://json-schema.org/draft-04/schema#",
69 "type": "object",
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,
77 "db_passwd": {"type": "string"},
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"},
85 "of_user": nameshort_schema,
86 "of_password": nameshort_schema,
87 "test_mode": {"type": "boolean"}, # leave for backward compatibility
88 "mode": {"type":"string", "enum":["normal", "host only", "OF only", "development", "test"] },
89 "development_bridge": {"type":"string"},
90 "tenant_id": {"type" : "string"},
91 "image_path": path_schema, # leave for backward compatibility
92 "host_image_path": path_schema,
93 "host_ssh_keyfile": path_schema,
94 "network_vlan_range_start": vlan_schema,
95 "network_vlan_range_end": vlan_schema,
96 "bridge_ifaces": {
97 "type": "object",
98 "patternProperties": {
99 "." : {
100 "type": "array",
101 "items": integer0_schema,
102 "minItems":2,
103 "maxItems":2,
104 },
105 },
106 "minProperties": 2
107 },
108 "dhcp_server": {
109 "type": "object",
110 "properties": {
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",
120 "items": nameshort_schema,
121 },
122 "nets": {
123 "type": "array",
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,
132 "network_type": {"type": "string", "enum": ["ovs", "bridge"]},
133 "ovs_controller_file_path": path_schema,
134 "ovs_controller_ip": nameshort_schema,
135 "ovs_controller_user": nameshort_schema,
136 "ovs_controller_password": {"type": "string"},
137 "ovs_controller_keyfile": path_schema,
138 },
139 "patternProperties": {
140 "of_*" : {"type": ["string", "integer", "boolean"]}
141 },
142 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
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"},
158 "topology": {"type":"string", "enum": ["oneSocket", "oneSocket:hyperthreading"]}
159 }
160 }
161
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 }
181
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,
232 "dev":nameshort_schema,
233 "size":integer1_schema,
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",
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,
271 "name": name_schema,
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
279 "hypervisors": description_schema, #Unikernels extension
280 "devices": {
281 "type": "array",
282 "items": {
283 "type": "object",
284 "properties": {
285 "type": {"type": "string", "enum": ["usb", "disk"]},
286 "vpci": pci_schema
287 },
288 "additionalProperties": False,
289 "required": ["type"]
290 }
291 },
292 "numas": {
293 "type": "array",
294 "minItems": 1,
295 "items": {
296 "type": "object",
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,
303 "cores":{
304 "type": "array",
305 "minItems": 2,
306 "items": {
307 "type": "object",
308 "properties": {
309 "core_id": integer0_schema,
310 "thread_id": integer0_schema,
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
314 },
315 "additionalProperties": False,
316 "required": ["core_id", "thread_id"]
317 }
318 },
319 "interfaces": {
320 "type": "array",
321 "minItems": 1,
322 "items": {
323 "type": "object",
324 "properties": {
325 "source_name": nameshort_schema,
326 "mac": mac_schema,
327 "Mbps": integer0_schema,
328 "pci": pci_schema,
329 "sriovs": {
330 "type": "array",
331 "minItems":1,
332 "items": {
333 "type": "object",
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,
339 },
340 "additionalProperties": False,
341 "required": ["source_name", "mac", "pci"]
342 }
343 },
344 "switch_port": nameshort_schema,
345 "switch_dpid": nameshort_schema,
346 "switch_mac": mac_schema,
347 },
348 "additionalProperties": False,
349 "required": ["source_name", "mac", "Mbps", "pci"]
350 }
351 },
352 },
353 "additionalProperties": False,
354 "required": ["cores", "numa_socket"]
355 }
356 }
357 },
358 "additionalProperties": False,
359 "required": ["name", "user", "ip_name"]
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":{
415 "host": host_data_schema,
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,
524 "ip_address": ip_schema,
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,
548 "hypervisor":{"type":"string", "enum":["kvm","xen-unik","xenhvm"]}, #Unikernels extension
549 "osImageType":{"type":"string", "enum":["clickos","other"]}, #Unikernels extension
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 = {
601 "title": "network creation information schema",
602 "$schema": "http://json-schema.org/draft-04/schema#",
603 "type": "object",
604 "properties": {
605 "network": {
606 "type": "object",
607 "properties":{
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"},
619 "dhcp_first_ip": ip_schema,
620 "dhcp_last_ip": ip_schema,
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
637 "bind_net": name_schema, # can be name, or uuid
638 "bind_type": {"oneOf": [{"type": "null"}, {"type": "string", "pattern": "^vlan:[0-9]{1,4}$"}]}
639 },
640 "required": ["name"]
641 }
642 },
643 "required": ["network"],
644 "additionalProperties": False
645 }
646
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"},
664 # "dhcp_first_ip": ip_schema,
665 # "dhcp_last_ip": ip_schema,
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 }
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
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,
781 "pci": {"OneOf": [{"type": "null"}, pci_extended_schema]},
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
799 }