2 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
3 # This file is part of openmano
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
18 # For those usages not covered by the Apache License, Version 2.0 please
19 # contact with: nfvlabs@tid.es
23 JSON schemas used by openmano httpserver.py module to parse the different files and messages sent through the API
25 __author__
="Alfonso Tierno, Gerardo Garcia"
26 __date__
="$09-oct-2014 09:09:48$"
29 patern_name
="^[ -~]+$"
30 passwd_schema
={"type" : "string", "minLength":1, "maxLength":60}
31 nameshort_schema
={"type" : "string", "minLength":1, "maxLength":60, "pattern" : "^[^,;()'\"]+$"}
32 name_schema
={"type" : "string", "minLength":1, "maxLength":255, "pattern" : "^[^,;()'\"]+$"}
33 xml_text_schema
={"type" : "string", "minLength":1, "maxLength":1000, "pattern" : "^[^']+$"}
34 description_schema
={"type" : ["string","null"], "maxLength":255, "pattern" : "^[^'\"]+$"}
35 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}$"
36 id_schema
= {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
37 pci_schema
={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
38 http_schema
={"type":"string", "pattern":"^https?://[^'\"=]+$"}
39 bandwidth_schema
={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
40 memory_schema
={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
41 integer0_schema
={"type":"integer","minimum":0}
42 integer1_schema
={"type":"integer","minimum":1}
43 path_schema
={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
44 vlan_schema
={"type":"integer","minimum":1,"maximum":4095}
45 vlan1000_schema
={"type":"integer","minimum":1000,"maximum":4095}
46 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
47 #mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
48 ip_schema
={"type":"string","pattern":"^([0-9]{1,3}.){3}[0-9]{1,3}$"}
49 port_schema
={"type":"integer","minimum":1,"maximum":65534}
50 object_schema
={"type":"object"}
51 schema_version_2
={"type":"integer","minimum":2,"maximum":2}
52 log_level_schema
={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
57 "architecture": {"type":"string"},
58 "use_incremental": {"type":"string","enum":["yes","no"]},
60 "os_distro": {"type":"string"},
61 "os_type": {"type":"string"},
62 "os_version": {"type":"string"},
63 "bus": {"type":"string"},
64 "topology": {"type":"string", "enum": ["oneSocket"]}
68 #Schema for the configuration file
70 "title":"configuration response information schema",
71 "$schema": "http://json-schema.org/draft-04/schema#",
74 "http_port": port_schema
,
75 "http_admin_port": port_schema
,
76 "http_host": nameshort_schema
,
77 "vnf_repository": path_schema
,
78 "db_host": nameshort_schema
,
79 "db_user": nameshort_schema
,
80 "db_passwd": {"type":"string"},
81 "db_name": nameshort_schema
,
82 # Next fields will disappear once the MANO API includes appropriate primitives
83 "vim_url": http_schema
,
84 "vim_url_admin": http_schema
,
85 "vim_name": nameshort_schema
,
86 "vim_tenant_name": nameshort_schema
,
87 "mano_tenant_name": nameshort_schema
,
88 "mano_tenant_id": id_schema
,
89 "http_console_ports": {
93 {"type":"object", "properties":{"from": port_schema
, "to": port_schema
}, "required": ["from","to"]}
96 "log_level": log_level_schema
,
97 "log_level_db": log_level_schema
,
98 "log_level_vimconn": log_level_schema
100 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
101 "additionalProperties": False
105 "title":"tenant information schema",
106 "$schema": "http://json-schema.org/draft-04/schema#",
112 "name": nameshort_schema
,
113 "description": description_schema
,
115 "required": ["name"],
116 "additionalProperties": True
119 "required": ["tenant"],
120 "additionalProperties": False
122 tenant_edit_schema
= {
123 "title":"tenant edit information schema",
124 "$schema": "http://json-schema.org/draft-04/schema#",
131 "description": description_schema
,
133 "additionalProperties": False
136 "required": ["tenant"],
137 "additionalProperties": False
140 datacenter_schema_properties
={
142 "description": description_schema
,
143 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarge with plugins
144 "vim_url": description_schema
,
145 "vim_url_admin": description_schema
,
146 "config": { "type":"object" }
149 datacenter_schema
= {
150 "title":"datacenter information schema",
151 "$schema": "http://json-schema.org/draft-04/schema#",
156 "properties":datacenter_schema_properties
,
157 "required": ["name", "vim_url"],
158 "additionalProperties": True
161 "required": ["datacenter"],
162 "additionalProperties": False
166 datacenter_edit_schema
= {
167 "title":"datacenter edit nformation schema",
168 "$schema": "http://json-schema.org/draft-04/schema#",
173 "properties":datacenter_schema_properties
,
174 "additionalProperties": False
177 "required": ["datacenter"],
178 "additionalProperties": False
182 netmap_new_schema
= {
183 "title":"netmap new information schema",
184 "$schema": "http://json-schema.org/draft-04/schema#",
187 "netmap":{ #delete from datacenter
190 "name": name_schema
, #name or uuid of net to change
192 "vim_name": name_schema
195 "additionalProperties": False
198 "required": ["netmap"],
199 "additionalProperties": False
202 netmap_edit_schema
= {
203 "title":"netmap edit information schema",
204 "$schema": "http://json-schema.org/draft-04/schema#",
207 "netmap":{ #delete from datacenter
210 "name": name_schema
, #name or uuid of net to change
213 "additionalProperties": False
216 "required": ["netmap"],
217 "additionalProperties": False
220 datacenter_action_schema
= {
221 "title":"datacenter action information schema",
222 "$schema": "http://json-schema.org/draft-04/schema#",
225 "net-update":{"type":"null",},
229 "net": name_schema
, #name or uuid of net to change
231 "description": description_schema
,
232 "shared": {"type": "boolean"}
235 "additionalProperties": False
240 "net": name_schema
, #name or uuid of net to change
243 "additionalProperties": False
248 "additionalProperties": False
252 datacenter_associate_schema
={
253 "title":"datacenter associate information schema",
254 "$schema": "http://json-schema.org/draft-04/schema#",
260 "vim_tenant": id_schema
,
261 "vim_tenant_name": nameshort_schema
,
262 "vim_username": nameshort_schema
,
263 "vim_password": nameshort_schema
,
265 # "required": ["vim_tenant"],
266 "additionalProperties": True
269 "required": ["datacenter"],
270 "additionalProperties": False
273 internal_connection_element_schema
= {
277 "local_iface_name": name_schema
281 internal_connection_schema
= {
285 "description":description_schema
,
286 "type":{"type":"string", "enum":["bridge","data","ptp"]},
287 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
289 "required": ["name", "type", "elements"],
290 "additionalProperties": False
293 external_connection_schema
= {
297 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
299 "local_iface_name": name_schema
,
300 "description":description_schema
302 "required": ["name", "type", "VNFC", "local_iface_name"],
303 "additionalProperties": False
312 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
313 "bandwidth":bandwidth_schema
,
315 "mac_address": mac_schema
317 "additionalProperties": False,
318 "required": ["name","dedicated", "bandwidth"]
322 bridge_interfaces_schema
={
328 "bandwidth":bandwidth_schema
,
330 "mac_address": mac_schema
,
331 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
333 "additionalProperties": False,
343 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
344 "image": path_schema
,
345 "image metadata": metadata_schema
,
347 "xml":xml_text_schema
,
349 "additionalProperties": False,
358 "memory":integer1_schema
,
359 "cores":integer1_schema
,
360 "paired-threads":integer1_schema
,
361 "threads":integer1_schema
,
362 "cores-id":{"type":"array","items":integer0_schema
},
363 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
364 "threads-id":{"type":"array","items":integer0_schema
},
365 "interfaces":interfaces_schema
367 "additionalProperties": False,
368 #"required": ["memory"]
375 "description": description_schema
,
376 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
377 "image metadata": metadata_schema
,
381 "model":description_schema
,
382 "features":{"type":"array","items":nameshort_schema
}
384 "required": ["model"],
385 "additionalProperties": False
390 "type":nameshort_schema
,
391 "version":description_schema
394 "ram":integer0_schema
,
395 "vcpus":integer0_schema
,
396 "disk": integer1_schema
,
401 "bridge-ifaces": bridge_interfaces_schema
,
402 "devices": devices_schema
404 "required": ["name", "VNFC image"],
405 "additionalProperties": False
409 "title":"vnfd information schema v0.1",
410 "$schema": "http://json-schema.org/draft-04/schema#",
417 "description": description_schema
,
418 "class": nameshort_schema
,
419 "public": {"type" : "boolean"},
420 "physical": {"type" : "boolean"},
421 "tenant_id": id_schema
, #only valid for admin
422 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
423 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
424 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
426 "required": ["name","external-connections"],
427 "additionalProperties": True
431 "additionalProperties": False
434 #Future VNFD schema to be defined
436 "title":"vnfd information schema v0.2",
437 "$schema": "http://json-schema.org/draft-04/schema#",
440 "schema_version": schema_version_2
,
446 "required": ["name"],
447 "additionalProperties": True
450 "required": ["vnf", "schema_version"],
451 "additionalProperties": False
454 #vnfd_schema = vnfd_schema_v01
456 # "title":"vnfd information schema v0.2",
457 # "$schema": "http://json-schema.org/draft-04/schema#",
458 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
462 "title":"graphical scenario descriptor information schema",
463 "$schema": "http://json-schema.org/draft-04/schema#",
466 "x": integer0_schema
,
467 "y": integer0_schema
,
471 "left": {"type":"array"},
472 "right": {"type":"array"},
473 "bottom": {"type":"array"},
477 "required": ["x","y"]
481 "title":"network scenario descriptor information schema v0.1",
482 "$schema": "http://json-schema.org/draft-04/schema#",
486 "description": description_schema
,
487 "tenant_id": id_schema
, #only valid for admin
488 "public": {"type": "boolean"},
494 "patternProperties":{
498 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
500 "graph": graph_schema
,
502 "patternProperties":{
503 "^(VNF )?model$": {"type": "string"}
511 "patternProperties":{
515 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
516 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
517 "graph": graph_schema
519 "required": ["nodes"]
524 "required": ["nodes"],
525 "additionalProperties": False
528 "required": ["name","topology"],
529 "additionalProperties": False
532 #Future NSD schema to be defined
534 "title":"network scenario descriptor information schema v0.2",
535 "$schema": "http://json-schema.org/draft-04/schema#",
538 "schema_version": schema_version_2
,
543 "description": description_schema
,
544 "tenant_id": id_schema
, #only valid for admin
545 "public": {"type": "boolean"},
548 "patternProperties":{
553 "graph": graph_schema
,
554 "vnf_name": name_schema
,
562 "patternProperties":{
566 "interfaces":{"type":"array", "minLength":1},
567 "type": {"type": "string", "enum":["dataplane", "bridge"]},
568 "external" : {"type": "boolean"},
569 "graph": graph_schema
571 "required": ["interfaces"]
577 "required": ["vnfs", "networks","name"],
578 "additionalProperties": False
581 "required": ["scenario","schema_version"],
582 "additionalProperties": False
585 #scenario_new_schema = {
586 # "title":"new scenario information schema",
587 # "$schema": "http://json-schema.org/draft-04/schema#",
588 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
589 # "oneOf": [nsd_schema_v01]
592 scenario_edit_schema
= {
593 "title":"edit scenario information schema",
594 "$schema": "http://json-schema.org/draft-04/schema#",
598 "description": description_schema
,
604 "patternProperties":{
605 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
611 "x": integer0_schema
,
612 "y": integer0_schema
,
613 "ifaces":{ "type": "object"}
616 "description": description_schema
,
623 "required": ["nodes"],
624 "additionalProperties": False
627 "additionalProperties": False
630 scenario_action_schema
= {
631 "title":"scenario action information schema",
632 "$schema": "http://json-schema.org/draft-04/schema#",
638 "instance_name":name_schema
,
639 "description":description_schema
,
640 "datacenter": {"type": "string"}
642 "required": ["instance_name"]
647 "instance_name":name_schema
,
648 "description":description_schema
,
649 "datacenter": {"type": "string"}
651 "required": ["instance_name"]
656 "instance_name":name_schema
,
657 "description":description_schema
,
658 "datacenter": {"type": "string"}
660 "required": ["instance_name"]
665 "instance_name":name_schema
,
666 "description":description_schema
,
667 "datacenter": {"type": "string"}
669 "required": ["instance_name"]
674 "additionalProperties": False
677 instance_scenario_create_schema
= {
678 "title":"instance scenario create information schema v0.1",
679 "$schema": "http://json-schema.org/draft-04/schema#",
682 "schema_version": {"type": "string", "enum": ["0.1"]},
687 "description":description_schema
,
688 "datacenter": name_schema
,
689 "scenario" : name_schema
, #can be an UUID or name
690 "action":{"enum": ["deploy","reserve","verify" ]},
691 "connect_mgmt_interfaces": {"oneOff": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
692 "vnfs":{ #mapping from scenario to datacenter
694 "patternProperties":{
698 "name": name_schema
,#override vnf name
699 "datacenter": name_schema
,
700 "metadata": {"type": "object"},
701 "user_data": {"type": "string"}
706 "networks":{ #mapping from scenario to datacenter
708 "patternProperties":{
712 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
713 "netmap-use": name_schema
,
714 "name": name_schema
,#override network name
715 "datacenter": name_schema
,
721 "additionalProperties": False,
722 "required": ["scenario", "name"]
725 "required": ["instance"],
726 "additionalProperties": False
730 instance_scenario_action_schema
= {
731 "title":"instance scenario action information schema",
732 "$schema": "http://json-schema.org/draft-04/schema#",
735 "start":{"type": "null"},
736 "pause":{"type": "null"},
737 "resume":{"type": "null"},
738 "shutoff":{"type": "null"},
739 "shutdown":{"type": "null"},
740 "forceOff":{"type": "null"},
741 "rebuild":{"type": "null"},
743 "type": ["object","null"],
745 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
746 "vnfs":{"type": "array", "items":{"type":"string"}},
747 "vms":{"type": "array", "items":{"type":"string"}}
751 "additionalProperties": False