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