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