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
102 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
103 "additionalProperties": False
107 "title":"tenant information schema",
108 "$schema": "http://json-schema.org/draft-04/schema#",
114 "name": nameshort_schema
,
115 "description": description_schema
,
117 "required": ["name"],
118 "additionalProperties": True
121 "required": ["tenant"],
122 "additionalProperties": False
124 tenant_edit_schema
= {
125 "title":"tenant edit information schema",
126 "$schema": "http://json-schema.org/draft-04/schema#",
133 "description": description_schema
,
135 "additionalProperties": False
138 "required": ["tenant"],
139 "additionalProperties": False
142 datacenter_schema_properties
={
144 "description": description_schema
,
145 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarge with plugins
146 "vim_url": description_schema
,
147 "vim_url_admin": description_schema
,
148 "config": { "type":"object" }
151 datacenter_schema
= {
152 "title":"datacenter information schema",
153 "$schema": "http://json-schema.org/draft-04/schema#",
158 "properties":datacenter_schema_properties
,
159 "required": ["name", "vim_url"],
160 "additionalProperties": True
163 "required": ["datacenter"],
164 "additionalProperties": False
168 datacenter_edit_schema
= {
169 "title":"datacenter edit nformation schema",
170 "$schema": "http://json-schema.org/draft-04/schema#",
175 "properties":datacenter_schema_properties
,
176 "additionalProperties": False
179 "required": ["datacenter"],
180 "additionalProperties": False
184 netmap_new_schema
= {
185 "title":"netmap new information schema",
186 "$schema": "http://json-schema.org/draft-04/schema#",
189 "netmap":{ #delete from datacenter
192 "name": name_schema
, #name or uuid of net to change
194 "vim_name": name_schema
197 "additionalProperties": False
200 "required": ["netmap"],
201 "additionalProperties": False
204 netmap_edit_schema
= {
205 "title":"netmap edit information schema",
206 "$schema": "http://json-schema.org/draft-04/schema#",
209 "netmap":{ #delete from datacenter
212 "name": name_schema
, #name or uuid of net to change
215 "additionalProperties": False
218 "required": ["netmap"],
219 "additionalProperties": False
222 datacenter_action_schema
= {
223 "title":"datacenter action information schema",
224 "$schema": "http://json-schema.org/draft-04/schema#",
227 "net-update":{"type":"null",},
231 "net": name_schema
, #name or uuid of net to change
233 "description": description_schema
,
234 "shared": {"type": "boolean"}
237 "additionalProperties": False
242 "net": name_schema
, #name or uuid of net to change
245 "additionalProperties": False
250 "additionalProperties": False
254 datacenter_associate_schema
={
255 "title":"datacenter associate information schema",
256 "$schema": "http://json-schema.org/draft-04/schema#",
262 "vim_tenant": id_schema
,
263 "vim_tenant_name": nameshort_schema
,
264 "vim_username": nameshort_schema
,
265 "vim_password": nameshort_schema
,
267 # "required": ["vim_tenant"],
268 "additionalProperties": True
271 "required": ["datacenter"],
272 "additionalProperties": False
275 internal_connection_element_schema
= {
279 "local_iface_name": name_schema
283 internal_connection_schema
= {
287 "description":description_schema
,
288 "type":{"type":"string", "enum":["bridge","data","ptp"]},
289 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
291 "required": ["name", "type", "elements"],
292 "additionalProperties": False
295 external_connection_schema
= {
299 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
301 "local_iface_name": name_schema
,
302 "description":description_schema
304 "required": ["name", "type", "VNFC", "local_iface_name"],
305 "additionalProperties": False
314 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
315 "bandwidth":bandwidth_schema
,
317 "mac_address": mac_schema
319 "additionalProperties": False,
320 "required": ["name","dedicated", "bandwidth"]
324 bridge_interfaces_schema
={
330 "bandwidth":bandwidth_schema
,
332 "mac_address": mac_schema
,
333 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
335 "additionalProperties": False,
345 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
346 "image": path_schema
,
347 "image metadata": metadata_schema
,
349 "xml":xml_text_schema
,
351 "additionalProperties": False,
360 "memory":integer1_schema
,
361 "cores":integer1_schema
,
362 "paired-threads":integer1_schema
,
363 "threads":integer1_schema
,
364 "cores-id":{"type":"array","items":integer0_schema
},
365 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
366 "threads-id":{"type":"array","items":integer0_schema
},
367 "interfaces":interfaces_schema
369 "additionalProperties": False,
370 #"required": ["memory"]
377 "description": description_schema
,
378 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
379 "image metadata": metadata_schema
,
383 "model":description_schema
,
384 "features":{"type":"array","items":nameshort_schema
}
386 "required": ["model"],
387 "additionalProperties": False
392 "type":nameshort_schema
,
393 "version":description_schema
396 "ram":integer0_schema
,
397 "vcpus":integer0_schema
,
398 "disk": integer1_schema
,
403 "bridge-ifaces": bridge_interfaces_schema
,
404 "devices": devices_schema
406 "required": ["name", "VNFC image"],
407 "additionalProperties": False
411 "title":"vnfd information schema v0.1",
412 "$schema": "http://json-schema.org/draft-04/schema#",
419 "description": description_schema
,
420 "class": nameshort_schema
,
421 "public": {"type" : "boolean"},
422 "physical": {"type" : "boolean"},
423 "tenant_id": id_schema
, #only valid for admin
424 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
425 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
426 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
428 "required": ["name","external-connections"],
429 "additionalProperties": True
433 "additionalProperties": False
436 #Future VNFD schema to be defined
438 "title":"vnfd information schema v0.2",
439 "$schema": "http://json-schema.org/draft-04/schema#",
442 "schema_version": schema_version_2
,
448 "required": ["name"],
449 "additionalProperties": True
452 "required": ["vnf", "schema_version"],
453 "additionalProperties": False
456 #vnfd_schema = vnfd_schema_v01
458 # "title":"vnfd information schema v0.2",
459 # "$schema": "http://json-schema.org/draft-04/schema#",
460 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
464 "title":"graphical scenario descriptor information schema",
465 "$schema": "http://json-schema.org/draft-04/schema#",
468 "x": integer0_schema
,
469 "y": integer0_schema
,
473 "left": {"type":"array"},
474 "right": {"type":"array"},
475 "bottom": {"type":"array"},
479 "required": ["x","y"]
483 "title":"network scenario descriptor information schema v0.1",
484 "$schema": "http://json-schema.org/draft-04/schema#",
488 "description": description_schema
,
489 "tenant_id": id_schema
, #only valid for admin
490 "public": {"type": "boolean"},
496 "patternProperties":{
500 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
502 "graph": graph_schema
,
504 "patternProperties":{
505 "^(VNF )?model$": {"type": "string"}
513 "patternProperties":{
517 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
518 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
519 "graph": graph_schema
521 "required": ["nodes"]
526 "required": ["nodes"],
527 "additionalProperties": False
530 "required": ["name","topology"],
531 "additionalProperties": False
534 #Future NSD schema to be defined
536 "title":"network scenario descriptor information schema v0.2",
537 "$schema": "http://json-schema.org/draft-04/schema#",
540 "schema_version": schema_version_2
,
545 "description": description_schema
,
546 "tenant_id": id_schema
, #only valid for admin
547 "public": {"type": "boolean"},
550 "patternProperties":{
555 "graph": graph_schema
,
556 "vnf_name": name_schema
,
564 "patternProperties":{
568 "interfaces":{"type":"array", "minLength":1},
569 "type": {"type": "string", "enum":["dataplane", "bridge"]},
570 "external" : {"type": "boolean"},
571 "graph": graph_schema
573 "required": ["interfaces"]
579 "required": ["vnfs", "networks","name"],
580 "additionalProperties": False
583 "required": ["scenario","schema_version"],
584 "additionalProperties": False
587 #scenario_new_schema = {
588 # "title":"new scenario information schema",
589 # "$schema": "http://json-schema.org/draft-04/schema#",
590 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
591 # "oneOf": [nsd_schema_v01]
594 scenario_edit_schema
= {
595 "title":"edit scenario information schema",
596 "$schema": "http://json-schema.org/draft-04/schema#",
600 "description": description_schema
,
606 "patternProperties":{
607 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
613 "x": integer0_schema
,
614 "y": integer0_schema
,
615 "ifaces":{ "type": "object"}
618 "description": description_schema
,
625 "required": ["nodes"],
626 "additionalProperties": False
629 "additionalProperties": False
632 scenario_action_schema
= {
633 "title":"scenario action information schema",
634 "$schema": "http://json-schema.org/draft-04/schema#",
640 "instance_name":name_schema
,
641 "description":description_schema
,
642 "datacenter": {"type": "string"}
644 "required": ["instance_name"]
649 "instance_name":name_schema
,
650 "description":description_schema
,
651 "datacenter": {"type": "string"}
653 "required": ["instance_name"]
658 "instance_name":name_schema
,
659 "description":description_schema
,
660 "datacenter": {"type": "string"}
662 "required": ["instance_name"]
667 "instance_name":name_schema
,
668 "description":description_schema
,
669 "datacenter": {"type": "string"}
671 "required": ["instance_name"]
676 "additionalProperties": False
679 instance_scenario_create_schema
= {
680 "title":"instance scenario create information schema v0.1",
681 "$schema": "http://json-schema.org/draft-04/schema#",
684 "schema_version": {"type": "string", "enum": ["0.1"]},
689 "description":description_schema
,
690 "datacenter": name_schema
,
691 "scenario" : name_schema
, #can be an UUID or name
692 "action":{"enum": ["deploy","reserve","verify" ]},
693 "connect_mgmt_interfaces": {"oneOff": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
694 "vnfs":{ #mapping from scenario to datacenter
696 "patternProperties":{
700 "name": name_schema
,#override vnf name
701 "datacenter": name_schema
,
702 "metadata": {"type": "object"},
703 "user_data": {"type": "string"}
708 "networks":{ #mapping from scenario to datacenter
710 "patternProperties":{
714 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
715 "netmap-use": name_schema
,
716 "name": name_schema
,#override network name
717 "datacenter": name_schema
,
723 "additionalProperties": False,
724 "required": ["scenario", "name"]
727 "required": ["instance"],
728 "additionalProperties": False
732 instance_scenario_action_schema
= {
733 "title":"instance scenario action information schema",
734 "$schema": "http://json-schema.org/draft-04/schema#",
737 "start":{"type": "null"},
738 "pause":{"type": "null"},
739 "resume":{"type": "null"},
740 "shutoff":{"type": "null"},
741 "shutdown":{"type": "null"},
742 "forceOff":{"type": "null"},
743 "rebuild":{"type": "null"},
745 "type": ["object","null"],
747 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
748 "vnfs":{"type": "array", "items":{"type":"string"}},
749 "vms":{"type": "array", "items":{"type":"string"}}
753 "additionalProperties": False