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
294 "required": ["enabled", "start-address", "count"],
297 ip_profile_schema
= {
298 "title":"IP profile schema",
299 "$schema": "http://json-schema.org/draft-04/schema#",
302 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
303 "subnet-address": ip_prefix_schema
,
304 "gateway-address": ip_schema
,
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":["overlay", "underlay"]},
384 "ip-profile": ip_profile_schema
,
385 "elements": {"type" : "array", "items": internal_connection_element_schema_v02
, "minItems":2}
387 "required": ["name", "type", "implementation", "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
405 external_connection_schema_v02
= {
409 "mgmt": {"type":"boolean"},
410 "type": {"type": "string", "enum":["e-line", "e-lan"]},
411 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
413 "local_iface_name": name_schema
,
414 "description":description_schema
416 "required": ["name", "type", "VNFC", "local_iface_name"],
417 "additionalProperties": False
426 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
427 "bandwidth":bandwidth_schema
,
429 "mac_address": mac_schema
431 "additionalProperties": False,
432 "required": ["name","dedicated", "bandwidth"]
436 bridge_interfaces_schema
={
442 "bandwidth":bandwidth_schema
,
444 "mac_address": mac_schema
,
445 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
447 "additionalProperties": False,
457 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
458 "image": path_schema
,
459 "image metadata": metadata_schema
,
461 "xml":xml_text_schema
,
463 "additionalProperties": False,
472 "memory":integer1_schema
,
473 "cores":integer1_schema
,
474 "paired-threads":integer1_schema
,
475 "threads":integer1_schema
,
476 "cores-id":{"type":"array","items":integer0_schema
},
477 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema
}},
478 "threads-id":{"type":"array","items":integer0_schema
},
479 "interfaces":interfaces_schema
481 "additionalProperties": False,
482 #"required": ["memory"]
489 "description": description_schema
,
490 "VNFC image": {"oneOf": [path_schema
, http_schema
]},
491 "image metadata": metadata_schema
,
492 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
496 "model":description_schema
,
497 "features":{"type":"array","items":nameshort_schema
}
499 "required": ["model"],
500 "additionalProperties": False
505 "type":nameshort_schema
,
506 "version":description_schema
509 "ram":integer0_schema
,
510 "vcpus":integer0_schema
,
511 "disk": integer1_schema
,
516 "bridge-ifaces": bridge_interfaces_schema
,
517 "devices": devices_schema
520 "required": ["name", "VNFC image"],
521 "additionalProperties": False
525 "title":"vnfd information schema v0.1",
526 "$schema": "http://json-schema.org/draft-04/schema#",
533 "description": description_schema
,
534 "class": nameshort_schema
,
535 "public": {"type" : "boolean"},
536 "physical": {"type" : "boolean"},
537 "tenant_id": id_schema
, #only valid for admin
538 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
539 "internal-connections": {"type" : "array", "items": internal_connection_schema
, "minItems":1},
540 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
542 "required": ["name","external-connections"],
543 "additionalProperties": True
547 "additionalProperties": False
550 #VNFD schema for OSM R1
552 "title":"vnfd information schema v0.2",
553 "$schema": "http://json-schema.org/draft-04/schema#",
556 "schema_version": {"type": "string", "enum": ["0.2"]},
561 "description": description_schema
,
562 "class": nameshort_schema
,
563 "public": {"type" : "boolean"},
564 "physical": {"type" : "boolean"},
565 "tenant_id": id_schema
, #only valid for admin
566 "external-connections": {"type" : "array", "items": external_connection_schema
, "minItems":1},
567 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02
, "minItems":1},
568 # "cloud-config": cloud_config_schema, #common for all vnfcs
569 "VNFC":{"type" : "array", "items": vnfc_schema
, "minItems":1}
571 "required": ["name"],
572 "additionalProperties": True
575 "required": ["vnf", "schema_version"],
576 "additionalProperties": False
579 #vnfd_schema = vnfd_schema_v01
581 # "title":"vnfd information schema v0.2",
582 # "$schema": "http://json-schema.org/draft-04/schema#",
583 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
587 "title":"graphical scenario descriptor information schema",
588 "$schema": "http://json-schema.org/draft-04/schema#",
591 "x": integer0_schema
,
592 "y": integer0_schema
,
596 "left": {"type":"array"},
597 "right": {"type":"array"},
598 "bottom": {"type":"array"},
602 "required": ["x","y"]
606 "title":"network scenario descriptor information schema v0.1",
607 "$schema": "http://json-schema.org/draft-04/schema#",
611 "description": description_schema
,
612 "tenant_id": id_schema
, #only valid for admin
613 "public": {"type": "boolean"},
619 "patternProperties":{
623 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
625 "graph": graph_schema
,
627 "patternProperties":{
628 "^(VNF )?model$": {"type": "string"}
636 "patternProperties":{
640 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
641 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
642 "graph": graph_schema
644 "required": ["nodes"]
649 "required": ["nodes"],
650 "additionalProperties": False
653 "required": ["name","topology"],
654 "additionalProperties": False
658 "title":"network scenario descriptor information schema v0.2",
659 "$schema": "http://json-schema.org/draft-04/schema#",
662 "schema_version": schema_version_2
,
667 "description": description_schema
,
668 "tenant_id": id_schema
, #only valid for admin
669 "public": {"type": "boolean"},
672 "patternProperties":{
677 "graph": graph_schema
,
678 "vnf_name": name_schema
,
686 "patternProperties":{
690 "interfaces":{"type":"array", "minLength":1},
691 "type": {"type": "string", "enum":["dataplane", "bridge"]},
692 "external" : {"type": "boolean"},
693 "graph": graph_schema
695 "required": ["interfaces"]
701 "required": ["vnfs", "name"],
702 "additionalProperties": False
705 "required": ["scenario","schema_version"],
706 "additionalProperties": False
709 #NSD schema for OSM R1
711 "title":"network scenario descriptor information schema v0.3",
712 "$schema": "http://json-schema.org/draft-04/schema#",
715 "schema_version": {"type": "string", "enum": ["0.3"]},
720 "description": description_schema
,
721 "tenant_id": id_schema
, #only valid for admin
722 "public": {"type": "boolean"},
723 "cloud-config": cloud_config_schema
, #common for all vnfs in the scenario
724 #"datacenter": name_schema,
727 "patternProperties":{
732 "graph": graph_schema
,
733 "vnf_name": name_schema
,
734 #"cloud-config": cloud_config_schema, #particular for a vnf
735 #"datacenter": name_schema,
736 "internal-connections": {
738 "patternProperties": {
742 "ip-profile": ip_profile_schema
,
749 "local_iface_name": name_schema
,
750 "ip_address": ip_schema
752 "required": ["VNFC", "local_iface_name"],
766 "patternProperties":{
777 "vnf_interface": name_schema
,
778 "ip_address": ip_schema
780 "required": ["vnf", "vnf_interface"],
783 "type": {"type": "string", "enum":["e-line", "e-lan"]},
784 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
785 "external" : {"type": "boolean"},
786 "graph": graph_schema
,
787 "ip-profile": ip_profile_schema
789 "required": ["interfaces"]
795 "required": ["vnfs", "networks","name"],
796 "additionalProperties": False
799 "required": ["scenario","schema_version"],
800 "additionalProperties": False
803 #scenario_new_schema = {
804 # "title":"new scenario information schema",
805 # "$schema": "http://json-schema.org/draft-04/schema#",
806 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
807 # "oneOf": [nsd_schema_v01]
810 scenario_edit_schema
= {
811 "title":"edit scenario information schema",
812 "$schema": "http://json-schema.org/draft-04/schema#",
816 "description": description_schema
,
822 "patternProperties":{
823 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
829 "x": integer0_schema
,
830 "y": integer0_schema
,
831 "ifaces":{ "type": "object"}
834 "description": description_schema
,
841 "required": ["nodes"],
842 "additionalProperties": False
845 "additionalProperties": False
848 scenario_action_schema
= {
849 "title":"scenario action information schema",
850 "$schema": "http://json-schema.org/draft-04/schema#",
856 "instance_name":name_schema
,
857 "description":description_schema
,
858 "datacenter": {"type": "string"}
860 "required": ["instance_name"]
865 "instance_name":name_schema
,
866 "description":description_schema
,
867 "datacenter": {"type": "string"}
869 "required": ["instance_name"]
874 "instance_name":name_schema
,
875 "description":description_schema
,
876 "datacenter": {"type": "string"}
878 "required": ["instance_name"]
883 "instance_name":name_schema
,
884 "description":description_schema
,
885 "datacenter": {"type": "string"}
887 "required": ["instance_name"]
892 "additionalProperties": False
895 instance_scenario_create_schema_v01
= {
896 "title":"instance scenario create information schema v0.1",
897 "$schema": "http://json-schema.org/draft-04/schema#",
900 "schema_version": {"type": "string", "enum": ["0.1"]},
905 "description":description_schema
,
906 "datacenter": name_schema
,
907 "scenario" : name_schema
, #can be an UUID or name
908 "action":{"enum": ["deploy","reserve","verify" ]},
909 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
910 "cloud-config": cloud_config_schema
, #common to all vnfs in the instance scenario
911 "vnfs":{ #mapping from scenario to datacenter
913 "patternProperties":{
917 "name": name_schema
, #override vnf name
918 "datacenter": name_schema
,
919 #"metadata": {"type": "object"},
920 #"user_data": {"type": "string"}
921 #"cloud-config": cloud_config_schema, #particular for a vnf
922 "external-connections": {
924 "patternProperties": {
928 "vim-network-name": name_schema
,
929 "ip_address": ip_schema
934 "internal-connections": {
936 "patternProperties": {
940 "ip-profile": ip_profile_schema
,
947 "local_iface_name": name_schema
,
948 "ip_address": ip_schema
950 "required": ["VNFC", "local_iface_name"],
961 "networks":{ #mapping from scenario to datacenter
963 "patternProperties":{
973 "ip_address": ip_schema
,
974 "datacenter": name_schema
,
975 "vim-network-name": name_schema
977 "patternProperties":{
978 ".": {"type": "string"}
982 "ip-profile": ip_profile_schema
,
983 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
990 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
991 # for other networks openamno creates at VIM
992 # Use netmap-create to force to create an external scenario network
993 "netmap-create": {"oneOf":[name_schema
,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
994 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
995 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
996 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
997 #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)
998 "netmap-use": name_schema
, #
999 "vim-network-name": name_schema
, #override network name
1000 #"ip-profile": ip_profile_schema,
1001 "datacenter": name_schema
,
1013 "additionalProperties": False,
1014 "required": ["name"]
1017 "required": ["instance"],
1018 "additionalProperties": False
1021 instance_scenario_action_schema
= {
1022 "title":"instance scenario action information schema",
1023 "$schema": "http://json-schema.org/draft-04/schema#",
1026 "start":{"type": "null"},
1027 "pause":{"type": "null"},
1028 "resume":{"type": "null"},
1029 "shutoff":{"type": "null"},
1030 "shutdown":{"type": "null"},
1031 "forceOff":{"type": "null"},
1032 "rebuild":{"type": "null"},
1034 "type": ["object","null"],
1036 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1037 "vnfs":{"type": "array", "items":{"type":"string"}},
1038 "vms":{"type": "array", "items":{"type":"string"}}
1041 #"maxProperties": 1,
1042 "additionalProperties": False