1 # -*- coding: utf-8 -*-
4 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5 # This file is part of openmano
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
12 # http://www.apache.org/licenses/LICENSE-2.0
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
20 # For those usages not covered by the Apache License, Version 2.0 please
21 # contact with: nfvlabs@tid.es
25 JSON schemas used by openmano httpserver.py module to parse the different files and messages sent through the API
27 __author__
="Alfonso Tierno, Gerardo Garcia"
28 __date__
="$09-oct-2014 09:09:48$"
31 patern_name
="^[ -~]+$"
32 passwd_schema
={"type" : "string", "minLength":1, "maxLength":60}
33 nameshort_schema
={"type" : "string", "minLength":1, "maxLength":60, "pattern" : "^[^,;()'\"]+$"}
34 name_schema
={"type" : "string", "minLength":1, "maxLength":255, "pattern" : "^[^,;()'\"]+$"}
35 xml_text_schema
={"type" : "string", "minLength":1, "maxLength":1000, "pattern" : "^[^']+$"}
36 description_schema
={"type" : ["string","null"], "maxLength":255, "pattern" : "^[^'\"]+$"}
37 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}$"
38 id_schema
= {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
39 pci_schema
={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
40 http_schema
={"type":"string", "pattern":"^https?://[^'\"=]+$"}
41 bandwidth_schema
={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
42 memory_schema
={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
43 integer0_schema
={"type":"integer","minimum":0}
44 integer1_schema
={"type":"integer","minimum":1}
45 path_schema
={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
46 vlan_schema
={"type":"integer","minimum":1,"maximum":4095}
47 vlan1000_schema
={"type":"integer","minimum":1000,"maximum":4095}
48 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
49 #mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
50 ip_schema
={"type":"string","pattern":"^([0-9]{1,3}.){3}[0-9]{1,3}$"}
51 port_schema
={"type":"integer","minimum":1,"maximum":65534}
52 object_schema
={"type":"object"}
53 schema_version_2
={"type":"integer","minimum":2,"maximum":2}
54 log_level_schema
={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
59 "architecture": {"type":"string"},
60 "use_incremental": {"type":"string","enum":["yes","no"]},
62 "os_distro": {"type":"string"},
63 "os_type": {"type":"string"},
64 "os_version": {"type":"string"},
65 "bus": {"type":"string"},
66 "topology": {"type":"string", "enum": ["oneSocket"]}
70 #Schema for the configuration file
72 "title":"configuration response information schema",
73 "$schema": "http://json-schema.org/draft-04/schema#",
76 "http_port": port_schema
,
77 "http_admin_port": port_schema
,
78 "http_host": nameshort_schema
,
79 "vnf_repository": path_schema
,
80 "db_host": nameshort_schema
,
81 "db_user": nameshort_schema
,
82 "db_passwd": {"type":"string"},
83 "db_name": nameshort_schema
,
84 # Next fields will disappear once the MANO API includes appropriate primitives
85 "vim_url": http_schema
,
86 "vim_url_admin": http_schema
,
87 "vim_name": nameshort_schema
,
88 "vim_tenant_name": nameshort_schema
,
89 "mano_tenant_name": nameshort_schema
,
90 "mano_tenant_id": id_schema
,
91 "http_console_ports": {
95 {"type":"object", "properties":{"from": port_schema
, "to": port_schema
}, "required": ["from","to"]}
98 "log_level": log_level_schema
,
99 "log_level_db": log_level_schema
,
100 "log_level_vimconn": log_level_schema
,
101 "log_level_nfvo": log_level_schema
,
102 "log_host": nameshort_schema
,
103 "log_port": port_schema
,
104 "log_file": path_schema
,
106 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
107 "additionalProperties": False
111 "title":"tenant information schema",
112 "$schema": "http://json-schema.org/draft-04/schema#",
118 "name": nameshort_schema
,
119 "description": description_schema
,
121 "required": ["name"],
122 "additionalProperties": True
125 "required": ["tenant"],
126 "additionalProperties": False
128 tenant_edit_schema
= {
129 "title":"tenant edit information schema",
130 "$schema": "http://json-schema.org/draft-04/schema#",
137 "description": description_schema
,
139 "additionalProperties": False
142 "required": ["tenant"],
143 "additionalProperties": False
146 datacenter_schema_properties
={
148 "description": description_schema
,
149 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarge with plugins
150 "vim_url": description_schema
,
151 "vim_url_admin": description_schema
,
152 "config": { "type":"object" }
155 datacenter_schema
= {
156 "title":"datacenter information schema",
157 "$schema": "http://json-schema.org/draft-04/schema#",
162 "properties":datacenter_schema_properties
,
163 "required": ["name", "vim_url"],
164 "additionalProperties": True
167 "required": ["datacenter"],
168 "additionalProperties": False
172 datacenter_edit_schema
= {
173 "title":"datacenter edit nformation schema",
174 "$schema": "http://json-schema.org/draft-04/schema#",
179 "properties":datacenter_schema_properties
,
180 "additionalProperties": False
183 "required": ["datacenter"],
184 "additionalProperties": False
188 netmap_new_schema
= {
189 "title":"netmap new information schema",
190 "$schema": "http://json-schema.org/draft-04/schema#",
193 "netmap":{ #delete from datacenter
196 "name": name_schema
, #name or uuid of net to change
198 "vim_name": name_schema
201 "additionalProperties": False
204 "required": ["netmap"],
205 "additionalProperties": False
208 netmap_edit_schema
= {
209 "title":"netmap edit information schema",
210 "$schema": "http://json-schema.org/draft-04/schema#",
213 "netmap":{ #delete from datacenter
216 "name": name_schema
, #name or uuid of net to change
219 "additionalProperties": False
222 "required": ["netmap"],
223 "additionalProperties": False
226 datacenter_action_schema
= {
227 "title":"datacenter action information schema",
228 "$schema": "http://json-schema.org/draft-04/schema#",
231 "net-update":{"type":"null",},
235 "net": name_schema
, #name or uuid of net to change
237 "description": description_schema
,
238 "shared": {"type": "boolean"}
241 "additionalProperties": False
246 "net": name_schema
, #name or uuid of net to change
249 "additionalProperties": False
254 "additionalProperties": False
258 datacenter_associate_schema
={
259 "title":"datacenter associate information schema",
260 "$schema": "http://json-schema.org/draft-04/schema#",
266 "vim_tenant": id_schema
,
267 "vim_tenant_name": nameshort_schema
,
268 "vim_username": nameshort_schema
,
269 "vim_password": nameshort_schema
,
271 # "required": ["vim_tenant"],
272 "additionalProperties": True
275 "required": ["datacenter"],
276 "additionalProperties": False
279 internal_connection_element_schema
= {
283 "local_iface_name": name_schema
287 internal_connection_schema
= {
291 "description":description_schema
,
292 "type":{"type":"string", "enum":["bridge","data","ptp"]},
293 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
295 "required": ["name", "type", "elements"],
296 "additionalProperties": False
299 external_connection_schema
= {
303 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
305 "local_iface_name": name_schema
,
306 "description":description_schema
308 "required": ["name", "type", "VNFC", "local_iface_name"],
309 "additionalProperties": False
318 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
319 "bandwidth":bandwidth_schema
,
321 "mac_address": mac_schema
323 "additionalProperties": False,
324 "required": ["name","dedicated", "bandwidth"]
328 bridge_interfaces_schema
={
334 "bandwidth":bandwidth_schema
,
336 "mac_address": mac_schema
,
337 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
339 "additionalProperties": False,
349 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
350 "image": path_schema
,
351 "image metadata": metadata_schema
,
353 "xml":xml_text_schema
,
355 "additionalProperties": False,
364 "memory":integer1_schema
,
365 "cores":integer1_schema
,
366 "paired-threads":integer1_schema
,
367 "threads":integer1_schema
,
368 "cores-id":{"type":"array","items":integer0_schema
},
369 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
370 "threads-id":{"type":"array","items":integer0_schema
},
371 "interfaces":interfaces_schema
373 "additionalProperties": False,
374 #"required": ["memory"]
381 "description": description_schema
,
382 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
383 "image metadata": metadata_schema
,
387 "model":description_schema
,
388 "features":{"type":"array","items":nameshort_schema
}
390 "required": ["model"],
391 "additionalProperties": False
396 "type":nameshort_schema
,
397 "version":description_schema
400 "ram":integer0_schema
,
401 "vcpus":integer0_schema
,
402 "disk": integer1_schema
,
407 "bridge-ifaces": bridge_interfaces_schema
,
408 "devices": devices_schema
410 "required": ["name", "VNFC image"],
411 "additionalProperties": False
415 "title":"vnfd information schema v0.1",
416 "$schema": "http://json-schema.org/draft-04/schema#",
423 "description": description_schema
,
424 "class": nameshort_schema
,
425 "public": {"type" : "boolean"},
426 "physical": {"type" : "boolean"},
427 "tenant_id": id_schema
, #only valid for admin
428 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
429 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
430 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
432 "required": ["name","external-connections"],
433 "additionalProperties": True
437 "additionalProperties": False
440 #Future VNFD schema to be defined
442 "title":"vnfd information schema v0.2",
443 "$schema": "http://json-schema.org/draft-04/schema#",
446 "schema_version": schema_version_2
,
452 "required": ["name"],
453 "additionalProperties": True
456 "required": ["vnf", "schema_version"],
457 "additionalProperties": False
460 #vnfd_schema = vnfd_schema_v01
462 # "title":"vnfd information schema v0.2",
463 # "$schema": "http://json-schema.org/draft-04/schema#",
464 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
468 "title":"graphical scenario descriptor information schema",
469 "$schema": "http://json-schema.org/draft-04/schema#",
472 "x": integer0_schema
,
473 "y": integer0_schema
,
477 "left": {"type":"array"},
478 "right": {"type":"array"},
479 "bottom": {"type":"array"},
483 "required": ["x","y"]
487 "title":"network scenario descriptor information schema v0.1",
488 "$schema": "http://json-schema.org/draft-04/schema#",
492 "description": description_schema
,
493 "tenant_id": id_schema
, #only valid for admin
494 "public": {"type": "boolean"},
500 "patternProperties":{
504 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
506 "graph": graph_schema
,
508 "patternProperties":{
509 "^(VNF )?model$": {"type": "string"}
517 "patternProperties":{
521 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
522 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
523 "graph": graph_schema
525 "required": ["nodes"]
530 "required": ["nodes"],
531 "additionalProperties": False
534 "required": ["name","topology"],
535 "additionalProperties": False
538 #Future NSD schema to be defined
540 "title":"network scenario descriptor information schema v0.2",
541 "$schema": "http://json-schema.org/draft-04/schema#",
544 "schema_version": schema_version_2
,
549 "description": description_schema
,
550 "tenant_id": id_schema
, #only valid for admin
551 "public": {"type": "boolean"},
554 "patternProperties":{
559 "graph": graph_schema
,
560 "vnf_name": name_schema
,
568 "patternProperties":{
572 "interfaces":{"type":"array", "minLength":1},
573 "type": {"type": "string", "enum":["dataplane", "bridge"]},
574 "external" : {"type": "boolean"},
575 "graph": graph_schema
577 "required": ["interfaces"]
583 "required": ["vnfs", "networks","name"],
584 "additionalProperties": False
587 "required": ["scenario","schema_version"],
588 "additionalProperties": False
591 #scenario_new_schema = {
592 # "title":"new scenario information schema",
593 # "$schema": "http://json-schema.org/draft-04/schema#",
594 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
595 # "oneOf": [nsd_schema_v01]
598 scenario_edit_schema
= {
599 "title":"edit scenario information schema",
600 "$schema": "http://json-schema.org/draft-04/schema#",
604 "description": description_schema
,
610 "patternProperties":{
611 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
617 "x": integer0_schema
,
618 "y": integer0_schema
,
619 "ifaces":{ "type": "object"}
622 "description": description_schema
,
629 "required": ["nodes"],
630 "additionalProperties": False
633 "additionalProperties": False
636 scenario_action_schema
= {
637 "title":"scenario action information schema",
638 "$schema": "http://json-schema.org/draft-04/schema#",
644 "instance_name":name_schema
,
645 "description":description_schema
,
646 "datacenter": {"type": "string"}
648 "required": ["instance_name"]
653 "instance_name":name_schema
,
654 "description":description_schema
,
655 "datacenter": {"type": "string"}
657 "required": ["instance_name"]
662 "instance_name":name_schema
,
663 "description":description_schema
,
664 "datacenter": {"type": "string"}
666 "required": ["instance_name"]
671 "instance_name":name_schema
,
672 "description":description_schema
,
673 "datacenter": {"type": "string"}
675 "required": ["instance_name"]
680 "additionalProperties": False
683 instance_scenario_create_schema
= {
684 "title":"instance scenario create information schema v0.1",
685 "$schema": "http://json-schema.org/draft-04/schema#",
688 "schema_version": {"type": "string", "enum": ["0.1"]},
693 "description":description_schema
,
694 "datacenter": name_schema
,
695 "scenario" : name_schema
, #can be an UUID or name
696 "action":{"enum": ["deploy","reserve","verify" ]},
697 "connect_mgmt_interfaces": {"oneOff": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
698 "vnfs":{ #mapping from scenario to datacenter
700 "patternProperties":{
704 "name": name_schema
,#override vnf name
705 "datacenter": name_schema
,
706 "metadata": {"type": "object"},
707 "user_data": {"type": "string"}
712 "networks":{ #mapping from scenario to datacenter
714 "patternProperties":{
718 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
719 "netmap-use": name_schema
,
720 "name": name_schema
,#override network name
721 "datacenter": name_schema
,
727 "additionalProperties": False,
728 "required": ["scenario", "name"]
731 "required": ["instance"],
732 "additionalProperties": False
736 instance_scenario_action_schema
= {
737 "title":"instance scenario action information schema",
738 "$schema": "http://json-schema.org/draft-04/schema#",
741 "start":{"type": "null"},
742 "pause":{"type": "null"},
743 "resume":{"type": "null"},
744 "shutoff":{"type": "null"},
745 "shutdown":{"type": "null"},
746 "forceOff":{"type": "null"},
747 "rebuild":{"type": "null"},
749 "type": ["object","null"],
751 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
752 "vnfs":{"type": "array", "items":{"type":"string"}},
753 "vms":{"type": "array", "items":{"type":"string"}}
757 "additionalProperties": False