fix logging to console_proxy_thread.py
[osm/RO.git] / openmano_schemas.py
1 # -*- coding: utf-8 -*-
2
3 ##
4 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5 # This file is part of openmano
6 # All Rights Reserved.
7 #
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
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
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
18 # under the License.
19 #
20 # For those usages not covered by the Apache License, Version 2.0 please
21 # contact with: nfvlabs@tid.es
22 ##
23
24 '''
25 JSON schemas used by openmano httpserver.py module to parse the different files and messages sent through the API
26 '''
27 __author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
28 __date__ ="$09-oct-2014 09:09:48$"
29
30 #Basis schemas
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"]}
57 checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"}
58 size_schema={"type":"integer","minimum":1,"maximum":100}
59
60 metadata_schema={
61 "type":"object",
62 "properties":{
63 "architecture": {"type":"string"},
64 "use_incremental": {"type":"string","enum":["yes","no"]},
65 "vpci": pci_schema,
66 "os_distro": {"type":"string"},
67 "os_type": {"type":"string"},
68 "os_version": {"type":"string"},
69 "bus": {"type":"string"},
70 "topology": {"type":"string", "enum": ["oneSocket"]}
71 }
72 }
73
74 #Schema for the configuration file
75 config_schema = {
76 "title":"configuration response information schema",
77 "$schema": "http://json-schema.org/draft-04/schema#",
78 "type":"object",
79 "properties":{
80 "http_port": port_schema,
81 "http_admin_port": port_schema,
82 "http_host": nameshort_schema,
83 "vnf_repository": path_schema,
84 "db_host": nameshort_schema,
85 "db_user": nameshort_schema,
86 "db_passwd": {"type":"string"},
87 "db_name": nameshort_schema,
88 # Next fields will disappear once the MANO API includes appropriate primitives
89 "vim_url": http_schema,
90 "vim_url_admin": http_schema,
91 "vim_name": nameshort_schema,
92 "vim_tenant_name": nameshort_schema,
93 "mano_tenant_name": nameshort_schema,
94 "mano_tenant_id": id_schema,
95 "http_console_proxy": {"type":"boolean"},
96 "http_console_host": nameshort_schema,
97 "http_console_ports": {
98 "type": "array",
99 "items": {"OneOf" : [
100 port_schema,
101 {"type":"object", "properties":{"from": port_schema, "to": port_schema}, "required": ["from","to"]}
102 ]}
103 },
104 "log_level": log_level_schema,
105 "log_socket_level": log_level_schema,
106 "log_level_db": log_level_schema,
107 "log_level_vim": log_level_schema,
108 "log_level_nfvo": log_level_schema,
109 "log_level_http": log_level_schema,
110 "log_level_console": log_level_schema,
111 "log_file_db": path_schema,
112 "log_file_vim": path_schema,
113 "log_file_nfvo": path_schema,
114 "log_file_http": path_schema,
115 "log_file_console": path_schema,
116 "log_socket_host": nameshort_schema,
117 "log_socket_port": port_schema,
118 "log_file": path_schema,
119 },
120 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
121 "additionalProperties": False
122 }
123
124 tenant_schema = {
125 "title":"tenant information schema",
126 "$schema": "http://json-schema.org/draft-04/schema#",
127 "type":"object",
128 "properties":{
129 "tenant":{
130 "type":"object",
131 "properties":{
132 "name": nameshort_schema,
133 "description": description_schema,
134 },
135 "required": ["name"],
136 "additionalProperties": True
137 }
138 },
139 "required": ["tenant"],
140 "additionalProperties": False
141 }
142
143 tenant_edit_schema = {
144 "title":"tenant edit information schema",
145 "$schema": "http://json-schema.org/draft-04/schema#",
146 "type":"object",
147 "properties":{
148 "tenant":{
149 "type":"object",
150 "properties":{
151 "name": name_schema,
152 "description": description_schema,
153 },
154 "additionalProperties": False
155 }
156 },
157 "required": ["tenant"],
158 "additionalProperties": False
159 }
160
161 datacenter_schema_properties={
162 "name": name_schema,
163 "description": description_schema,
164 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
165 "vim_url": description_schema,
166 "vim_url_admin": description_schema,
167 "config": { "type":"object" }
168 }
169
170 datacenter_schema = {
171 "title":"datacenter information schema",
172 "$schema": "http://json-schema.org/draft-04/schema#",
173 "type":"object",
174 "properties":{
175 "datacenter":{
176 "type":"object",
177 "properties":datacenter_schema_properties,
178 "required": ["name", "vim_url"],
179 "additionalProperties": True
180 }
181 },
182 "required": ["datacenter"],
183 "additionalProperties": False
184 }
185
186
187 datacenter_edit_schema = {
188 "title":"datacenter edit nformation schema",
189 "$schema": "http://json-schema.org/draft-04/schema#",
190 "type":"object",
191 "properties":{
192 "datacenter":{
193 "type":"object",
194 "properties":datacenter_schema_properties,
195 "additionalProperties": False
196 }
197 },
198 "required": ["datacenter"],
199 "additionalProperties": False
200 }
201
202
203 netmap_new_schema = {
204 "title":"netmap new information schema",
205 "$schema": "http://json-schema.org/draft-04/schema#",
206 "type":"object",
207 "properties":{
208 "netmap":{ #delete from datacenter
209 "type":"object",
210 "properties":{
211 "name": name_schema, #name or uuid of net to change
212 "vim_id": id_schema,
213 "vim_name": name_schema
214 },
215 "minProperties": 1,
216 "additionalProperties": False
217 },
218 },
219 "required": ["netmap"],
220 "additionalProperties": False
221 }
222
223 netmap_edit_schema = {
224 "title":"netmap edit information schema",
225 "$schema": "http://json-schema.org/draft-04/schema#",
226 "type":"object",
227 "properties":{
228 "netmap":{ #delete from datacenter
229 "type":"object",
230 "properties":{
231 "name": name_schema, #name or uuid of net to change
232 },
233 "minProperties": 1,
234 "additionalProperties": False
235 },
236 },
237 "required": ["netmap"],
238 "additionalProperties": False
239 }
240
241 datacenter_action_schema = {
242 "title":"datacenter action information schema",
243 "$schema": "http://json-schema.org/draft-04/schema#",
244 "type":"object",
245 "properties":{
246 "net-update":{"type":"null",},
247 "net-edit":{
248 "type":"object",
249 "properties":{
250 "net": name_schema, #name or uuid of net to change
251 "name": name_schema,
252 "description": description_schema,
253 "shared": {"type": "boolean"}
254 },
255 "minProperties": 1,
256 "additionalProperties": False
257 },
258 "net-delete":{
259 "type":"object",
260 "properties":{
261 "net": name_schema, #name or uuid of net to change
262 },
263 "required": ["net"],
264 "additionalProperties": False
265 },
266 },
267 "minProperties": 1,
268 "maxProperties": 1,
269 "additionalProperties": False
270 }
271
272
273 datacenter_associate_schema={
274 "title":"datacenter associate information schema",
275 "$schema": "http://json-schema.org/draft-04/schema#",
276 "type":"object",
277 "properties":{
278 "datacenter":{
279 "type":"object",
280 "properties":{
281 "vim_tenant": name_schema,
282 "vim_tenant_name": name_schema,
283 "vim_username": nameshort_schema,
284 "vim_password": nameshort_schema,
285 "config": {"type": "object"}
286 },
287 # "required": ["vim_tenant"],
288 "additionalProperties": True
289 }
290 },
291 "required": ["datacenter"],
292 "additionalProperties": False
293 }
294
295 dhcp_schema = {
296 "title":"DHCP schema",
297 "$schema": "http://json-schema.org/draft-04/schema#",
298 "type":"object",
299 "properties":{
300 "enabled": {"type": "boolean"},
301 "start-address": ip_schema,
302 "count": integer1_schema
303 },
304 "required": ["enabled", "start-address", "count"],
305 }
306
307 ip_profile_schema = {
308 "title":"IP profile schema",
309 "$schema": "http://json-schema.org/draft-04/schema#",
310 "type":"object",
311 "properties":{
312 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
313 "subnet-address": ip_prefix_schema,
314 "gateway-address": ip_schema,
315 "dns-address": ip_schema,
316 "dhcp": dhcp_schema
317 },
318 }
319
320 key_pair_schema = {
321 "title": "Key-pair schema for cloud-init configuration schema",
322 "$schema": "http://json-schema.org/draft-04/schema#",
323 "type":"object",
324 "properties":{
325 "name": name_schema,
326 "key": {"type":"string"}
327 },
328 "required": ["key"],
329 "additionalProperties": False
330 }
331
332 cloud_config_user_schema = {
333 "title": "User schema for cloud-init configuration schema",
334 "$schema": "http://json-schema.org/draft-04/schema#",
335 "type":"object",
336 "properties":{
337 "name": nameshort_schema,
338 "user-info": {"type":"string"},
339 #"key-pairs": {"type" : "array", "items": key_pair_schema}
340 "key-pairs": {"type" : "array", "items": {"type":"string"}}
341 },
342 "required": ["name"],
343 "additionalProperties": False
344 }
345
346 cloud_config_schema = {
347 "title": "Cloud-init configuration schema",
348 "$schema": "http://json-schema.org/draft-04/schema#",
349 "type":"object",
350 "properties":{
351 #"key-pairs": {"type" : "array", "items": key_pair_schema},
352 "key-pairs": {"type" : "array", "items": {"type":"string"}},
353 "users": {"type" : "array", "items": cloud_config_user_schema}
354 },
355 "additionalProperties": False
356 }
357
358 internal_connection_element_schema = {
359 "type":"object",
360 "properties":{
361 "VNFC": name_schema,
362 "local_iface_name": name_schema
363 }
364 }
365
366 internal_connection_element_schema_v02 = {
367 "type":"object",
368 "properties":{
369 "VNFC": name_schema,
370 "local_iface_name": name_schema,
371 "ip_address": ip_schema
372 }
373 }
374
375 internal_connection_schema = {
376 "type":"object",
377 "properties":{
378 "name": name_schema,
379 "description":description_schema,
380 "type":{"type":"string", "enum":["bridge","data","ptp"]},
381 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
382 },
383 "required": ["name", "type", "elements"],
384 "additionalProperties": False
385 }
386
387 internal_connection_schema_v02 = {
388 "type":"object",
389 "properties":{
390 "name": name_schema,
391 "description":description_schema,
392 "type": {"type": "string", "enum":["e-line", "e-lan"]},
393 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
394 "ip-profile": ip_profile_schema,
395 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":2}
396 },
397 "required": ["name", "type", "implementation", "elements"],
398 "additionalProperties": False
399 }
400
401 external_connection_schema = {
402 "type":"object",
403 "properties":{
404 "name": name_schema,
405 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
406 "VNFC": name_schema,
407 "local_iface_name": name_schema ,
408 "description":description_schema
409 },
410 "required": ["name", "type", "VNFC", "local_iface_name"],
411 "additionalProperties": False
412 }
413
414 #Not yet used
415 external_connection_schema_v02 = {
416 "type":"object",
417 "properties":{
418 "name": name_schema,
419 "mgmt": {"type":"boolean"},
420 "type": {"type": "string", "enum":["e-line", "e-lan"]},
421 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
422 "VNFC": name_schema,
423 "local_iface_name": name_schema ,
424 "description":description_schema
425 },
426 "required": ["name", "type", "VNFC", "local_iface_name"],
427 "additionalProperties": False
428 }
429
430 interfaces_schema={
431 "type":"array",
432 "items":{
433 "type":"object",
434 "properties":{
435 "name":name_schema,
436 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
437 "bandwidth":bandwidth_schema,
438 "vpci":pci_schema,
439 "mac_address": mac_schema
440 },
441 "additionalProperties": False,
442 "required": ["name","dedicated", "bandwidth"]
443 }
444 }
445
446 bridge_interfaces_schema={
447 "type":"array",
448 "items":{
449 "type":"object",
450 "properties":{
451 "name": name_schema,
452 "bandwidth":bandwidth_schema,
453 "vpci":pci_schema,
454 "mac_address": mac_schema,
455 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]},
456 "port-security": {"type" : "boolean"},
457 "floating-ip": {"type" : "boolean"}
458 },
459 "additionalProperties": False,
460 "required": ["name"]
461 }
462 }
463
464 devices_schema={
465 "type":"array",
466 "items":{
467 "type":"object",
468 "properties":{
469 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
470 "image": path_schema,
471 "image name": name_schema,
472 "image checksum": checksum_schema,
473 "image metadata": metadata_schema,
474 "size": size_schema,
475 "vpci":pci_schema,
476 "xml":xml_text_schema,
477 },
478 "additionalProperties": False,
479 "required": ["type"]
480 }
481 }
482
483
484 numa_schema = {
485 "type": "object",
486 "properties": {
487 "memory":integer1_schema,
488 "cores":integer1_schema,
489 "paired-threads":integer1_schema,
490 "threads":integer1_schema,
491 "cores-id":{"type":"array","items":integer0_schema},
492 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
493 "threads-id":{"type":"array","items":integer0_schema},
494 "interfaces":interfaces_schema
495 },
496 "additionalProperties": False,
497 #"required": ["memory"]
498 }
499
500 config_files_schema = {
501 "title": "Config files for cloud init schema",
502 "$schema": "http://json-schema.org/draft-04/schema#",
503 "type": "object",
504 "properties": {
505 "dest": path_schema,
506 "encoding": {"type": "string", "enum": ["b64", "base64", "gz", "gz+b64", "gz+base64", "gzip+b64", "gzip+base64"]}, #by default text
507 "content": {"type": "string"},
508 "permissions": {"type": "string"}, # tiypically octal notation '0644'
509 "owner": {"type": "string"}, # format: owner:group
510
511 },
512 "additionalProperties": False,
513 "required": ["dest", "content"],
514 }
515
516 boot_data_vdu_schema = {
517 "title": "Boot data (Cloud-init) configuration schema",
518 "$schema": "http://json-schema.org/draft-04/schema#",
519 "type": "object",
520 "properties":{
521 "key-pairs": {"type" : "array", "items": {"type":"string"}},
522 "users": {"type" : "array", "items": cloud_config_user_schema},
523 "user-data": {"type" : "string"}, # scrip to run
524 "config-files": {"type": "array", "items": config_files_schema},
525 # NOTE: “user-data” are mutually exclusive with users and config-files because user/files are injected using user-data
526 "boot-data-drive": {"type": "boolean"},
527 },
528 "additionalProperties": False,
529 }
530
531 vnfc_schema = {
532 "type":"object",
533 "properties":{
534 "name": name_schema,
535 "description": description_schema,
536 "VNFC image": {"oneOf": [path_schema, http_schema]},
537 "image name": name_schema,
538 "image checksum": checksum_schema,
539 "image metadata": metadata_schema,
540 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
541 "processor": {
542 "type":"object",
543 "properties":{
544 "model":description_schema,
545 "features":{"type":"array","items":nameshort_schema}
546 },
547 "required": ["model"],
548 "additionalProperties": False
549 },
550 "hypervisor": {
551 "type":"object",
552 "properties":{
553 "type":nameshort_schema,
554 "version":description_schema
555 },
556 },
557 "ram":integer0_schema,
558 "vcpus":integer0_schema,
559 "disk": integer1_schema,
560 "numas": {
561 "type": "array",
562 "items": numa_schema
563 },
564 "bridge-ifaces": bridge_interfaces_schema,
565 "devices": devices_schema,
566 "boot-data" : boot_data_vdu_schema
567
568 },
569 "required": ["name"],
570 "oneOf": [
571 {"required": ["VNFC image"]},
572 {"required": ["image name"]}
573 ],
574 "additionalProperties": False
575 }
576
577 vnfd_schema_v01 = {
578 "title":"vnfd information schema v0.1",
579 "$schema": "http://json-schema.org/draft-04/schema#",
580 "type":"object",
581 "properties":{
582 "vnf":{
583 "type":"object",
584 "properties":{
585 "name": name_schema,
586 "description": description_schema,
587 "class": nameshort_schema,
588 "public": {"type" : "boolean"},
589 "physical": {"type" : "boolean"},
590 "tenant_id": id_schema, #only valid for admin
591 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
592 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
593 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
594 },
595 "required": ["name","external-connections"],
596 "additionalProperties": True
597 }
598 },
599 "required": ["vnf"],
600 "additionalProperties": False
601 }
602
603 #VNFD schema for OSM R1
604 vnfd_schema_v02 = {
605 "title":"vnfd information schema v0.2",
606 "$schema": "http://json-schema.org/draft-04/schema#",
607 "type":"object",
608 "properties":{
609 "schema_version": {"type": "string", "enum": ["0.2"]},
610 "vnf":{
611 "type":"object",
612 "properties":{
613 "name": name_schema,
614 "description": description_schema,
615 "class": nameshort_schema,
616 "public": {"type" : "boolean"},
617 "physical": {"type" : "boolean"},
618 "tenant_id": id_schema, #only valid for admin
619 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
620 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
621 # "cloud-config": cloud_config_schema, #common for all vnfcs
622 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
623 },
624 "required": ["name"],
625 "additionalProperties": True
626 }
627 },
628 "required": ["vnf", "schema_version"],
629 "additionalProperties": False
630 }
631
632 #vnfd_schema = vnfd_schema_v01
633 #{
634 # "title":"vnfd information schema v0.2",
635 # "$schema": "http://json-schema.org/draft-04/schema#",
636 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
637 #}
638
639 graph_schema = {
640 "title":"graphical scenario descriptor information schema",
641 "$schema": "http://json-schema.org/draft-04/schema#",
642 "type":"object",
643 "properties":{
644 "x": integer0_schema,
645 "y": integer0_schema,
646 "ifaces": {
647 "type":"object",
648 "properties":{
649 "left": {"type":"array"},
650 "right": {"type":"array"},
651 "bottom": {"type":"array"},
652 }
653 }
654 },
655 "required": ["x","y"]
656 }
657
658 nsd_schema_v01 = {
659 "title":"network scenario descriptor information schema v0.1",
660 "$schema": "http://json-schema.org/draft-04/schema#",
661 "type":"object",
662 "properties":{
663 "name":name_schema,
664 "description": description_schema,
665 "tenant_id": id_schema, #only valid for admin
666 "public": {"type": "boolean"},
667 "topology":{
668 "type":"object",
669 "properties":{
670 "nodes": {
671 "type":"object",
672 "patternProperties":{
673 ".": {
674 "type": "object",
675 "properties":{
676 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
677 "vnf_id": id_schema,
678 "graph": graph_schema,
679 },
680 "patternProperties":{
681 "^(VNF )?model$": {"type": "string"}
682 },
683 "required": ["type"]
684 }
685 }
686 },
687 "connections": {
688 "type":"object",
689 "patternProperties":{
690 ".": {
691 "type": "object",
692 "properties":{
693 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
694 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
695 "graph": graph_schema
696 },
697 "required": ["nodes"]
698 },
699 }
700 }
701 },
702 "required": ["nodes"],
703 "additionalProperties": False
704 }
705 },
706 "required": ["name","topology"],
707 "additionalProperties": False
708 }
709
710 nsd_schema_v02 = {
711 "title":"network scenario descriptor information schema v0.2",
712 "$schema": "http://json-schema.org/draft-04/schema#",
713 "type":"object",
714 "properties":{
715 "schema_version": schema_version_2,
716 "scenario":{
717 "type":"object",
718 "properties":{
719 "name": name_schema,
720 "description": description_schema,
721 "tenant_id": id_schema, #only valid for admin
722 "public": {"type": "boolean"},
723 "vnfs": {
724 "type":"object",
725 "patternProperties":{
726 ".": {
727 "type": "object",
728 "properties":{
729 "vnf_id": id_schema,
730 "graph": graph_schema,
731 "vnf_name": name_schema,
732 },
733 }
734 },
735 "minProperties": 1
736 },
737 "networks": {
738 "type":"object",
739 "patternProperties":{
740 ".": {
741 "type": "object",
742 "properties":{
743 "interfaces":{"type":"array", "minLength":1},
744 "type": {"type": "string", "enum":["dataplane", "bridge"]},
745 "external" : {"type": "boolean"},
746 "graph": graph_schema
747 },
748 "required": ["interfaces"]
749 },
750 }
751 },
752
753 },
754 "required": ["vnfs", "name"],
755 "additionalProperties": False
756 }
757 },
758 "required": ["scenario","schema_version"],
759 "additionalProperties": False
760 }
761
762 #NSD schema for OSM R1
763 nsd_schema_v03 = {
764 "title":"network scenario descriptor information schema v0.3",
765 "$schema": "http://json-schema.org/draft-04/schema#",
766 "type":"object",
767 "properties":{
768 "schema_version": {"type": "string", "enum": ["0.3"]},
769 "scenario":{
770 "type":"object",
771 "properties":{
772 "name": name_schema,
773 "description": description_schema,
774 "tenant_id": id_schema, #only valid for admin
775 "public": {"type": "boolean"},
776 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
777 #"datacenter": name_schema,
778 "vnfs": {
779 "type":"object",
780 "patternProperties":{
781 ".": {
782 "type": "object",
783 "properties":{
784 "vnf_id": id_schema,
785 "graph": graph_schema,
786 "vnf_name": name_schema,
787 #"cloud-config": cloud_config_schema, #particular for a vnf
788 #"datacenter": name_schema,
789 "internal-connections": {
790 "type": "object",
791 "patternProperties": {
792 ".": {
793 "type": "object",
794 "properties": {
795 "ip-profile": ip_profile_schema,
796 "elements": {
797 "type" : "array",
798 "items":{
799 "type":"object",
800 "properties":{
801 "VNFC": name_schema,
802 "local_iface_name": name_schema,
803 "ip_address": ip_schema
804 },
805 "required": ["VNFC", "local_iface_name"],
806 }
807 }
808 }
809 }
810 }
811 }
812 },
813 }
814 },
815 "minProperties": 1
816 },
817 "networks": {
818 "type":"object",
819 "patternProperties":{
820 ".": {
821 "type": "object",
822 "properties":{
823 "interfaces":{
824 "type":"array",
825 "minLength":1,
826 "items":{
827 "type":"object",
828 "properties":{
829 "vnf": name_schema,
830 "vnf_interface": name_schema,
831 "ip_address": ip_schema
832 },
833 "required": ["vnf", "vnf_interface"],
834 }
835 },
836 "type": {"type": "string", "enum":["e-line", "e-lan"]},
837 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
838 "external" : {"type": "boolean"},
839 "graph": graph_schema,
840 "ip-profile": ip_profile_schema
841 },
842 "required": ["interfaces"]
843 },
844 }
845 },
846
847 },
848 "required": ["vnfs", "networks","name"],
849 "additionalProperties": False
850 }
851 },
852 "required": ["scenario","schema_version"],
853 "additionalProperties": False
854 }
855
856 #scenario_new_schema = {
857 # "title":"new scenario information schema",
858 # "$schema": "http://json-schema.org/draft-04/schema#",
859 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
860 # "oneOf": [nsd_schema_v01]
861 #}
862
863 scenario_edit_schema = {
864 "title":"edit scenario information schema",
865 "$schema": "http://json-schema.org/draft-04/schema#",
866 "type":"object",
867 "properties":{
868 "name":name_schema,
869 "description": description_schema,
870 "topology":{
871 "type":"object",
872 "properties":{
873 "nodes": {
874 "type":"object",
875 "patternProperties":{
876 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
877 "type":"object",
878 "properties":{
879 "graph":{
880 "type": "object",
881 "properties":{
882 "x": integer0_schema,
883 "y": integer0_schema,
884 "ifaces":{ "type": "object"}
885 }
886 },
887 "description": description_schema,
888 "name": name_schema
889 }
890 }
891 }
892 }
893 },
894 "required": ["nodes"],
895 "additionalProperties": False
896 }
897 },
898 "additionalProperties": False
899 }
900
901 scenario_action_schema = {
902 "title":"scenario action information schema",
903 "$schema": "http://json-schema.org/draft-04/schema#",
904 "type":"object",
905 "properties":{
906 "start":{
907 "type": "object",
908 "properties": {
909 "instance_name":name_schema,
910 "description":description_schema,
911 "datacenter": {"type": "string"}
912 },
913 "required": ["instance_name"]
914 },
915 "deploy":{
916 "type": "object",
917 "properties": {
918 "instance_name":name_schema,
919 "description":description_schema,
920 "datacenter": {"type": "string"}
921 },
922 "required": ["instance_name"]
923 },
924 "reserve":{
925 "type": "object",
926 "properties": {
927 "instance_name":name_schema,
928 "description":description_schema,
929 "datacenter": {"type": "string"}
930 },
931 "required": ["instance_name"]
932 },
933 "verify":{
934 "type": "object",
935 "properties": {
936 "instance_name":name_schema,
937 "description":description_schema,
938 "datacenter": {"type": "string"}
939 },
940 "required": ["instance_name"]
941 }
942 },
943 "minProperties": 1,
944 "maxProperties": 1,
945 "additionalProperties": False
946 }
947
948 instance_scenario_create_schema_v01 = {
949 "title":"instance scenario create information schema v0.1",
950 "$schema": "http://json-schema.org/draft-04/schema#",
951 "type":"object",
952 "properties":{
953 "schema_version": {"type": "string", "enum": ["0.1"]},
954 "instance":{
955 "type":"object",
956 "properties":{
957 "name":name_schema,
958 "description":description_schema,
959 "datacenter": name_schema,
960 "scenario" : name_schema, #can be an UUID or name
961 "action":{"enum": ["deploy","reserve","verify" ]},
962 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
963 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
964 "vnfs":{ #mapping from scenario to datacenter
965 "type": "object",
966 "patternProperties":{
967 ".": {
968 "type": "object",
969 "properties":{
970 "name": name_schema, #override vnf name
971 "datacenter": name_schema,
972 #"metadata": {"type": "object"},
973 #"user_data": {"type": "string"}
974 #"cloud-config": cloud_config_schema, #particular for a vnf
975 "external-connections": {
976 "type": "object",
977 "patternProperties": {
978 ".": {
979 "type": "object",
980 "properties": {
981 "vim-network-name": name_schema,
982 "ip_address": ip_schema
983 }
984 }
985 }
986 },
987 "internal-connections": {
988 "type": "object",
989 "patternProperties": {
990 ".": {
991 "type": "object",
992 "properties": {
993 "ip-profile": ip_profile_schema,
994 "elements": {
995 "type" : "array",
996 "items":{
997 "type":"object",
998 "properties":{
999 "VNFC": name_schema,
1000 "local_iface_name": name_schema,
1001 "ip_address": ip_schema
1002 },
1003 "required": ["VNFC", "local_iface_name"],
1004 }
1005 }
1006 }
1007 }
1008 }
1009 }
1010 }
1011 }
1012 },
1013 },
1014 "networks":{ #mapping from scenario to datacenter
1015 "type": "object",
1016 "patternProperties":{
1017 ".": {
1018 "type": "object",
1019 "properties":{
1020 "interfaces":{
1021 "type":"array",
1022 "minLength":1,
1023 "items":{
1024 "type":"object",
1025 "properties":{
1026 "ip_address": ip_schema,
1027 "datacenter": name_schema,
1028 "vim-network-name": name_schema
1029 },
1030 "patternProperties":{
1031 ".": {"type": "string"}
1032 }
1033 }
1034 },
1035 "ip-profile": ip_profile_schema,
1036 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
1037 "sites": {
1038 "type":"array",
1039 "minLength":1,
1040 "items":{
1041 "type":"object",
1042 "properties":{
1043 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
1044 # for other networks openamno creates at VIM
1045 # Use netmap-create to force to create an external scenario network
1046 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
1047 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
1048 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
1049 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
1050 #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)
1051 "netmap-use": name_schema, #
1052 "vim-network-name": name_schema, #override network name
1053 #"ip-profile": ip_profile_schema,
1054 "datacenter": name_schema,
1055 }
1056 }
1057 },
1058
1059
1060
1061 }
1062 }
1063 },
1064 },
1065 },
1066 "additionalProperties": False,
1067 "required": ["name"]
1068 },
1069 },
1070 "required": ["instance"],
1071 "additionalProperties": False
1072 }
1073
1074 instance_scenario_action_schema = {
1075 "title":"instance scenario action information schema",
1076 "$schema": "http://json-schema.org/draft-04/schema#",
1077 "type":"object",
1078 "properties":{
1079 "start":{"type": "null"},
1080 "pause":{"type": "null"},
1081 "resume":{"type": "null"},
1082 "shutoff":{"type": "null"},
1083 "shutdown":{"type": "null"},
1084 "forceOff":{"type": "null"},
1085 "rebuild":{"type": "null"},
1086 "reboot":{
1087 "type": ["object","null"],
1088 },
1089 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1090 "vnfs":{"type": "array", "items":{"type":"string"}},
1091 "vms":{"type": "array", "items":{"type":"string"}}
1092 },
1093 "minProperties": 1,
1094 #"maxProperties": 1,
1095 "additionalProperties": False
1096 }