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}
58 "architecture": {"type":"string"},
59 "use_incremental": {"type":"string","enum":["yes","no"]},
61 "os_distro": {"type":"string"},
62 "os_type": {"type":"string"},
63 "os_version": {"type":"string"},
64 "bus": {"type":"string"},
65 "topology": {"type":"string", "enum": ["oneSocket"]}
69 #Schema for the configuration file
71 "title":"configuration response information schema",
72 "$schema": "http://json-schema.org/draft-04/schema#",
75 "http_port": port_schema
,
76 "http_admin_port": port_schema
,
77 "http_host": nameshort_schema
,
78 "vnf_repository": path_schema
,
79 "db_host": nameshort_schema
,
80 "db_user": nameshort_schema
,
81 "db_passwd": {"type":"string"},
82 "db_name": nameshort_schema
,
83 # Next fields will disappear once the MANO API includes appropriate primitives
84 "vim_url": http_schema
,
85 "vim_url_admin": http_schema
,
86 "vim_name": nameshort_schema
,
87 "vim_tenant_name": nameshort_schema
,
88 "mano_tenant_name": nameshort_schema
,
89 "mano_tenant_id": id_schema
,
90 "http_console_ports": {
94 {"type":"object", "properties":{"from": port_schema
, "to": port_schema
}, "required": ["from","to"]}
98 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
99 "additionalProperties": False
103 "title":"tenant information schema",
104 "$schema": "http://json-schema.org/draft-04/schema#",
110 "name": nameshort_schema
,
111 "description": description_schema
,
113 "required": ["name"],
114 "additionalProperties": True
117 "required": ["tenant"],
118 "additionalProperties": False
120 tenant_edit_schema
= {
121 "title":"tenant edit information schema",
122 "$schema": "http://json-schema.org/draft-04/schema#",
129 "description": description_schema
,
131 "additionalProperties": False
134 "required": ["tenant"],
135 "additionalProperties": False
138 datacenter_schema_properties
={
140 "description": description_schema
,
141 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarge with plugins
142 "vim_url": description_schema
,
143 "vim_url_admin": description_schema
,
144 "config": { "type":"object" }
147 datacenter_schema
= {
148 "title":"datacenter information schema",
149 "$schema": "http://json-schema.org/draft-04/schema#",
154 "properties":datacenter_schema_properties
,
155 "required": ["name", "vim_url"],
156 "additionalProperties": True
159 "required": ["datacenter"],
160 "additionalProperties": False
164 datacenter_edit_schema
= {
165 "title":"datacenter edit nformation schema",
166 "$schema": "http://json-schema.org/draft-04/schema#",
171 "properties":datacenter_schema_properties
,
172 "additionalProperties": False
175 "required": ["datacenter"],
176 "additionalProperties": False
180 netmap_new_schema
= {
181 "title":"netmap new information schema",
182 "$schema": "http://json-schema.org/draft-04/schema#",
185 "netmap":{ #delete from datacenter
188 "name": name_schema
, #name or uuid of net to change
190 "vim_name": name_schema
193 "additionalProperties": False
196 "required": ["netmap"],
197 "additionalProperties": False
200 netmap_edit_schema
= {
201 "title":"netmap edit information schema",
202 "$schema": "http://json-schema.org/draft-04/schema#",
205 "netmap":{ #delete from datacenter
208 "name": name_schema
, #name or uuid of net to change
211 "additionalProperties": False
214 "required": ["netmap"],
215 "additionalProperties": False
218 datacenter_action_schema
= {
219 "title":"datacenter action information schema",
220 "$schema": "http://json-schema.org/draft-04/schema#",
223 "net-update":{"type":"null",},
227 "net": name_schema
, #name or uuid of net to change
229 "description": description_schema
,
230 "shared": {"type": "boolean"}
233 "additionalProperties": False
238 "net": name_schema
, #name or uuid of net to change
241 "additionalProperties": False
246 "additionalProperties": False
250 datacenter_associate_schema
={
251 "title":"datacenter associate information schema",
252 "$schema": "http://json-schema.org/draft-04/schema#",
258 "vim_tenant": id_schema
,
259 "vim_tenant_name": nameshort_schema
,
260 "vim_username": nameshort_schema
,
261 "vim_password": nameshort_schema
,
263 # "required": ["vim_tenant"],
264 "additionalProperties": True
267 "required": ["datacenter"],
268 "additionalProperties": False
271 internal_connection_element_schema
= {
275 "local_iface_name": name_schema
279 internal_connection_schema
= {
283 "description":description_schema
,
284 "type":{"type":"string", "enum":["bridge","data","ptp"]},
285 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
287 "required": ["name", "type", "elements"],
288 "additionalProperties": False
291 external_connection_schema
= {
295 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
297 "local_iface_name": name_schema
,
298 "description":description_schema
300 "required": ["name", "type", "VNFC", "local_iface_name"],
301 "additionalProperties": False
310 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
311 "bandwidth":bandwidth_schema
,
313 "mac_address": mac_schema
315 "additionalProperties": False,
316 "required": ["name","dedicated", "bandwidth"]
320 bridge_interfaces_schema
={
326 "bandwidth":bandwidth_schema
,
328 "mac_address": mac_schema
,
329 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
331 "additionalProperties": False,
341 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
342 "image": path_schema
,
343 "image metadata": metadata_schema
,
345 "xml":xml_text_schema
,
347 "additionalProperties": False,
356 "memory":integer1_schema
,
357 "cores":integer1_schema
,
358 "paired-threads":integer1_schema
,
359 "threads":integer1_schema
,
360 "cores-id":{"type":"array","items":integer0_schema
},
361 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
362 "threads-id":{"type":"array","items":integer0_schema
},
363 "interfaces":interfaces_schema
365 "additionalProperties": False,
366 #"required": ["memory"]
373 "description": description_schema
,
374 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
375 "image metadata": metadata_schema
,
379 "model":description_schema
,
380 "features":{"type":"array","items":nameshort_schema
}
382 "required": ["model"],
383 "additionalProperties": False
388 "type":nameshort_schema
,
389 "version":description_schema
392 "ram":integer0_schema
,
393 "vcpus":integer0_schema
,
394 "disk": integer1_schema
,
399 "bridge-ifaces": bridge_interfaces_schema
,
400 "devices": devices_schema
402 "required": ["name", "VNFC image"],
403 "additionalProperties": False
407 "title":"vnfd information schema v0.1",
408 "$schema": "http://json-schema.org/draft-04/schema#",
415 "description": description_schema
,
416 "class": nameshort_schema
,
417 "public": {"type" : "boolean"},
418 "physical": {"type" : "boolean"},
419 "tenant_id": id_schema
, #only valid for admin
420 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
421 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
422 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
424 "required": ["name","external-connections"],
425 "additionalProperties": True
429 "additionalProperties": False
432 #Future VNFD schema to be defined
434 "title":"vnfd information schema v0.2",
435 "$schema": "http://json-schema.org/draft-04/schema#",
438 "schema_version": schema_version_2
,
444 "required": ["name"],
445 "additionalProperties": True
448 "required": ["vnf", "schema_version"],
449 "additionalProperties": False
452 #vnfd_schema = vnfd_schema_v01
454 # "title":"vnfd information schema v0.2",
455 # "$schema": "http://json-schema.org/draft-04/schema#",
456 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
460 "title":"graphical scenario descriptor information schema",
461 "$schema": "http://json-schema.org/draft-04/schema#",
464 "x": integer0_schema
,
465 "y": integer0_schema
,
469 "left": {"type":"array"},
470 "right": {"type":"array"},
471 "bottom": {"type":"array"},
475 "required": ["x","y"]
479 "title":"network scenario descriptor information schema v0.1",
480 "$schema": "http://json-schema.org/draft-04/schema#",
484 "description": description_schema
,
485 "tenant_id": id_schema
, #only valid for admin
486 "public": {"type": "boolean"},
492 "patternProperties":{
496 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
498 "graph": graph_schema
,
500 "patternProperties":{
501 "^(VNF )?model$": {"type": "string"}
509 "patternProperties":{
513 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
514 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
515 "graph": graph_schema
517 "required": ["nodes"]
522 "required": ["nodes"],
523 "additionalProperties": False
526 "required": ["name","topology"],
527 "additionalProperties": False
530 #Future NSD schema to be defined
532 "title":"network scenario descriptor information schema v0.2",
533 "$schema": "http://json-schema.org/draft-04/schema#",
536 "schema_version": schema_version_2
,
541 "description": description_schema
,
542 "tenant_id": id_schema
, #only valid for admin
543 "public": {"type": "boolean"},
546 "patternProperties":{
551 "graph": graph_schema
,
552 "vnf_name": name_schema
,
560 "patternProperties":{
564 "interfaces":{"type":"array", "minLength":1},
565 "type": {"type": "string", "enum":["dataplane", "bridge"]},
566 "external" : {"type": "boolean"},
567 "graph": graph_schema
569 "required": ["interfaces"]
575 "required": ["vnfs", "networks","name"],
576 "additionalProperties": False
579 "required": ["scenario","schema_version"],
580 "additionalProperties": False
583 #scenario_new_schema = {
584 # "title":"new scenario information schema",
585 # "$schema": "http://json-schema.org/draft-04/schema#",
586 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
587 # "oneOf": [nsd_schema_v01]
590 scenario_edit_schema
= {
591 "title":"edit scenario information schema",
592 "$schema": "http://json-schema.org/draft-04/schema#",
596 "description": description_schema
,
602 "patternProperties":{
603 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
609 "x": integer0_schema
,
610 "y": integer0_schema
,
611 "ifaces":{ "type": "object"}
614 "description": description_schema
,
621 "required": ["nodes"],
622 "additionalProperties": False
625 "additionalProperties": False
628 scenario_action_schema
= {
629 "title":"scenario action information schema",
630 "$schema": "http://json-schema.org/draft-04/schema#",
636 "instance_name":name_schema
,
637 "description":description_schema
,
638 "datacenter": {"type": "string"}
640 "required": ["instance_name"]
645 "instance_name":name_schema
,
646 "description":description_schema
,
647 "datacenter": {"type": "string"}
649 "required": ["instance_name"]
654 "instance_name":name_schema
,
655 "description":description_schema
,
656 "datacenter": {"type": "string"}
658 "required": ["instance_name"]
663 "instance_name":name_schema
,
664 "description":description_schema
,
665 "datacenter": {"type": "string"}
667 "required": ["instance_name"]
672 "additionalProperties": False
675 instance_scenario_create_schema
= {
676 "title":"instance scenario create information schema v0.1",
677 "$schema": "http://json-schema.org/draft-04/schema#",
680 "schema_version": {"type": "string", "enum": ["0.1"]},
685 "description":description_schema
,
686 "datacenter": name_schema
,
687 "scenario" : name_schema
, #can be an UUID or name
688 "action":{"enum": ["deploy","reserve","verify" ]},
689 "connect_mgmt_interfaces": {"oneOff": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
690 "vnfs":{ #mapping from scenario to datacenter
692 "patternProperties":{
696 "name": name_schema
,#override vnf name
697 "datacenter": name_schema
,
698 "metadata": {"type": "object"},
699 "user_data": {"type": "string"}
704 "networks":{ #mapping from scenario to datacenter
706 "patternProperties":{
710 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
711 "netmap-use": name_schema
,
712 "name": name_schema
,#override network name
713 "datacenter": name_schema
,
719 "additionalProperties": False,
720 "required": ["scenario", "name"]
723 "required": ["instance"],
724 "additionalProperties": False
728 instance_scenario_action_schema
= {
729 "title":"instance scenario action information schema",
730 "$schema": "http://json-schema.org/draft-04/schema#",
733 "start":{"type": "null"},
734 "pause":{"type": "null"},
735 "resume":{"type": "null"},
736 "shutoff":{"type": "null"},
737 "shutdown":{"type": "null"},
738 "forceOff":{"type": "null"},
739 "rebuild":{"type": "null"},
741 "type": ["object","null"],
743 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
744 "vnfs":{"type": "array", "items":{"type":"string"}},
745 "vms":{"type": "array", "items":{"type":"string"}}
749 "additionalProperties": False