Changes in openmano_schemas for OSM R1
[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"
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
58 metadata_schema={
59 "type":"object",
60 "properties":{
61 "architecture": {"type":"string"},
62 "use_incremental": {"type":"string","enum":["yes","no"]},
63 "vpci": pci_schema,
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"]}
69 }
70 }
71
72 #Schema for the configuration file
73 config_schema = {
74 "title":"configuration response information schema",
75 "$schema": "http://json-schema.org/draft-04/schema#",
76 "type":"object",
77 "properties":{
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": {
96 "type": "array",
97 "items": {"OneOf" : [
98 port_schema,
99 {"type":"object", "properties":{"from": port_schema, "to": port_schema}, "required": ["from","to"]}
100 ]}
101 },
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,
110 },
111 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
112 "additionalProperties": False
113 }
114
115 tenant_schema = {
116 "title":"tenant information schema",
117 "$schema": "http://json-schema.org/draft-04/schema#",
118 "type":"object",
119 "properties":{
120 "tenant":{
121 "type":"object",
122 "properties":{
123 "name": nameshort_schema,
124 "description": description_schema,
125 },
126 "required": ["name"],
127 "additionalProperties": True
128 }
129 },
130 "required": ["tenant"],
131 "additionalProperties": False
132 }
133
134 tenant_edit_schema = {
135 "title":"tenant edit information schema",
136 "$schema": "http://json-schema.org/draft-04/schema#",
137 "type":"object",
138 "properties":{
139 "tenant":{
140 "type":"object",
141 "properties":{
142 "name": name_schema,
143 "description": description_schema,
144 },
145 "additionalProperties": False
146 }
147 },
148 "required": ["tenant"],
149 "additionalProperties": False
150 }
151
152 datacenter_schema_properties={
153 "name": name_schema,
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" }
159 }
160
161 datacenter_schema = {
162 "title":"datacenter information schema",
163 "$schema": "http://json-schema.org/draft-04/schema#",
164 "type":"object",
165 "properties":{
166 "datacenter":{
167 "type":"object",
168 "properties":datacenter_schema_properties,
169 "required": ["name", "vim_url"],
170 "additionalProperties": True
171 }
172 },
173 "required": ["datacenter"],
174 "additionalProperties": False
175 }
176
177
178 datacenter_edit_schema = {
179 "title":"datacenter edit nformation schema",
180 "$schema": "http://json-schema.org/draft-04/schema#",
181 "type":"object",
182 "properties":{
183 "datacenter":{
184 "type":"object",
185 "properties":datacenter_schema_properties,
186 "additionalProperties": False
187 }
188 },
189 "required": ["datacenter"],
190 "additionalProperties": False
191 }
192
193
194 netmap_new_schema = {
195 "title":"netmap new information schema",
196 "$schema": "http://json-schema.org/draft-04/schema#",
197 "type":"object",
198 "properties":{
199 "netmap":{ #delete from datacenter
200 "type":"object",
201 "properties":{
202 "name": name_schema, #name or uuid of net to change
203 "vim_id": id_schema,
204 "vim_name": name_schema
205 },
206 "minProperties": 1,
207 "additionalProperties": False
208 },
209 },
210 "required": ["netmap"],
211 "additionalProperties": False
212 }
213
214 netmap_edit_schema = {
215 "title":"netmap edit information schema",
216 "$schema": "http://json-schema.org/draft-04/schema#",
217 "type":"object",
218 "properties":{
219 "netmap":{ #delete from datacenter
220 "type":"object",
221 "properties":{
222 "name": name_schema, #name or uuid of net to change
223 },
224 "minProperties": 1,
225 "additionalProperties": False
226 },
227 },
228 "required": ["netmap"],
229 "additionalProperties": False
230 }
231
232 datacenter_action_schema = {
233 "title":"datacenter action information schema",
234 "$schema": "http://json-schema.org/draft-04/schema#",
235 "type":"object",
236 "properties":{
237 "net-update":{"type":"null",},
238 "net-edit":{
239 "type":"object",
240 "properties":{
241 "net": name_schema, #name or uuid of net to change
242 "name": name_schema,
243 "description": description_schema,
244 "shared": {"type": "boolean"}
245 },
246 "minProperties": 1,
247 "additionalProperties": False
248 },
249 "net-delete":{
250 "type":"object",
251 "properties":{
252 "net": name_schema, #name or uuid of net to change
253 },
254 "required": ["net"],
255 "additionalProperties": False
256 },
257 },
258 "minProperties": 1,
259 "maxProperties": 1,
260 "additionalProperties": False
261 }
262
263
264 datacenter_associate_schema={
265 "title":"datacenter associate information schema",
266 "$schema": "http://json-schema.org/draft-04/schema#",
267 "type":"object",
268 "properties":{
269 "datacenter":{
270 "type":"object",
271 "properties":{
272 "vim_tenant": id_schema,
273 "vim_tenant_name": nameshort_schema,
274 "vim_username": nameshort_schema,
275 "vim_password": nameshort_schema,
276 },
277 # "required": ["vim_tenant"],
278 "additionalProperties": True
279 }
280 },
281 "required": ["datacenter"],
282 "additionalProperties": False
283 }
284
285 dhcp_schema = {
286 "title":"DHCP schema",
287 "$schema": "http://json-schema.org/draft-04/schema#",
288 "type":"object",
289 "properties":{
290 "enabled": {"type": "boolean"},
291 "start-address": ip_schema,
292 "count": integer1_schema
293 }
294 }
295
296 ip_profile_schema = {
297 "title":"IP profile schema",
298 "$schema": "http://json-schema.org/draft-04/schema#",
299 "type":"object",
300 "properties":{
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,
306 "dhcp": dhcp_schema
307 },
308 }
309
310 key_pair_schema = {
311 "title": "Key-pair schema for cloud-init configuration schema",
312 "$schema": "http://json-schema.org/draft-04/schema#",
313 "type":"object",
314 "properties":{
315 "name": name_schema,
316 "key": {"type":"string"}
317 },
318 "required": ["key"],
319 "additionalProperties": False
320 }
321
322 cloud_config_user_schema = {
323 "title": "User schema for cloud-init configuration schema",
324 "$schema": "http://json-schema.org/draft-04/schema#",
325 "type":"object",
326 "properties":{
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"}}
331 },
332 "required": ["name"],
333 "additionalProperties": False
334 }
335
336 cloud_config_schema = {
337 "title": "Cloud-init configuration schema",
338 "$schema": "http://json-schema.org/draft-04/schema#",
339 "type":"object",
340 "properties":{
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}
344 },
345 "additionalProperties": False
346 }
347
348 internal_connection_element_schema = {
349 "type":"object",
350 "properties":{
351 "VNFC": name_schema,
352 "local_iface_name": name_schema
353 }
354 }
355
356 internal_connection_element_schema_v02 = {
357 "type":"object",
358 "properties":{
359 "VNFC": name_schema,
360 "local_iface_name": name_schema,
361 "ip-address": ip_schema
362 }
363 }
364
365 internal_connection_schema = {
366 "type":"object",
367 "properties":{
368 "name": name_schema,
369 "description":description_schema,
370 "type":{"type":"string", "enum":["bridge","data","ptp"]},
371 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
372 },
373 "required": ["name", "type", "elements"],
374 "additionalProperties": False
375 }
376
377 internal_connection_schema_v02 = {
378 "type":"object",
379 "properties":{
380 "name": name_schema,
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}
386 },
387 "required": ["name", "type", "elements"],
388 "additionalProperties": False
389 }
390
391 external_connection_schema = {
392 "type":"object",
393 "properties":{
394 "name": name_schema,
395 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
396 "VNFC": name_schema,
397 "local_iface_name": name_schema ,
398 "description":description_schema
399 },
400 "required": ["name", "type", "VNFC", "local_iface_name"],
401 "additionalProperties": False
402 }
403
404 external_connection_schema_v02 = {
405 "type":"object",
406 "properties":{
407 "name": name_schema,
408 "VNFC": name_schema,
409 "local_iface_name": name_schema ,
410 "description":description_schema
411 },
412 "required": ["name", "VNFC", "local_iface_name"],
413 "additionalProperties": False
414 }
415
416 interfaces_schema={
417 "type":"array",
418 "items":{
419 "type":"object",
420 "properties":{
421 "name":name_schema,
422 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
423 "bandwidth":bandwidth_schema,
424 "vpci":pci_schema,
425 "mac_address": mac_schema
426 },
427 "additionalProperties": False,
428 "required": ["name","dedicated", "bandwidth"]
429 }
430 }
431
432 bridge_interfaces_schema={
433 "type":"array",
434 "items":{
435 "type":"object",
436 "properties":{
437 "name": name_schema,
438 "bandwidth":bandwidth_schema,
439 "vpci":pci_schema,
440 "mac_address": mac_schema,
441 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
442 },
443 "additionalProperties": False,
444 "required": ["name"]
445 }
446 }
447
448 devices_schema={
449 "type":"array",
450 "items":{
451 "type":"object",
452 "properties":{
453 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
454 "image": path_schema,
455 "image metadata": metadata_schema,
456 "vpci":pci_schema,
457 "xml":xml_text_schema,
458 },
459 "additionalProperties": False,
460 "required": ["type"]
461 }
462 }
463
464
465 numa_schema = {
466 "type": "object",
467 "properties": {
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
476 },
477 "additionalProperties": False,
478 #"required": ["memory"]
479 }
480
481 vnfc_schema = {
482 "type":"object",
483 "properties":{
484 "name": name_schema,
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
489 "processor": {
490 "type":"object",
491 "properties":{
492 "model":description_schema,
493 "features":{"type":"array","items":nameshort_schema}
494 },
495 "required": ["model"],
496 "additionalProperties": False
497 },
498 "hypervisor": {
499 "type":"object",
500 "properties":{
501 "type":nameshort_schema,
502 "version":description_schema
503 },
504 },
505 "ram":integer0_schema,
506 "vcpus":integer0_schema,
507 "disk": integer1_schema,
508 "numas": {
509 "type": "array",
510 "items": numa_schema
511 },
512 "bridge-ifaces": bridge_interfaces_schema,
513 "devices": devices_schema
514
515 },
516 "required": ["name", "VNFC image"],
517 "additionalProperties": False
518 }
519
520 vnfd_schema_v01 = {
521 "title":"vnfd information schema v0.1",
522 "$schema": "http://json-schema.org/draft-04/schema#",
523 "type":"object",
524 "properties":{
525 "vnf":{
526 "type":"object",
527 "properties":{
528 "name": name_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}
537 },
538 "required": ["name","external-connections"],
539 "additionalProperties": True
540 }
541 },
542 "required": ["vnf"],
543 "additionalProperties": False
544 }
545
546 #VNFD schema for OSM R1
547 vnfd_schema_v02 = {
548 "title":"vnfd information schema v0.2",
549 "$schema": "http://json-schema.org/draft-04/schema#",
550 "type":"object",
551 "properties":{
552 "schema_version": {"type": "string", "enum": ["0.2"]},
553 "vnf":{
554 "type":"object",
555 "properties":{
556 "name": name_schema,
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}
566 },
567 "required": ["name"],
568 "additionalProperties": True
569 }
570 },
571 "required": ["vnf", "schema_version"],
572 "additionalProperties": False
573 }
574
575 #vnfd_schema = vnfd_schema_v01
576 #{
577 # "title":"vnfd information schema v0.2",
578 # "$schema": "http://json-schema.org/draft-04/schema#",
579 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
580 #}
581
582 graph_schema = {
583 "title":"graphical scenario descriptor information schema",
584 "$schema": "http://json-schema.org/draft-04/schema#",
585 "type":"object",
586 "properties":{
587 "x": integer0_schema,
588 "y": integer0_schema,
589 "ifaces": {
590 "type":"object",
591 "properties":{
592 "left": {"type":"array"},
593 "right": {"type":"array"},
594 "bottom": {"type":"array"},
595 }
596 }
597 },
598 "required": ["x","y"]
599 }
600
601 nsd_schema_v01 = {
602 "title":"network scenario descriptor information schema v0.1",
603 "$schema": "http://json-schema.org/draft-04/schema#",
604 "type":"object",
605 "properties":{
606 "name":name_schema,
607 "description": description_schema,
608 "tenant_id": id_schema, #only valid for admin
609 "public": {"type": "boolean"},
610 "topology":{
611 "type":"object",
612 "properties":{
613 "nodes": {
614 "type":"object",
615 "patternProperties":{
616 ".": {
617 "type": "object",
618 "properties":{
619 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
620 "vnf_id": id_schema,
621 "graph": graph_schema,
622 },
623 "patternProperties":{
624 "^(VNF )?model$": {"type": "string"}
625 },
626 "required": ["type"]
627 }
628 }
629 },
630 "connections": {
631 "type":"object",
632 "patternProperties":{
633 ".": {
634 "type": "object",
635 "properties":{
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
639 },
640 "required": ["nodes"]
641 },
642 }
643 }
644 },
645 "required": ["nodes"],
646 "additionalProperties": False
647 }
648 },
649 "required": ["name","topology"],
650 "additionalProperties": False
651 }
652
653 nsd_schema_v02 = {
654 "title":"network scenario descriptor information schema v0.2",
655 "$schema": "http://json-schema.org/draft-04/schema#",
656 "type":"object",
657 "properties":{
658 "schema_version": {"type": "string", "enum": ["0.2"]},
659 "scenario":{
660 "type":"object",
661 "properties":{
662 "name": name_schema,
663 "description": description_schema,
664 "tenant_id": id_schema, #only valid for admin
665 "public": {"type": "boolean"},
666 "vnfs": {
667 "type":"object",
668 "patternProperties":{
669 ".": {
670 "type": "object",
671 "properties":{
672 "vnf_id": id_schema,
673 "graph": graph_schema,
674 "vnf_name": name_schema,
675 },
676 }
677 },
678 "minProperties": 1
679 },
680 "networks": {
681 "type":"object",
682 "patternProperties":{
683 ".": {
684 "type": "object",
685 "properties":{
686 "interfaces":{"type":"array", "minLength":1},
687 "type": {"type": "string", "enum":["dataplane", "bridge"]},
688 "external" : {"type": "boolean"},
689 "graph": graph_schema
690 },
691 "required": ["interfaces"]
692 },
693 }
694 },
695
696 },
697 "required": ["vnfs", "name"],
698 "additionalProperties": False
699 }
700 },
701 "required": ["scenario","schema_version"],
702 "additionalProperties": False
703 }
704
705 #NSD schema for OSM R1
706 nsd_schema_v03 = {
707 "title":"network scenario descriptor information schema v0.3",
708 "$schema": "http://json-schema.org/draft-04/schema#",
709 "type":"object",
710 "properties":{
711 "schema_version": {"type": "string", "enum": ["0.3"]},
712 "scenario":{
713 "type":"object",
714 "properties":{
715 "name": name_schema,
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 #"site": name_schema,
721 "vnfs": {
722 "type":"object",
723 "patternProperties":{
724 ".": {
725 "type": "object",
726 "properties":{
727 "vnf_id": id_schema,
728 "graph": graph_schema,
729 "vnf_name": name_schema,
730 "cloud-config": cloud_config_schema, #particular for a vnf
731 #"site": name_schema,
732 "internal-connections": {
733 "type": "object",
734 "patternProperties": {
735 ".": {
736 "type": "object",
737 "properties": {
738 "ip-profile": ip_profile_schema,
739 "elements": {
740 "type" : "array",
741 "items":{
742 "type":"object",
743 "properties":{
744 "VNFC": name_schema,
745 "local_iface_name": name_schema,
746 "ip-address": ip_schema
747 },
748 "required": ["VNFC", "local_iface_name"],
749 }
750 }
751 }
752 }
753 }
754 }
755 },
756 }
757 },
758 "minProperties": 1
759 },
760 "networks": {
761 "type":"object",
762 "patternProperties":{
763 ".": {
764 "type": "object",
765 "properties":{
766 "interfaces":{
767 "type":"array",
768 "minLength":1,
769 "items":{
770 "type":"object",
771 "properties":{
772 "ip-address": ip_schema
773 },
774 "patternProperties":{
775 ".": {"type": "string"}
776 }
777 }
778 },
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
784 },
785 "required": ["interfaces"]
786 },
787 }
788 },
789
790 },
791 "required": ["vnfs", "networks","name"],
792 "additionalProperties": False
793 }
794 },
795 "required": ["scenario","schema_version"],
796 "additionalProperties": False
797 }
798
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]
804 #}
805
806 scenario_edit_schema = {
807 "title":"edit scenario information schema",
808 "$schema": "http://json-schema.org/draft-04/schema#",
809 "type":"object",
810 "properties":{
811 "name":name_schema,
812 "description": description_schema,
813 "topology":{
814 "type":"object",
815 "properties":{
816 "nodes": {
817 "type":"object",
818 "patternProperties":{
819 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
820 "type":"object",
821 "properties":{
822 "graph":{
823 "type": "object",
824 "properties":{
825 "x": integer0_schema,
826 "y": integer0_schema,
827 "ifaces":{ "type": "object"}
828 }
829 },
830 "description": description_schema,
831 "name": name_schema
832 }
833 }
834 }
835 }
836 },
837 "required": ["nodes"],
838 "additionalProperties": False
839 }
840 },
841 "additionalProperties": False
842 }
843
844 scenario_action_schema = {
845 "title":"scenario action information schema",
846 "$schema": "http://json-schema.org/draft-04/schema#",
847 "type":"object",
848 "properties":{
849 "start":{
850 "type": "object",
851 "properties": {
852 "instance_name":name_schema,
853 "description":description_schema,
854 "datacenter": {"type": "string"}
855 },
856 "required": ["instance_name"]
857 },
858 "deploy":{
859 "type": "object",
860 "properties": {
861 "instance_name":name_schema,
862 "description":description_schema,
863 "datacenter": {"type": "string"}
864 },
865 "required": ["instance_name"]
866 },
867 "reserve":{
868 "type": "object",
869 "properties": {
870 "instance_name":name_schema,
871 "description":description_schema,
872 "datacenter": {"type": "string"}
873 },
874 "required": ["instance_name"]
875 },
876 "verify":{
877 "type": "object",
878 "properties": {
879 "instance_name":name_schema,
880 "description":description_schema,
881 "datacenter": {"type": "string"}
882 },
883 "required": ["instance_name"]
884 }
885 },
886 "minProperties": 1,
887 "maxProperties": 1,
888 "additionalProperties": False
889 }
890
891 instance_scenario_create_schema_v01 = {
892 "title":"instance scenario create information schema v0.1",
893 "$schema": "http://json-schema.org/draft-04/schema#",
894 "type":"object",
895 "properties":{
896 "schema_version": {"type": "string", "enum": ["0.1"]},
897 "instance":{
898 "type":"object",
899 "properties":{
900 "name":name_schema,
901 "description":description_schema,
902 "site": name_schema,
903 "action":{"enum": ["deploy","reserve","verify" ]},
904 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
905 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
906 "vnfs":{ #mapping from scenario to datacenter
907 "type": "object",
908 "patternProperties":{
909 ".": {
910 "type": "object",
911 "properties":{
912 "name": name_schema, #override vnf name
913 "site": name_schema,
914 #"metadata": {"type": "object"},
915 #"user_data": {"type": "string"}
916 "cloud-config": cloud_config_schema, #particular for a vnf
917 "external-connections": {
918 "type": "object",
919 "patternProperties": {
920 ".": {
921 "type": "object",
922 "properties": {
923 "vim-network-name": name_schema,
924 "ip-address": ip_schema
925 }
926 }
927 }
928 },
929 "internal-connections": {
930 "type": "object",
931 "patternProperties": {
932 ".": {
933 "type": "object",
934 "properties": {
935 "ip-profile": ip_profile_schema,
936 "elements": {
937 "type" : "array",
938 "items":{
939 "type":"object",
940 "properties":{
941 "VNFC": name_schema,
942 "local_iface_name": name_schema,
943 "ip-address": ip_schema
944 },
945 "required": ["VNFC", "local_iface_name"],
946 }
947 }
948 }
949 }
950 }
951 }
952 }
953 }
954 },
955 },
956 "networks":{ #mapping from scenario to datacenter
957 "type": "object",
958 "patternProperties":{
959 ".": {
960 "type": "object",
961 "properties":{
962 "interfaces":{
963 "type":"array",
964 "minLength":1,
965 "items":{
966 "type":"object",
967 "properties":{
968 "ip-address": ip_schema
969 },
970 "patternProperties":{
971 ".": {"type": "string"}
972 }
973 }
974 },
975 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
976 "netmap-use": name_schema,
977 "name": name_schema, #override network name
978 "ip-profile": ip_profile_schema,
979 #"site": name_schema,
980 "vim-network-name": name_schema
981 }
982 }
983 },
984 },
985 },
986 "additionalProperties": False,
987 "required": ["name"]
988 },
989 },
990 "required": ["instance"],
991 "additionalProperties": False
992 }
993
994 instance_scenario_action_schema = {
995 "title":"instance scenario action information schema",
996 "$schema": "http://json-schema.org/draft-04/schema#",
997 "type":"object",
998 "properties":{
999 "start":{"type": "null"},
1000 "pause":{"type": "null"},
1001 "resume":{"type": "null"},
1002 "shutoff":{"type": "null"},
1003 "shutdown":{"type": "null"},
1004 "forceOff":{"type": "null"},
1005 "rebuild":{"type": "null"},
1006 "reboot":{
1007 "type": ["object","null"],
1008 },
1009 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1010 "vnfs":{"type": "array", "items":{"type":"string"}},
1011 "vms":{"type": "array", "items":{"type":"string"}}
1012 },
1013 "minProperties": 1,
1014 #"maxProperties": 1,
1015 "additionalProperties": False
1016 }