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 passwd_schema
={"type" : "string", "minLength":1, "maxLength":60}
32 nameshort_schema
={"type" : "string", "minLength":1, "maxLength":60, "pattern" : "^[^,;()'\"]+$"}
33 name_schema
={"type" : "string", "minLength":1, "maxLength":255, "pattern" : "^[^,;()'\"]+$"}
34 xml_text_schema
={"type" : "string", "minLength":1, "maxLength":1000, "pattern" : "^[^']+$"}
35 description_schema
={"type" : ["string","null"], "maxLength":255, "pattern" : "^[^'\"]+$"}
36 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}$"
37 id_schema
= {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
38 pci_schema
={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
39 http_schema
={"type":"string", "pattern":"^https?://[^'\"=]+$"}
40 bandwidth_schema
={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
41 memory_schema
={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
42 integer0_schema
={"type":"integer","minimum":0}
43 integer1_schema
={"type":"integer","minimum":1}
44 path_schema
={"type":"string", "pattern":"^(\.(\.?))?(/[^/"":{}\ \(\)]+)+$"}
45 vlan_schema
={"type":"integer","minimum":1,"maximum":4095}
46 vlan1000_schema
={"type":"integer","minimum":1000,"maximum":4095}
47 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
48 #mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
49 ip_schema
={"type":"string","pattern":"^([0-9]{1,3}.){3}[0-9]{1,3}$"}
50 port_schema
={"type":"integer","minimum":1,"maximum":65534}
51 object_schema
={"type":"object"}
56 "architecture": {"type":"string"},
57 "use_incremental": {"type":"string","enum":["yes","no"]},
59 "os_distro": {"type":"string"},
60 "os_type": {"type":"string"},
61 "os_version": {"type":"string"},
62 "bus": {"type":"string"},
63 "topology": {"type":"string", "enum": ["oneSocket"]}
67 #Schema for the configuration file
69 "title":"configuration response information schema",
70 "$schema": "http://json-schema.org/draft-04/schema#",
73 "http_port": port_schema
,
74 "http_admin_port": port_schema
,
75 "http_host": nameshort_schema
,
76 "vnf_repository": path_schema
,
77 "db_host": nameshort_schema
,
78 "db_user": nameshort_schema
,
79 "db_passwd": {"type":"string"},
80 "db_name": nameshort_schema
,
81 # Next fields will disappear once the MANO API includes appropriate primitives
82 "vim_url": http_schema
,
83 "vim_url_admin": http_schema
,
84 "vim_name": nameshort_schema
,
85 "vim_tenant_name": nameshort_schema
,
86 "mano_tenant_name": nameshort_schema
,
87 "mano_tenant_id": id_schema
,
88 "http_console_ports": {
92 {"type":"object", "properties":{"from": port_schema
, "to": port_schema
}, "required": ["from","to"]}
96 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
97 "additionalProperties": False
101 "title":"tenant information schema",
102 "$schema": "http://json-schema.org/draft-04/schema#",
108 "name": nameshort_schema
,
109 "description": description_schema
,
111 "required": ["name"],
112 "additionalProperties": True
115 "required": ["tenant"],
116 "additionalProperties": False
118 tenant_edit_schema
= {
119 "title":"tenant edit information schema",
120 "$schema": "http://json-schema.org/draft-04/schema#",
127 "description": description_schema
,
129 "additionalProperties": False
132 "required": ["tenant"],
133 "additionalProperties": False
136 datacenter_schema_properties
={
138 "description": description_schema
,
139 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarge with plugins
140 "vim_url": description_schema
,
141 "vim_url_admin": description_schema
,
142 "config": { "type":"object" }
145 datacenter_schema
= {
146 "title":"datacenter information schema",
147 "$schema": "http://json-schema.org/draft-04/schema#",
152 "properties":datacenter_schema_properties
,
153 "required": ["name", "vim_url"],
154 "additionalProperties": True
157 "required": ["datacenter"],
158 "additionalProperties": False
162 datacenter_edit_schema
= {
163 "title":"datacenter edit nformation schema",
164 "$schema": "http://json-schema.org/draft-04/schema#",
169 "properties":datacenter_schema_properties
,
170 "additionalProperties": False
173 "required": ["datacenter"],
174 "additionalProperties": False
178 netmap_new_schema
= {
179 "title":"netmap new information schema",
180 "$schema": "http://json-schema.org/draft-04/schema#",
183 "netmap":{ #delete from datacenter
186 "name": name_schema
, #name or uuid of net to change
188 "vim_name": name_schema
191 "additionalProperties": False
194 "required": ["netmap"],
195 "additionalProperties": False
198 netmap_edit_schema
= {
199 "title":"netmap edit information schema",
200 "$schema": "http://json-schema.org/draft-04/schema#",
203 "netmap":{ #delete from datacenter
206 "name": name_schema
, #name or uuid of net to change
209 "additionalProperties": False
212 "required": ["netmap"],
213 "additionalProperties": False
216 datacenter_action_schema
= {
217 "title":"datacenter action information schema",
218 "$schema": "http://json-schema.org/draft-04/schema#",
221 "net-update":{"type":"null",},
225 "net": name_schema
, #name or uuid of net to change
227 "description": description_schema
,
228 "shared": {"type": "boolean"}
231 "additionalProperties": False
236 "net": name_schema
, #name or uuid of net to change
239 "additionalProperties": False
244 "additionalProperties": False
248 datacenter_associate_schema
={
249 "title":"datacenter associate information schema",
250 "$schema": "http://json-schema.org/draft-04/schema#",
256 "vim_tenant": id_schema
,
257 "vim_tenant_name": nameshort_schema
,
258 "vim_username": nameshort_schema
,
259 "vim_password": nameshort_schema
,
261 # "required": ["vim_tenant"],
262 "additionalProperties": True
265 "required": ["datacenter"],
266 "additionalProperties": False
269 internal_connection_element_schema
= {
273 "local_iface_name": name_schema
277 internal_connection_schema
= {
281 "description":description_schema
,
282 "type":{"type":"string", "enum":["bridge","data","ptp"]},
283 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
285 "required": ["name", "type", "elements"],
286 "additionalProperties": False
289 external_connection_schema
= {
293 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
295 "local_iface_name": name_schema
,
296 "description":description_schema
298 "required": ["name", "type", "VNFC", "local_iface_name"],
299 "additionalProperties": False
308 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
309 "bandwidth":bandwidth_schema
,
311 "mac_address": mac_schema
313 "additionalProperties": False,
314 "required": ["name","dedicated", "bandwidth"]
318 bridge_interfaces_schema
={
324 "bandwidth":bandwidth_schema
,
326 "mac_address": mac_schema
,
327 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
329 "additionalProperties": False,
339 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
340 "image": path_schema
,
341 "image metadata": metadata_schema
,
343 "xml":xml_text_schema
,
345 "additionalProperties": False,
354 "memory":integer1_schema
,
355 "cores":integer1_schema
,
356 "paired-threads":integer1_schema
,
357 "threads":integer1_schema
,
358 "cores-id":{"type":"array","items":integer0_schema
},
359 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
360 "threads-id":{"type":"array","items":integer0_schema
},
361 "interfaces":interfaces_schema
363 "additionalProperties": False,
364 #"required": ["memory"]
371 "description": description_schema
,
372 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
373 "image metadata": metadata_schema
,
377 "model":description_schema
,
378 "features":{"type":"array","items":nameshort_schema
}
380 "required": ["model"],
381 "additionalProperties": False
386 "type":nameshort_schema
,
387 "version":description_schema
390 "ram":integer0_schema
,
391 "vcpus":integer0_schema
,
392 "disk": integer1_schema
,
397 "bridge-ifaces": bridge_interfaces_schema
,
398 "devices": devices_schema
400 "required": ["name", "VNFC image"],
401 "additionalProperties": False
405 "title":"vnfd information schema v0.1",
406 "$schema": "http://json-schema.org/draft-04/schema#",
413 "description": description_schema
,
414 "class": nameshort_schema
,
415 "public": {"type" : "boolean"},
416 "physical": {"type" : "boolean"},
417 "tenant_id": id_schema
, #only valid for admin
418 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
419 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
420 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
422 "required": ["name","external-connections"],
423 "additionalProperties": True
427 "additionalProperties": False
430 #Future VNFD schema to be defined
432 "title":"vnfd information schema v0.2",
433 "$schema": "http://json-schema.org/draft-04/schema#",
436 "version": {"type": "string", "pattern":"^v0.2$"},
442 "required": ["name"],
443 "additionalProperties": True
446 "required": ["vnf", "version"],
447 "additionalProperties": False
450 #vnfd_schema = vnfd_schema_v01
452 # "title":"vnfd information schema v0.2",
453 # "$schema": "http://json-schema.org/draft-04/schema#",
454 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
458 "title":"graphical scenario descriptor information schema",
459 "$schema": "http://json-schema.org/draft-04/schema#",
462 "x": integer0_schema
,
463 "y": integer0_schema
,
467 "left": {"type":"array"},
468 "right": {"type":"array"},
469 "bottom": {"type":"array"},
473 "required": ["x","y"]
477 "title":"network scenario descriptor information schema v0.1",
478 "$schema": "http://json-schema.org/draft-04/schema#",
482 "description": description_schema
,
483 "tenant_id": id_schema
, #only valid for admin
489 "patternProperties":{
493 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
495 "graph": graph_schema
,
497 "patternProperties":{
498 "^(VNF )?model$": {"type": "string"}
506 "patternProperties":{
510 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
511 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
512 "graph": graph_schema
514 "required": ["nodes"]
519 "required": ["nodes"],
520 "additionalProperties": False
523 "required": ["name","topology"],
524 "additionalProperties": False
527 #Future NSD schema to be defined
529 "title":"network scenario descriptor information schema v0.2",
530 "$schema": "http://json-schema.org/draft-04/schema#",
533 "schema_version": {"type": "string", "enum": ["0.2"]},
535 "description": description_schema
,
536 "tenant_id": id_schema
, #only valid for admin
539 "patternProperties":{
544 "graph": graph_schema
,
545 "vnf_model": name_schema
,
553 "patternProperties":{
557 "interfaces":{"type":"array", "minLength":1},
558 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
559 "graph": graph_schema
561 "required": ["interfaces"]
566 "required": ["vnfs", "networks","name", "schema_version"],
567 "additionalProperties": False
570 #scenario_new_schema = {
571 # "title":"new scenario information schema",
572 # "$schema": "http://json-schema.org/draft-04/schema#",
573 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
574 # "oneOf": [nsd_schema_v01]
577 scenario_edit_schema
= {
578 "title":"edit scenario information schema",
579 "$schema": "http://json-schema.org/draft-04/schema#",
583 "description": description_schema
,
589 "patternProperties":{
590 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
596 "x": integer0_schema
,
597 "y": integer0_schema
,
598 "ifaces":{ "type": "object"}
601 "description": description_schema
,
608 "required": ["nodes"],
609 "additionalProperties": False
612 "additionalProperties": False
615 scenario_action_schema
= {
616 "title":"scenario action information schema",
617 "$schema": "http://json-schema.org/draft-04/schema#",
623 "instance_name":name_schema
,
624 "description":description_schema
,
625 "datacenter": {"type": "string"}
627 "required": ["instance_name"]
632 "instance_name":name_schema
,
633 "description":description_schema
,
634 "datacenter": {"type": "string"}
636 "required": ["instance_name"]
641 "instance_name":name_schema
,
642 "description":description_schema
,
643 "datacenter": {"type": "string"}
645 "required": ["instance_name"]
650 "instance_name":name_schema
,
651 "description":description_schema
,
652 "datacenter": {"type": "string"}
654 "required": ["instance_name"]
659 "additionalProperties": False
662 instance_scenario_create_schema
= {
663 "title":"instance scenario create information schema v0.1",
664 "$schema": "http://json-schema.org/draft-04/schema#",
667 "schema_version": {"type": "string", "enum": ["0.1"]},
672 "description":description_schema
,
673 "datacenter": name_schema
,
674 "scenario" : name_schema
, #can be an UUID or name
675 "action":{"enum": ["deploy","reserve","verify" ]},
676 "connect_mgmt_interfaces": {"oneOff": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
677 "vnfs":{ #mapping from scenario to datacenter
679 "patternProperties":{
683 "name": name_schema
,#override vnf name
684 "datacenter": name_schema
,
685 "metadata": {"type": "object"},
686 "user_data": {"type": "string"}
691 "networks":{ #mapping from scenario to datacenter
693 "patternProperties":{
697 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
698 "netmap-use": name_schema
,
699 "name": name_schema
,#override network name
700 "datacenter": name_schema
,
706 "additionalProperties": False,
707 "required": ["scenario", "name"]
710 "required": ["instance"],
711 "additionalProperties": False
715 instance_scenario_action_schema
= {
716 "title":"instance scenario action information schema",
717 "$schema": "http://json-schema.org/draft-04/schema#",
720 "start":{"type": "null"},
721 "pause":{"type": "null"},
722 "resume":{"type": "null"},
723 "shutoff":{"type": "null"},
724 "shutdown":{"type": "null"},
725 "forceOff":{"type": "null"},
726 "rebuild":{"type": "null"},
728 "type": ["object","null"],
730 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
731 "vnfs":{"type": "array", "items":{"type":"string"}},
732 "vms":{"type": "array", "items":{"type":"string"}}
736 "additionalProperties": False