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_proxy": {"type":"boolean"},
92 "http_console_host": nameshort_schema
,
93 "http_console_ports": {
97 {"type":"object", "properties":{"from": port_schema
, "to": port_schema
}, "required": ["from","to"]}
100 "log_level": log_level_schema
,
101 "log_socket_level": log_level_schema
,
102 "log_level_db": log_level_schema
,
103 "log_level_vimconn": log_level_schema
,
104 "log_level_nfvo": log_level_schema
,
105 "log_socket_host": nameshort_schema
,
106 "log_socket_port": port_schema
,
107 "log_file": path_schema
,
109 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
110 "additionalProperties": False
114 "title":"tenant information schema",
115 "$schema": "http://json-schema.org/draft-04/schema#",
121 "name": nameshort_schema
,
122 "description": description_schema
,
124 "required": ["name"],
125 "additionalProperties": True
128 "required": ["tenant"],
129 "additionalProperties": False
131 tenant_edit_schema
= {
132 "title":"tenant edit information schema",
133 "$schema": "http://json-schema.org/draft-04/schema#",
140 "description": description_schema
,
142 "additionalProperties": False
145 "required": ["tenant"],
146 "additionalProperties": False
149 datacenter_schema_properties
={
151 "description": description_schema
,
152 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarge with plugins
153 "vim_url": description_schema
,
154 "vim_url_admin": description_schema
,
155 "config": { "type":"object" }
158 datacenter_schema
= {
159 "title":"datacenter information schema",
160 "$schema": "http://json-schema.org/draft-04/schema#",
165 "properties":datacenter_schema_properties
,
166 "required": ["name", "vim_url"],
167 "additionalProperties": True
170 "required": ["datacenter"],
171 "additionalProperties": False
175 datacenter_edit_schema
= {
176 "title":"datacenter edit nformation schema",
177 "$schema": "http://json-schema.org/draft-04/schema#",
182 "properties":datacenter_schema_properties
,
183 "additionalProperties": False
186 "required": ["datacenter"],
187 "additionalProperties": False
191 netmap_new_schema
= {
192 "title":"netmap new information schema",
193 "$schema": "http://json-schema.org/draft-04/schema#",
196 "netmap":{ #delete from datacenter
199 "name": name_schema
, #name or uuid of net to change
201 "vim_name": name_schema
204 "additionalProperties": False
207 "required": ["netmap"],
208 "additionalProperties": False
211 netmap_edit_schema
= {
212 "title":"netmap edit information schema",
213 "$schema": "http://json-schema.org/draft-04/schema#",
216 "netmap":{ #delete from datacenter
219 "name": name_schema
, #name or uuid of net to change
222 "additionalProperties": False
225 "required": ["netmap"],
226 "additionalProperties": False
229 datacenter_action_schema
= {
230 "title":"datacenter action information schema",
231 "$schema": "http://json-schema.org/draft-04/schema#",
234 "net-update":{"type":"null",},
238 "net": name_schema
, #name or uuid of net to change
240 "description": description_schema
,
241 "shared": {"type": "boolean"}
244 "additionalProperties": False
249 "net": name_schema
, #name or uuid of net to change
252 "additionalProperties": False
257 "additionalProperties": False
261 datacenter_associate_schema
={
262 "title":"datacenter associate information schema",
263 "$schema": "http://json-schema.org/draft-04/schema#",
269 "vim_tenant": id_schema
,
270 "vim_tenant_name": nameshort_schema
,
271 "vim_username": nameshort_schema
,
272 "vim_password": nameshort_schema
,
274 # "required": ["vim_tenant"],
275 "additionalProperties": True
278 "required": ["datacenter"],
279 "additionalProperties": False
282 internal_connection_element_schema
= {
286 "local_iface_name": name_schema
290 internal_connection_schema
= {
294 "description":description_schema
,
295 "type":{"type":"string", "enum":["bridge","data","ptp"]},
296 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
298 "required": ["name", "type", "elements"],
299 "additionalProperties": False
302 external_connection_schema
= {
306 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
308 "local_iface_name": name_schema
,
309 "description":description_schema
311 "required": ["name", "type", "VNFC", "local_iface_name"],
312 "additionalProperties": False
321 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
322 "bandwidth":bandwidth_schema
,
324 "mac_address": mac_schema
326 "additionalProperties": False,
327 "required": ["name","dedicated", "bandwidth"]
331 bridge_interfaces_schema
={
337 "bandwidth":bandwidth_schema
,
339 "mac_address": mac_schema
,
340 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
342 "additionalProperties": False,
352 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
353 "image": path_schema
,
354 "image metadata": metadata_schema
,
356 "xml":xml_text_schema
,
358 "additionalProperties": False,
367 "memory":integer1_schema
,
368 "cores":integer1_schema
,
369 "paired-threads":integer1_schema
,
370 "threads":integer1_schema
,
371 "cores-id":{"type":"array","items":integer0_schema
},
372 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
373 "threads-id":{"type":"array","items":integer0_schema
},
374 "interfaces":interfaces_schema
376 "additionalProperties": False,
377 #"required": ["memory"]
384 "description": description_schema
,
385 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
386 "image metadata": metadata_schema
,
390 "model":description_schema
,
391 "features":{"type":"array","items":nameshort_schema
}
393 "required": ["model"],
394 "additionalProperties": False
399 "type":nameshort_schema
,
400 "version":description_schema
403 "ram":integer0_schema
,
404 "vcpus":integer0_schema
,
405 "disk": integer1_schema
,
410 "bridge-ifaces": bridge_interfaces_schema
,
411 "devices": devices_schema
413 "required": ["name", "VNFC image"],
414 "additionalProperties": False
418 "title":"vnfd information schema v0.1",
419 "$schema": "http://json-schema.org/draft-04/schema#",
426 "description": description_schema
,
427 "class": nameshort_schema
,
428 "public": {"type" : "boolean"},
429 "physical": {"type" : "boolean"},
430 "tenant_id": id_schema
, #only valid for admin
431 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
432 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
433 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
435 "required": ["name","external-connections"],
436 "additionalProperties": True
440 "additionalProperties": False
443 #Future VNFD schema to be defined
445 "title":"vnfd information schema v0.2",
446 "$schema": "http://json-schema.org/draft-04/schema#",
449 "schema_version": schema_version_2
,
455 "required": ["name"],
456 "additionalProperties": True
459 "required": ["vnf", "schema_version"],
460 "additionalProperties": False
463 #vnfd_schema = vnfd_schema_v01
465 # "title":"vnfd information schema v0.2",
466 # "$schema": "http://json-schema.org/draft-04/schema#",
467 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
471 "title":"graphical scenario descriptor information schema",
472 "$schema": "http://json-schema.org/draft-04/schema#",
475 "x": integer0_schema
,
476 "y": integer0_schema
,
480 "left": {"type":"array"},
481 "right": {"type":"array"},
482 "bottom": {"type":"array"},
486 "required": ["x","y"]
490 "title":"network scenario descriptor information schema v0.1",
491 "$schema": "http://json-schema.org/draft-04/schema#",
495 "description": description_schema
,
496 "tenant_id": id_schema
, #only valid for admin
497 "public": {"type": "boolean"},
503 "patternProperties":{
507 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
509 "graph": graph_schema
,
511 "patternProperties":{
512 "^(VNF )?model$": {"type": "string"}
520 "patternProperties":{
524 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
525 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
526 "graph": graph_schema
528 "required": ["nodes"]
533 "required": ["nodes"],
534 "additionalProperties": False
537 "required": ["name","topology"],
538 "additionalProperties": False
541 #Future NSD schema to be defined
543 "title":"network scenario descriptor information schema v0.2",
544 "$schema": "http://json-schema.org/draft-04/schema#",
547 "schema_version": schema_version_2
,
552 "description": description_schema
,
553 "tenant_id": id_schema
, #only valid for admin
554 "public": {"type": "boolean"},
557 "patternProperties":{
562 "graph": graph_schema
,
563 "vnf_name": name_schema
,
571 "patternProperties":{
575 "interfaces":{"type":"array", "minLength":1},
576 "type": {"type": "string", "enum":["dataplane", "bridge"]},
577 "external" : {"type": "boolean"},
578 "graph": graph_schema
580 "required": ["interfaces"]
586 "required": ["vnfs", "networks","name"],
587 "additionalProperties": False
590 "required": ["scenario","schema_version"],
591 "additionalProperties": False
594 #scenario_new_schema = {
595 # "title":"new scenario information schema",
596 # "$schema": "http://json-schema.org/draft-04/schema#",
597 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
598 # "oneOf": [nsd_schema_v01]
601 scenario_edit_schema
= {
602 "title":"edit scenario information schema",
603 "$schema": "http://json-schema.org/draft-04/schema#",
607 "description": description_schema
,
613 "patternProperties":{
614 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
620 "x": integer0_schema
,
621 "y": integer0_schema
,
622 "ifaces":{ "type": "object"}
625 "description": description_schema
,
632 "required": ["nodes"],
633 "additionalProperties": False
636 "additionalProperties": False
639 scenario_action_schema
= {
640 "title":"scenario action information schema",
641 "$schema": "http://json-schema.org/draft-04/schema#",
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 "instance_name":name_schema
,
675 "description":description_schema
,
676 "datacenter": {"type": "string"}
678 "required": ["instance_name"]
683 "additionalProperties": False
686 instance_scenario_create_schema
= {
687 "title":"instance scenario create information schema v0.1",
688 "$schema": "http://json-schema.org/draft-04/schema#",
691 "schema_version": {"type": "string", "enum": ["0.1"]},
696 "description":description_schema
,
697 "datacenter": name_schema
,
698 "scenario" : name_schema
, #can be an UUID or name
699 "action":{"enum": ["deploy","reserve","verify" ]},
700 "connect_mgmt_interfaces": {"oneOff": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
701 "vnfs":{ #mapping from scenario to datacenter
703 "patternProperties":{
707 "name": name_schema
,#override vnf name
708 "datacenter": name_schema
,
709 "metadata": {"type": "object"},
710 "user_data": {"type": "string"}
715 "networks":{ #mapping from scenario to datacenter
717 "patternProperties":{
721 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
722 "netmap-use": name_schema
,
723 "name": name_schema
,#override network name
724 "datacenter": name_schema
,
730 "additionalProperties": False,
731 "required": ["scenario", "name"]
734 "required": ["instance"],
735 "additionalProperties": False
739 instance_scenario_action_schema
= {
740 "title":"instance scenario action information schema",
741 "$schema": "http://json-schema.org/draft-04/schema#",
744 "start":{"type": "null"},
745 "pause":{"type": "null"},
746 "resume":{"type": "null"},
747 "shutoff":{"type": "null"},
748 "shutdown":{"type": "null"},
749 "forceOff":{"type": "null"},
750 "rebuild":{"type": "null"},
752 "type": ["object","null"],
754 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
755 "vnfs":{"type": "array", "items":{"type":"string"}},
756 "vms":{"type": "array", "items":{"type":"string"}}
760 "additionalProperties": False