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":"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"}
51 ip_prefix_schema
={"type":"string","pattern":"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$"}
52 port_schema
={"type":"integer","minimum":1,"maximum":65534}
53 object_schema
={"type":"object"}
54 schema_version_2
={"type":"integer","minimum":2,"maximum":2}
55 #schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
56 log_level_schema
={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
61 "architecture": {"type":"string"},
62 "use_incremental": {"type":"string","enum":["yes","no"]},
64 "os_distro": {"type":"string"},
65 "os_type": {"type":"string"},
66 "os_version": {"type":"string"},
67 "bus": {"type":"string"},
68 "topology": {"type":"string", "enum": ["oneSocket"]}
72 #Schema for the configuration file
74 "title":"configuration response information schema",
75 "$schema": "http://json-schema.org/draft-04/schema#",
78 "http_port": port_schema
,
79 "http_admin_port": port_schema
,
80 "http_host": nameshort_schema
,
81 "vnf_repository": path_schema
,
82 "db_host": nameshort_schema
,
83 "db_user": nameshort_schema
,
84 "db_passwd": {"type":"string"},
85 "db_name": nameshort_schema
,
86 # Next fields will disappear once the MANO API includes appropriate primitives
87 "vim_url": http_schema
,
88 "vim_url_admin": http_schema
,
89 "vim_name": nameshort_schema
,
90 "vim_tenant_name": nameshort_schema
,
91 "mano_tenant_name": nameshort_schema
,
92 "mano_tenant_id": id_schema
,
93 "http_console_proxy": {"type":"boolean"},
94 "http_console_host": nameshort_schema
,
95 "http_console_ports": {
99 {"type":"object", "properties":{"from": port_schema
, "to": port_schema
}, "required": ["from","to"]}
102 "log_level": log_level_schema
,
103 "log_socket_level": log_level_schema
,
104 "log_level_db": log_level_schema
,
105 "log_level_vimconn": log_level_schema
,
106 "log_level_nfvo": log_level_schema
,
107 "log_socket_host": nameshort_schema
,
108 "log_socket_port": port_schema
,
109 "log_file": path_schema
,
111 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
112 "additionalProperties": False
116 "title":"tenant information schema",
117 "$schema": "http://json-schema.org/draft-04/schema#",
123 "name": nameshort_schema
,
124 "description": description_schema
,
126 "required": ["name"],
127 "additionalProperties": True
130 "required": ["tenant"],
131 "additionalProperties": False
134 tenant_edit_schema
= {
135 "title":"tenant edit information schema",
136 "$schema": "http://json-schema.org/draft-04/schema#",
143 "description": description_schema
,
145 "additionalProperties": False
148 "required": ["tenant"],
149 "additionalProperties": False
152 datacenter_schema_properties
={
154 "description": description_schema
,
155 "type": nameshort_schema
, #currently "openvim" or "openstack", can be enlarged with plugins
156 "vim_url": description_schema
,
157 "vim_url_admin": description_schema
,
158 "config": { "type":"object" }
161 datacenter_schema
= {
162 "title":"datacenter information schema",
163 "$schema": "http://json-schema.org/draft-04/schema#",
168 "properties":datacenter_schema_properties
,
169 "required": ["name", "vim_url"],
170 "additionalProperties": True
173 "required": ["datacenter"],
174 "additionalProperties": False
178 datacenter_edit_schema
= {
179 "title":"datacenter edit nformation schema",
180 "$schema": "http://json-schema.org/draft-04/schema#",
185 "properties":datacenter_schema_properties
,
186 "additionalProperties": False
189 "required": ["datacenter"],
190 "additionalProperties": False
194 netmap_new_schema
= {
195 "title":"netmap new information schema",
196 "$schema": "http://json-schema.org/draft-04/schema#",
199 "netmap":{ #delete from datacenter
202 "name": name_schema
, #name or uuid of net to change
204 "vim_name": name_schema
207 "additionalProperties": False
210 "required": ["netmap"],
211 "additionalProperties": False
214 netmap_edit_schema
= {
215 "title":"netmap edit information schema",
216 "$schema": "http://json-schema.org/draft-04/schema#",
219 "netmap":{ #delete from datacenter
222 "name": name_schema
, #name or uuid of net to change
225 "additionalProperties": False
228 "required": ["netmap"],
229 "additionalProperties": False
232 datacenter_action_schema
= {
233 "title":"datacenter action information schema",
234 "$schema": "http://json-schema.org/draft-04/schema#",
237 "net-update":{"type":"null",},
241 "net": name_schema
, #name or uuid of net to change
243 "description": description_schema
,
244 "shared": {"type": "boolean"}
247 "additionalProperties": False
252 "net": name_schema
, #name or uuid of net to change
255 "additionalProperties": False
260 "additionalProperties": False
264 datacenter_associate_schema
={
265 "title":"datacenter associate information schema",
266 "$schema": "http://json-schema.org/draft-04/schema#",
272 "vim_tenant": id_schema
,
273 "vim_tenant_name": nameshort_schema
,
274 "vim_username": nameshort_schema
,
275 "vim_password": nameshort_schema
,
277 # "required": ["vim_tenant"],
278 "additionalProperties": True
281 "required": ["datacenter"],
282 "additionalProperties": False
286 "title":"DHCP schema",
287 "$schema": "http://json-schema.org/draft-04/schema#",
290 "enabled": {"type": "boolean"},
291 "start-address": ip_schema
,
292 "count": integer1_schema
296 ip_profile_schema
= {
297 "title":"IP profile schema",
298 "$schema": "http://json-schema.org/draft-04/schema#",
301 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
302 "subnet-address": ip_prefix_schema
,
303 "gateway-address": ip_schema
,
304 "security-group": {"type":"string"},
305 "dns-address": ip_schema
,
311 "title": "Key-pair schema for cloud-init configuration schema",
312 "$schema": "http://json-schema.org/draft-04/schema#",
316 "key": {"type":"string"}
319 "additionalProperties": False
322 cloud_config_user_schema
= {
323 "title": "User schema for cloud-init configuration schema",
324 "$schema": "http://json-schema.org/draft-04/schema#",
327 "name": nameshort_schema
,
328 "user-info": {"type":"string"},
329 #"key-pairs": {"type" : "array", "items": key_pair_schema}
330 "key-pairs": {"type" : "array", "items": {"type":"string"}}
332 "required": ["name"],
333 "additionalProperties": False
336 cloud_config_schema
= {
337 "title": "Cloud-init configuration schema",
338 "$schema": "http://json-schema.org/draft-04/schema#",
341 #"key-pairs": {"type" : "array", "items": key_pair_schema},
342 "key-pairs": {"type" : "array", "items": {"type":"string"}},
343 "users": {"type" : "array", "items": cloud_config_user_schema
}
345 "additionalProperties": False
348 internal_connection_element_schema
= {
352 "local_iface_name": name_schema
356 internal_connection_element_schema_v02
= {
360 "local_iface_name": name_schema
,
361 "ip_address": ip_schema
365 internal_connection_schema
= {
369 "description":description_schema
,
370 "type":{"type":"string", "enum":["bridge","data","ptp"]},
371 "elements": {"type" : "array", "items": internal_connection_element_schema
, "minItems":2}
373 "required": ["name", "type", "elements"],
374 "additionalProperties": False
377 internal_connection_schema_v02
= {
381 "description":description_schema
,
382 "type": {"type": "string", "enum":["e-line", "e-lan"]},
383 "implementation": {"type": "string", "enum":["virtual", "underlay"]},
384 "ip-profile": ip_profile_schema
,
385 "elements": {"type" : "array", "items": internal_connection_element_schema_v02
, "minItems":2}
387 "required": ["name", "type", "elements"],
388 "additionalProperties": False
391 external_connection_schema
= {
395 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
397 "local_iface_name": name_schema
,
398 "description":description_schema
400 "required": ["name", "type", "VNFC", "local_iface_name"],
401 "additionalProperties": False
404 external_connection_schema_v02
= {
409 "local_iface_name": name_schema
,
410 "description":description_schema
412 "required": ["name", "VNFC", "local_iface_name"],
413 "additionalProperties": False
422 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
423 "bandwidth":bandwidth_schema
,
425 "mac_address": mac_schema
427 "additionalProperties": False,
428 "required": ["name","dedicated", "bandwidth"]
432 bridge_interfaces_schema
={
438 "bandwidth":bandwidth_schema
,
440 "mac_address": mac_schema
,
441 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
443 "additionalProperties": False,
453 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
454 "image": path_schema
,
455 "image metadata": metadata_schema
,
457 "xml":xml_text_schema
,
459 "additionalProperties": False,
468 "memory":integer1_schema
,
469 "cores":integer1_schema
,
470 "paired-threads":integer1_schema
,
471 "threads":integer1_schema
,
472 "cores-id":{"type":"array","items":integer0_schema
},
473 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
474 "threads-id":{"type":"array","items":integer0_schema
},
475 "interfaces":interfaces_schema
477 "additionalProperties": False,
478 #"required": ["memory"]
485 "description": description_schema
,
486 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
487 "image metadata": metadata_schema
,
488 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
492 "model":description_schema
,
493 "features":{"type":"array","items":nameshort_schema
}
495 "required": ["model"],
496 "additionalProperties": False
501 "type":nameshort_schema
,
502 "version":description_schema
505 "ram":integer0_schema
,
506 "vcpus":integer0_schema
,
507 "disk": integer1_schema
,
512 "bridge-ifaces": bridge_interfaces_schema
,
513 "devices": devices_schema
516 "required": ["name", "VNFC image"],
517 "additionalProperties": False
521 "title":"vnfd information schema v0.1",
522 "$schema": "http://json-schema.org/draft-04/schema#",
529 "description": description_schema
,
530 "class": nameshort_schema
,
531 "public": {"type" : "boolean"},
532 "physical": {"type" : "boolean"},
533 "tenant_id": id_schema
, #only valid for admin
534 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
535 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
536 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
538 "required": ["name","external-connections"],
539 "additionalProperties": True
543 "additionalProperties": False
546 #VNFD schema for OSM R1
548 "title":"vnfd information schema v0.2",
549 "$schema": "http://json-schema.org/draft-04/schema#",
552 "schema_version": {"type": "string", "enum": ["0.2"]},
557 "description": description_schema
,
558 "class": nameshort_schema
,
559 "public": {"type" : "boolean"},
560 "physical": {"type" : "boolean"},
561 "tenant_id": id_schema
, #only valid for admin
562 "external-connections": {"type" : "array", "items": external_connection_schema_v02
, "minItems":1},
563 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02
, "minItems":1},
564 # "cloud-config": cloud_config_schema, #common for all vnfcs
565 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
567 "required": ["name"],
568 "additionalProperties": True
571 "required": ["vnf", "schema_version"],
572 "additionalProperties": False
575 #vnfd_schema = vnfd_schema_v01
577 # "title":"vnfd information schema v0.2",
578 # "$schema": "http://json-schema.org/draft-04/schema#",
579 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
583 "title":"graphical scenario descriptor information schema",
584 "$schema": "http://json-schema.org/draft-04/schema#",
587 "x": integer0_schema
,
588 "y": integer0_schema
,
592 "left": {"type":"array"},
593 "right": {"type":"array"},
594 "bottom": {"type":"array"},
598 "required": ["x","y"]
602 "title":"network scenario descriptor information schema v0.1",
603 "$schema": "http://json-schema.org/draft-04/schema#",
607 "description": description_schema
,
608 "tenant_id": id_schema
, #only valid for admin
609 "public": {"type": "boolean"},
615 "patternProperties":{
619 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
621 "graph": graph_schema
,
623 "patternProperties":{
624 "^(VNF )?model$": {"type": "string"}
632 "patternProperties":{
636 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
637 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
638 "graph": graph_schema
640 "required": ["nodes"]
645 "required": ["nodes"],
646 "additionalProperties": False
649 "required": ["name","topology"],
650 "additionalProperties": False
654 "title":"network scenario descriptor information schema v0.2",
655 "$schema": "http://json-schema.org/draft-04/schema#",
658 "schema_version": schema_version_2
,
663 "description": description_schema
,
664 "tenant_id": id_schema
, #only valid for admin
665 "public": {"type": "boolean"},
668 "patternProperties":{
673 "graph": graph_schema
,
674 "vnf_name": name_schema
,
682 "patternProperties":{
686 "interfaces":{"type":"array", "minLength":1},
687 "type": {"type": "string", "enum":["dataplane", "bridge"]},
688 "external" : {"type": "boolean"},
689 "graph": graph_schema
691 "required": ["interfaces"]
697 "required": ["vnfs", "name"],
698 "additionalProperties": False
701 "required": ["scenario","schema_version"],
702 "additionalProperties": False
705 #NSD schema for OSM R1
707 "title":"network scenario descriptor information schema v0.3",
708 "$schema": "http://json-schema.org/draft-04/schema#",
711 "schema_version": {"type": "string", "enum": ["0.3"]},
716 "description": description_schema
,
717 "tenant_id": id_schema
, #only valid for admin
718 "public": {"type": "boolean"},
719 "cloud-config": cloud_config_schema
, #common for all vnfs in the scenario
720 #"datacenter": name_schema,
723 "patternProperties":{
728 "graph": graph_schema
,
729 "vnf_name": name_schema
,
730 #"cloud-config": cloud_config_schema, #particular for a vnf
731 #"datacenter": name_schema,
732 "internal-connections": {
734 "patternProperties": {
738 "ip-profile": ip_profile_schema
,
745 "local_iface_name": name_schema
,
746 "ip_address": ip_schema
748 "required": ["VNFC", "local_iface_name"],
762 "patternProperties":{
772 "ip_address": ip_schema
774 "patternProperties":{
775 ".": {"type": "string"}
779 "type": {"type": "string", "enum":["e-line", "e-lan"]},
780 "implementation": {"type": "string", "enum":["virtual", "underlay"]},
781 "external" : {"type": "boolean"},
782 "graph": graph_schema
,
783 "ip-profile": ip_profile_schema
785 "required": ["interfaces"]
791 "required": ["vnfs", "networks","name"],
792 "additionalProperties": False
795 "required": ["scenario","schema_version"],
796 "additionalProperties": False
799 #scenario_new_schema = {
800 # "title":"new scenario information schema",
801 # "$schema": "http://json-schema.org/draft-04/schema#",
802 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
803 # "oneOf": [nsd_schema_v01]
806 scenario_edit_schema
= {
807 "title":"edit scenario information schema",
808 "$schema": "http://json-schema.org/draft-04/schema#",
812 "description": description_schema
,
818 "patternProperties":{
819 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
825 "x": integer0_schema
,
826 "y": integer0_schema
,
827 "ifaces":{ "type": "object"}
830 "description": description_schema
,
837 "required": ["nodes"],
838 "additionalProperties": False
841 "additionalProperties": False
844 scenario_action_schema
= {
845 "title":"scenario action information schema",
846 "$schema": "http://json-schema.org/draft-04/schema#",
852 "instance_name":name_schema
,
853 "description":description_schema
,
854 "datacenter": {"type": "string"}
856 "required": ["instance_name"]
861 "instance_name":name_schema
,
862 "description":description_schema
,
863 "datacenter": {"type": "string"}
865 "required": ["instance_name"]
870 "instance_name":name_schema
,
871 "description":description_schema
,
872 "datacenter": {"type": "string"}
874 "required": ["instance_name"]
879 "instance_name":name_schema
,
880 "description":description_schema
,
881 "datacenter": {"type": "string"}
883 "required": ["instance_name"]
888 "additionalProperties": False
891 instance_scenario_create_schema_v01
= {
892 "title":"instance scenario create information schema v0.1",
893 "$schema": "http://json-schema.org/draft-04/schema#",
896 "schema_version": {"type": "string", "enum": ["0.1"]},
901 "description":description_schema
,
902 "datacenter": name_schema
,
903 "scenario" : name_schema
, #can be an UUID or name
904 "action":{"enum": ["deploy","reserve","verify" ]},
905 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
906 "cloud-config": cloud_config_schema
, #common to all vnfs in the instance scenario
907 "vnfs":{ #mapping from scenario to datacenter
909 "patternProperties":{
913 "name": name_schema
, #override vnf name
914 "datacenter": name_schema
,
915 #"metadata": {"type": "object"},
916 #"user_data": {"type": "string"}
917 #"cloud-config": cloud_config_schema, #particular for a vnf
918 "external-connections": {
920 "patternProperties": {
924 "vim-network-name": name_schema
,
925 "ip_address": ip_schema
930 "internal-connections": {
932 "patternProperties": {
936 "ip-profile": ip_profile_schema
,
943 "local_iface_name": name_schema
,
944 "ip_address": ip_schema
946 "required": ["VNFC", "local_iface_name"],
957 "networks":{ #mapping from scenario to datacenter
959 "patternProperties":{
969 "ip_address": ip_schema
971 "patternProperties":{
972 ".": {"type": "string"}
976 "ip-profile": ip_profile_schema
,
977 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
984 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
985 # for other networks openamno creates at VIM
986 # Use netmap-create to force to create an external scenario network
987 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
988 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
989 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
990 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
991 #In oder words, it is the same as 'try to map to the VIM network (netmap-use) if exist, and if not create the network (netmap-create)
992 "netmap-use": name_schema
, #
993 "vim-network-name": name_schema
, #override network name
994 #"ip-profile": ip_profile_schema,
995 "datacenter": name_schema
,
1007 "additionalProperties": False,
1008 "required": ["name"]
1011 "required": ["instance"],
1012 "additionalProperties": False
1015 instance_scenario_action_schema
= {
1016 "title":"instance scenario action information schema",
1017 "$schema": "http://json-schema.org/draft-04/schema#",
1020 "start":{"type": "null"},
1021 "pause":{"type": "null"},
1022 "resume":{"type": "null"},
1023 "shutoff":{"type": "null"},
1024 "shutdown":{"type": "null"},
1025 "forceOff":{"type": "null"},
1026 "rebuild":{"type": "null"},
1028 "type": ["object","null"],
1030 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1031 "vnfs":{"type": "array", "items":{"type":"string"}},
1032 "vms":{"type": "array", "items":{"type":"string"}}
1035 #"maxProperties": 1,
1036 "additionalProperties": False