Adding cover to tox.ini default envs
[osm/RO.git] / RO / osm_ro / openmano_schemas.py
1 # -*- coding: utf-8 -*-
2
3 ##
4 # Copyright 2015 Telefonica Investigacion 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 # allows [] for wildcards. For that reason huge length limit is set
41 pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\[\]]{12,40}$"}
42
43 http_schema={"type":"string", "pattern":"^https?://[^'\"=]+$"}
44 bandwidth_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
45 memory_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
46 integer0_schema={"type":"integer","minimum":0}
47 integer1_schema={"type":"integer","minimum":1}
48 path_schema={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
49 vlan_schema={"type":"integer","minimum":1,"maximum":4095}
50 vlan1000_schema={"type":"integer","minimum":1000,"maximum":4095}
51 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
52 #mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
53 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]?)$"}
54 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])$"}
55 port_schema={"type":"integer","minimum":1,"maximum":65534}
56 object_schema={"type":"object"}
57 schema_version_2={"type":"integer","minimum":2,"maximum":2}
58 #schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
59 string_list = {"type": "array", "items": {"type": "string"}}
60 log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
61 checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"}
62 size_schema={"type":"integer","minimum":1,"maximum":100}
63 boolean_schema = {"type": "boolean"}
64 null_schema = {"type": "null"}
65
66 metadata_schema={
67 "type":"object",
68 "properties":{
69 "architecture": {"type":"string"},
70 "use_incremental": {"type":"string","enum":["yes","no"]},
71 "vpci": pci_schema,
72 "os_distro": {"type":"string"},
73 "os_type": {"type":"string"},
74 "os_version": {"type":"string"},
75 "bus": {"type":"string"},
76 "topology": {"type":"string", "enum": ["oneSocket"]}
77 }
78 }
79
80 #Schema for the configuration file
81 config_schema = {
82 "title":"configuration response information schema",
83 "$schema": "http://json-schema.org/draft-04/schema#",
84 "type":"object",
85 "properties":{
86 "http_port": port_schema,
87 "http_admin_port": port_schema,
88 "http_host": nameshort_schema,
89 "auto_push_VNF_to_VIMs": boolean_schema,
90 "vnf_repository": path_schema,
91 "db_host": nameshort_schema,
92 "db_user": nameshort_schema,
93 "db_passwd": {"type":"string"},
94 "db_name": nameshort_schema,
95 "db_ovim_host": nameshort_schema,
96 "db_ovim_user": nameshort_schema,
97 "db_ovim_passwd": {"type":"string"},
98 "db_ovim_name": nameshort_schema,
99 # Next fields will disappear once the MANO API includes appropriate primitives
100 "vim_url": http_schema,
101 "vim_url_admin": http_schema,
102 "vim_name": nameshort_schema,
103 "vim_tenant_name": nameshort_schema,
104 "mano_tenant_name": nameshort_schema,
105 "mano_tenant_id": id_schema,
106 "http_console_proxy": boolean_schema,
107 "http_console_host": nameshort_schema,
108 "http_console_ports": {
109 "type": "array",
110 "items": {"oneOf": [
111 port_schema,
112 {"type": "object", "properties": {"from": port_schema, "to": port_schema}, "required": ["from", "to"]}
113 ]}
114 },
115 "log_level": log_level_schema,
116 "log_socket_level": log_level_schema,
117 "log_level_db": log_level_schema,
118 "log_level_vim": log_level_schema,
119 "log_level_wim": log_level_schema,
120 "log_level_nfvo": log_level_schema,
121 "log_level_http": log_level_schema,
122 "log_level_console": log_level_schema,
123 "log_level_ovim": log_level_schema,
124 "log_level_sdn": log_level_schema,
125 "log_level_sdnconn": log_level_schema,
126 "log_file_db": path_schema,
127 "log_file_vim": path_schema,
128 "log_file_wim": path_schema,
129 "log_file_nfvo": path_schema,
130 "log_file_http": path_schema,
131 "log_file_console": path_schema,
132 "log_file_ovim": path_schema,
133 "log_file_sdn": path_schema,
134 "log_file_sdnconn": path_schema,
135 "log_socket_host": nameshort_schema,
136 "log_socket_port": port_schema,
137 "log_file": path_schema,
138 },
139 "required": ['db_user', 'db_passwd', 'db_name'],
140 "additionalProperties": False
141 }
142
143 tenant_schema = {
144 "title":"tenant information schema",
145 "$schema": "http://json-schema.org/draft-04/schema#",
146 "type":"object",
147 "properties":{
148 "tenant":{
149 "type":"object",
150 "properties":{
151 "name": nameshort_schema,
152 "description": description_schema,
153 },
154 "required": ["name"],
155 "additionalProperties": True
156 }
157 },
158 "required": ["tenant"],
159 "additionalProperties": False
160 }
161
162 tenant_edit_schema = {
163 "title":"tenant edit information schema",
164 "$schema": "http://json-schema.org/draft-04/schema#",
165 "type":"object",
166 "properties":{
167 "tenant":{
168 "type":"object",
169 "properties":{
170 "name": name_schema,
171 "description": description_schema,
172 },
173 "additionalProperties": False
174 }
175 },
176 "required": ["tenant"],
177 "additionalProperties": False
178 }
179
180 datacenter_schema_properties={
181 "name": name_schema,
182 "description": description_schema,
183 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
184 "vim_url": description_schema,
185 "vim_url_admin": description_schema,
186 "config": { "type":"object" }
187 }
188
189 datacenter_schema = {
190 "title":"datacenter information schema",
191 "$schema": "http://json-schema.org/draft-04/schema#",
192 "type":"object",
193 "properties":{
194 "datacenter":{
195 "type":"object",
196 "properties":datacenter_schema_properties,
197 "required": ["name", "vim_url"],
198 "additionalProperties": True
199 }
200 },
201 "required": ["datacenter"],
202 "additionalProperties": False
203 }
204
205
206 datacenter_edit_schema = {
207 "title":"datacenter edit nformation schema",
208 "$schema": "http://json-schema.org/draft-04/schema#",
209 "type":"object",
210 "properties":{
211 "datacenter":{
212 "type":"object",
213 "properties":datacenter_schema_properties,
214 "additionalProperties": False
215 }
216 },
217 "required": ["datacenter"],
218 "additionalProperties": False
219 }
220
221
222 netmap_new_schema = {
223 "title":"netmap new information schema",
224 "$schema": "http://json-schema.org/draft-04/schema#",
225 "type":"object",
226 "properties":{
227 "netmap":{ #delete from datacenter
228 "type":"object",
229 "properties":{
230 "name": name_schema, #name or uuid of net to change
231 "vim_id": id_schema,
232 "vim_name": name_schema
233 },
234 "minProperties": 1,
235 "additionalProperties": False
236 },
237 },
238 "required": ["netmap"],
239 "additionalProperties": False
240 }
241
242 netmap_edit_schema = {
243 "title":"netmap edit information schema",
244 "$schema": "http://json-schema.org/draft-04/schema#",
245 "type":"object",
246 "properties":{
247 "netmap":{ #delete from datacenter
248 "type":"object",
249 "properties":{
250 "name": name_schema, #name or uuid of net to change
251 },
252 "minProperties": 1,
253 "additionalProperties": False
254 },
255 },
256 "required": ["netmap"],
257 "additionalProperties": False
258 }
259
260 datacenter_action_schema = {
261 "title":"datacenter action information schema",
262 "$schema": "http://json-schema.org/draft-04/schema#",
263 "type":"object",
264 "properties":{
265 "check-connectivity": {"type": "null"},
266 "net-update": {"type": "null"},
267 "net-edit": {
268 "type":"object",
269 "properties":{
270 "net": name_schema, #name or uuid of net to change
271 "name": name_schema,
272 "description": description_schema,
273 "shared": boolean_schema
274 },
275 "minProperties": 1,
276 "additionalProperties": False
277 },
278 "net-delete":{
279 "type":"object",
280 "properties":{
281 "net": name_schema, #name or uuid of net to change
282 },
283 "required": ["net"],
284 "additionalProperties": False
285 },
286 },
287 "minProperties": 1,
288 "maxProperties": 1,
289 "additionalProperties": False
290 }
291
292
293 datacenter_associate_schema={
294 "title":"datacenter associate information schema",
295 "$schema": "http://json-schema.org/draft-04/schema#",
296 "type":"object",
297 "properties":{
298 "datacenter":{
299 "type": "object",
300 "properties": {
301 "name": name_schema,
302 "vim_id": id_schema,
303 "vim_tenant": name_schema,
304 "vim_tenant_name": name_schema,
305 "vim_username": nameshort_schema,
306 "vim_password": nameshort_schema,
307 "config": {"type": "object"}
308 },
309 # "required": ["vim_tenant"],
310 "additionalProperties": True
311 }
312 },
313 "required": ["datacenter"],
314 "additionalProperties": False
315 }
316
317 dhcp_schema = {
318 "title": "DHCP schema",
319 "$schema": "http://json-schema.org/draft-04/schema#",
320 "type": "object",
321 "properties":{
322 "enabled": boolean_schema,
323 "start-address": {"oneOf": [null_schema, ip_schema]},
324 "count": integer0_schema
325 },
326 # "required": ["start-address", "count"],
327 }
328
329 ip_profile_schema = {
330 "title": "IP profile schema",
331 "$schema": "http://json-schema.org/draft-04/schema#",
332 "type": "object",
333 "properties": {
334 "ip-version": {"type": "string", "enum": ["IPv4", "IPv6"]},
335 "subnet-address": ip_prefix_schema,
336 "gateway-address": ip_schema,
337 "dns-address": {"oneOf": [ip_schema, # for backward compatibility
338 {"type": "array", "items": ip_schema}]},
339 "dhcp": dhcp_schema
340 },
341 }
342
343 key_pair_schema = {
344 "title": "Key-pair schema for cloud-init configuration schema",
345 "$schema": "http://json-schema.org/draft-04/schema#",
346 "type":"object",
347 "properties":{
348 "name": name_schema,
349 "key": {"type":"string"}
350 },
351 "required": ["key"],
352 "additionalProperties": False
353 }
354
355 cloud_config_user_schema = {
356 "title": "User schema for cloud-init configuration schema",
357 "$schema": "http://json-schema.org/draft-04/schema#",
358 "type":"object",
359 "properties":{
360 "name": nameshort_schema,
361 "user-info": {"type":"string"},
362 #"key-pairs": {"type" : "array", "items": key_pair_schema}
363 "key-pairs": {"type" : "array", "items": {"type":"string"}}
364 },
365 "required": ["name"],
366 "additionalProperties": False
367 }
368
369 cloud_config_schema = {
370 "title": "Cloud-init configuration schema",
371 "$schema": "http://json-schema.org/draft-04/schema#",
372 "type":"object",
373 "properties":{
374 #"key-pairs": {"type" : "array", "items": key_pair_schema},
375 "key-pairs": {"type" : "array", "items": {"type":"string"}},
376 "users": {"type" : "array", "items": cloud_config_user_schema}
377 },
378 "additionalProperties": False
379 }
380
381 internal_connection_element_schema = {
382 "type":"object",
383 "properties":{
384 "VNFC": name_schema,
385 "local_iface_name": name_schema
386 }
387 }
388
389 internal_connection_element_schema_v02 = {
390 "type":"object",
391 "properties":{
392 "VNFC": name_schema,
393 "local_iface_name": name_schema,
394 "ip_address": ip_schema
395 }
396 }
397
398 internal_connection_schema = {
399 "type":"object",
400 "properties":{
401 "name": name_schema,
402 "description":description_schema,
403 "type":{"type":"string", "enum":["bridge","data","ptp"]},
404 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":1}
405 },
406 "required": ["name", "type", "elements"],
407 "additionalProperties": False
408 }
409
410 internal_connection_schema_v02 = {
411 "type":"object",
412 "properties":{
413 "name": name_schema,
414 "description":description_schema,
415 "type": {"type": "string", "enum":["e-line", "e-lan"]},
416 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
417 "ip-profile": ip_profile_schema,
418 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":1}
419 },
420 "required": ["name", "type", "implementation", "elements"],
421 "additionalProperties": False
422 }
423
424 external_connection_schema = {
425 "type":"object",
426 "properties":{
427 "name": name_schema,
428 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
429 "VNFC": name_schema,
430 "local_iface_name": name_schema ,
431 "description":description_schema
432 },
433 "required": ["name", "type", "VNFC", "local_iface_name"],
434 "additionalProperties": False
435 }
436
437 #Not yet used
438 external_connection_schema_v02 = {
439 "type":"object",
440 "properties":{
441 "name": name_schema,
442 "mgmt": boolean_schema,
443 "type": {"type": "string", "enum":["e-line", "e-lan"]},
444 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
445 "VNFC": name_schema,
446 "local_iface_name": name_schema ,
447 "description":description_schema
448 },
449 "required": ["name", "type", "VNFC", "local_iface_name"],
450 "additionalProperties": False
451 }
452
453 interfaces_schema={
454 "type":"array",
455 "items":{
456 "type":"object",
457 "properties":{
458 "name":name_schema,
459 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
460 "bandwidth":bandwidth_schema,
461 "vpci":pci_schema,
462 "mac_address": mac_schema
463 },
464 "additionalProperties": False,
465 "required": ["name","dedicated", "bandwidth"]
466 }
467 }
468
469 bridge_interfaces_schema={
470 "type":"array",
471 "items":{
472 "type":"object",
473 "properties":{
474 "name": name_schema,
475 "bandwidth":bandwidth_schema,
476 "vpci":pci_schema,
477 "mac_address": mac_schema,
478 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139", "paravirt"]},
479 "port-security": boolean_schema,
480 "floating-ip": boolean_schema,
481 },
482 "additionalProperties": False,
483 "required": ["name"]
484 }
485 }
486
487 devices_schema={
488 "type":"array",
489 "items":{
490 "type":"object",
491 "properties":{
492 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
493 "image": path_schema,
494 "image name": name_schema,
495 "image checksum": checksum_schema,
496 "image metadata": metadata_schema,
497 "size": size_schema,
498 "vpci":pci_schema,
499 "xml":xml_text_schema,
500 "name": name_schema,
501 },
502 "additionalProperties": False,
503 "required": ["type"]
504 }
505 }
506
507
508 numa_schema = {
509 "type": "object",
510 "properties": {
511 "memory":integer1_schema,
512 "cores":integer1_schema,
513 "paired-threads":integer1_schema,
514 "threads":integer1_schema,
515 "cores-id":{"type":"array","items":integer0_schema},
516 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
517 "threads-id":{"type":"array","items":integer0_schema},
518 "interfaces":interfaces_schema
519 },
520 "additionalProperties": False,
521 #"required": ["memory"]
522 }
523
524 config_files_schema = {
525 "title": "Config files for cloud init schema",
526 "$schema": "http://json-schema.org/draft-04/schema#",
527 "type": "object",
528 "properties": {
529 "dest": path_schema,
530 "encoding": {"type": "string", "enum": ["b64", "base64", "gz", "gz+b64", "gz+base64", "gzip+b64", "gzip+base64"]}, #by default text
531 "content": {"type": "string"},
532 "permissions": {"type": "string"}, # tiypically octal notation '0644'
533 "owner": {"type": "string"}, # format: owner:group
534
535 },
536 "additionalProperties": False,
537 "required": ["dest", "content"],
538 }
539
540 boot_data_vdu_schema = {
541 "title": "Boot data (Cloud-init) configuration schema",
542 "$schema": "http://json-schema.org/draft-04/schema#",
543 "type": "object",
544 "properties":{
545 "key-pairs": {"type" : "array", "items": {"type":"string"}},
546 "users": {"type" : "array", "items": cloud_config_user_schema},
547 "user-data": {"type" : "string"}, # scrip to run
548 "config-files": {"type": "array", "items": config_files_schema},
549 # NOTE: “user-data” are mutually exclusive with users and config-files because user/files are injected using user-data
550 "boot-data-drive": boolean_schema,
551 },
552 "additionalProperties": False,
553 }
554
555 vnfc_schema = {
556 "type":"object",
557 "properties":{
558 "name": name_schema,
559 "description": description_schema,
560 "count": integer1_schema,
561 "image name": name_schema,
562 "availability_zone": name_schema,
563 "VNFC image": {"oneOf": [path_schema, http_schema]},
564 "image checksum": checksum_schema,
565 "image metadata": metadata_schema,
566 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
567 "processor": {
568 "type":"object",
569 "properties":{
570 "model":description_schema,
571 "features":{"type":"array","items":nameshort_schema}
572 },
573 "required": ["model"],
574 "additionalProperties": False
575 },
576 "hypervisor": {
577 "type":"object",
578 "properties":{
579 "type":nameshort_schema,
580 "version":description_schema
581 },
582 },
583 "ram":integer0_schema,
584 "vcpus":integer0_schema,
585 "disk": integer1_schema,
586 "numas": {
587 "type": "array",
588 "items": numa_schema
589 },
590 "bridge-ifaces": bridge_interfaces_schema,
591 "devices": devices_schema,
592 "boot-data" : boot_data_vdu_schema
593
594 },
595 "required": ["name"],
596 "oneOf": [
597 {"required": ["VNFC image"]},
598 {"required": ["image name"]}
599 ],
600 "additionalProperties": False
601 }
602
603 vnfd_schema_v01 = {
604 "title":"vnfd information schema v0.1",
605 "$schema": "http://json-schema.org/draft-04/schema#",
606 "type":"object",
607 "properties":{
608 "vnf":{
609 "type":"object",
610 "properties":{
611 "name": name_schema,
612 "description": description_schema,
613
614 "class": nameshort_schema,
615 "public": boolean_schema,
616 "physical": boolean_schema,
617 "default_user": name_schema,
618 "tenant_id": id_schema, #only valid for admin
619 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
620 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
621 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
622 },
623 "required": ["name","external-connections"],
624 "additionalProperties": True
625 }
626 },
627 "required": ["vnf"],
628 "additionalProperties": False
629 }
630
631 #VNFD schema for OSM R1
632 vnfd_schema_v02 = {
633 "title":"vnfd information schema v0.2",
634 "$schema": "http://json-schema.org/draft-04/schema#",
635 "type":"object",
636 "properties":{
637 "schema_version": {"type": "string", "enum": ["0.2"]},
638 "vnf":{
639 "type":"object",
640 "properties":{
641 "name": name_schema,
642 "description": description_schema,
643 "class": nameshort_schema,
644 "public": boolean_schema,
645 "physical": boolean_schema,
646 "tenant_id": id_schema, #only valid for admin
647 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
648 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
649 # "cloud-config": cloud_config_schema, #common for all vnfcs
650 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
651 },
652 "required": ["name"],
653 "additionalProperties": True
654 }
655 },
656 "required": ["vnf", "schema_version"],
657 "additionalProperties": False
658 }
659
660 #vnfd_schema = vnfd_schema_v01
661 #{
662 # "title":"vnfd information schema v0.2",
663 # "$schema": "http://json-schema.org/draft-04/schema#",
664 # "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
665 #}
666
667 graph_schema = {
668 "title":"graphical scenario descriptor information schema",
669 "$schema": "http://json-schema.org/draft-04/schema#",
670 "type":"object",
671 "properties":{
672 "x": integer0_schema,
673 "y": integer0_schema,
674 "ifaces": {
675 "type":"object",
676 "properties":{
677 "left": {"type":"array"},
678 "right": {"type":"array"},
679 "bottom": {"type":"array"},
680 }
681 }
682 },
683 "required": ["x","y"]
684 }
685
686 nsd_schema_v01 = {
687 "title":"network scenario descriptor information schema v0.1",
688 "$schema": "http://json-schema.org/draft-04/schema#",
689 "type":"object",
690 "properties":{
691 "name":name_schema,
692 "description": description_schema,
693 "tenant_id": id_schema, #only valid for admin
694 "public": boolean_schema,
695 "topology":{
696 "type":"object",
697 "properties":{
698 "nodes": {
699 "type":"object",
700 "patternProperties":{
701 ".": {
702 "type": "object",
703 "properties":{
704 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
705 "vnf_id": id_schema,
706 "graph": graph_schema,
707 },
708 "patternProperties":{
709 "^(VNF )?model$": {"type": "string"}
710 },
711 "required": ["type"]
712 }
713 }
714 },
715 "connections": {
716 "type":"object",
717 "patternProperties":{
718 ".": {
719 "type": "object",
720 "properties":{
721 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
722 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
723 "graph": graph_schema
724 },
725 "required": ["nodes"]
726 },
727 }
728 }
729 },
730 "required": ["nodes"],
731 "additionalProperties": False
732 }
733 },
734 "required": ["name","topology"],
735 "additionalProperties": False
736 }
737
738 nsd_schema_v02 = {
739 "title":"network scenario descriptor information schema v0.2",
740 "$schema": "http://json-schema.org/draft-04/schema#",
741 "type":"object",
742 "properties":{
743 "schema_version": schema_version_2,
744 "scenario":{
745 "type":"object",
746 "properties":{
747 "name": name_schema,
748 "description": description_schema,
749 "tenant_id": id_schema, #only valid for admin
750 "public": boolean_schema,
751 "vnfs": {
752 "type":"object",
753 "patternProperties":{
754 ".": {
755 "type": "object",
756 "properties":{
757 "vnf_id": id_schema,
758 "graph": graph_schema,
759 "vnf_name": name_schema,
760 },
761 }
762 },
763 "minProperties": 1
764 },
765 "networks": {
766 "type":"object",
767 "patternProperties":{
768 ".": {
769 "type": "object",
770 "properties":{
771 "interfaces":{"type":"array", "minLength":1},
772 "type": {"type": "string", "enum":["dataplane", "bridge"]},
773 "external" : boolean_schema,
774 "graph": graph_schema
775 },
776 "required": ["interfaces"]
777 },
778 }
779 },
780
781 },
782 "required": ["vnfs", "name"],
783 "additionalProperties": False
784 }
785 },
786 "required": ["scenario","schema_version"],
787 "additionalProperties": False
788 }
789
790 #NSD schema for OSM R1
791 nsd_schema_v03 = {
792 "title":"network scenario descriptor information schema v0.3",
793 "$schema": "http://json-schema.org/draft-04/schema#",
794 "type":"object",
795 "properties":{
796 "schema_version": {"type": "string", "enum": ["0.3"]},
797 "scenario":{
798 "type":"object",
799 "properties":{
800 "name": name_schema,
801 "description": description_schema,
802 "tenant_id": id_schema, #only valid for admin
803 "public": boolean_schema,
804 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
805 #"datacenter": name_schema,
806 "vnfs": {
807 "type":"object",
808 "patternProperties":{
809 ".": {
810 "type": "object",
811 "properties":{
812 "vnf_id": id_schema,
813 "graph": graph_schema,
814 "vnf_name": name_schema,
815 #"cloud-config": cloud_config_schema, #particular for a vnf
816 #"datacenter": name_schema,
817 "internal-connections": {
818 "type": "object",
819 "patternProperties": {
820 ".": {
821 "type": "object",
822 "properties": {
823 "ip-profile": ip_profile_schema,
824 "elements": {
825 "type" : "array",
826 "items":{
827 "type":"object",
828 "properties":{
829 "VNFC": name_schema,
830 "local_iface_name": name_schema,
831 "ip_address": ip_schema,
832 },
833 "required": ["VNFC", "local_iface_name"],
834 }
835 }
836 }
837 }
838 }
839 }
840 },
841 }
842 },
843 "minProperties": 1
844 },
845 "networks": {
846 "type":"object",
847 "patternProperties":{
848 ".": {
849 "type": "object",
850 "properties":{
851 "interfaces":{
852 "type":"array",
853 "minLength":1,
854 "items":{
855 "type":"object",
856 "properties":{
857 "vnf": name_schema,
858 "vnf_interface": name_schema,
859 "ip_address": ip_schema
860 },
861 "required": ["vnf", "vnf_interface"],
862 }
863 },
864 "type": {"type": "string", "enum":["e-line", "e-lan"]},
865 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
866 "external" : boolean_schema,
867 "graph": graph_schema,
868 "ip-profile": ip_profile_schema
869 },
870 "required": ["interfaces"]
871 },
872 }
873 },
874
875 },
876 "required": ["vnfs", "networks","name"],
877 "additionalProperties": False
878 }
879 },
880 "required": ["scenario","schema_version"],
881 "additionalProperties": False
882 }
883
884 #scenario_new_schema = {
885 # "title":"new scenario information schema",
886 # "$schema": "http://json-schema.org/draft-04/schema#",
887 # #"oneOf": [nsd_schema_v01, nsd_schema_v02]
888 # "oneOf": [nsd_schema_v01]
889 #}
890
891 scenario_edit_schema = {
892 "title":"edit scenario information schema",
893 "$schema": "http://json-schema.org/draft-04/schema#",
894 "type":"object",
895 "properties":{
896 "name":name_schema,
897 "description": description_schema,
898 "topology":{
899 "type":"object",
900 "properties":{
901 "nodes": {
902 "type":"object",
903 "patternProperties":{
904 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
905 "type":"object",
906 "properties":{
907 "graph":{
908 "type": "object",
909 "properties":{
910 "x": integer0_schema,
911 "y": integer0_schema,
912 "ifaces":{ "type": "object"}
913 }
914 },
915 "description": description_schema,
916 "name": name_schema
917 }
918 }
919 }
920 }
921 },
922 "required": ["nodes"],
923 "additionalProperties": False
924 }
925 },
926 "additionalProperties": False
927 }
928
929 scenario_action_schema = {
930 "title":"scenario action information schema",
931 "$schema": "http://json-schema.org/draft-04/schema#",
932 "type":"object",
933 "properties":{
934 "start":{
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 "deploy":{
944 "type": "object",
945 "properties": {
946 "instance_name":name_schema,
947 "description":description_schema,
948 "datacenter": {"type": "string"}
949 },
950 "required": ["instance_name"]
951 },
952 "reserve":{
953 "type": "object",
954 "properties": {
955 "instance_name":name_schema,
956 "description":description_schema,
957 "datacenter": {"type": "string"}
958 },
959 "required": ["instance_name"]
960 },
961 "verify":{
962 "type": "object",
963 "properties": {
964 "instance_name":name_schema,
965 "description":description_schema,
966 "datacenter": {"type": "string"}
967 },
968 "required": ["instance_name"]
969 }
970 },
971 "minProperties": 1,
972 "maxProperties": 1,
973 "additionalProperties": False
974 }
975
976 instance_scenario_object = {
977 "title": "scenario object used to create an instance not based on any nsd",
978 "$schema": "http://json-schema.org/draft-04/schema#",
979 "type": "object",
980 "properties": {
981 "nets": {
982 "type": "array",
983 "minLength": 1,
984 "items": {
985 "type": "object",
986 "properties": {
987 "name": name_schema,
988 "external": boolean_schema,
989 "type": {"enum": ["bridge", "ptp", "data"]}, # for overlay, underlay E-LINE, underlay E-LAN
990 },
991 "additionalProperties": False,
992 "required": ["name", "external", "type"]
993 }
994 }
995 },
996 "additionalProperties": False,
997 "required": ["nets"]
998 }
999
1000 instance_scenario_create_schema_v01 = {
1001 "title": "instance scenario create information schema v0.1",
1002 "$schema": "http://json-schema.org/draft-04/schema#",
1003 "type": "object",
1004 "properties": {
1005 "schema_version": {"type": "string", "enum": ["0.1"]},
1006 "instance": {
1007 "type": "object",
1008 "properties": {
1009 "mgmt_keys": {"type": "array", "items": {"type":"string"}},
1010 "vduImage": name_schema,
1011 "name": name_schema,
1012 "description":description_schema,
1013 "datacenter": name_schema,
1014 "wim_account": {"oneOf": [boolean_schema, id_schema, null_schema]},
1015 "scenario" : {"oneOff": [name_schema, instance_scenario_object]}, # can be an UUID or name or a dict
1016 "action":{"enum": ["deploy","reserve","verify" ]},
1017 "connect_mgmt_interfaces": {"oneOf": [boolean_schema, {"type":"object"}]},# can be true or a dict with datacenter: net_name
1018 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
1019 "vnfs":{ #mapping from scenario to datacenter
1020 "type": "object",
1021 "patternProperties":{
1022 ".": {
1023 "type": "object",
1024 "properties":{
1025 "name": name_schema, #override vnf name
1026 "datacenter": name_schema,
1027 #"metadata": {"type": "object"},
1028 #"user_data": {"type": "string"}
1029 #"cloud-config": cloud_config_schema, #particular for a vnf
1030 "vdus": {
1031 "type": "object",
1032 "patternProperties": {
1033 ".": {
1034 "type": "object",
1035 "properties": {
1036 "name": name_schema, # overrides vdu name schema
1037 "mgmt_keys": string_list,
1038 "vduImage": name_schema,
1039 "cloud_init": string_list,
1040 "devices": {
1041 "type": "object",
1042 "patternProperties": {
1043 ".": {
1044 "vim_id": name_schema,
1045 }
1046 }
1047 },
1048 "interfaces": {
1049 "type": "object",
1050 "patternProperties": {
1051 ".": {
1052 "ip_address": ip_schema,
1053 "mac_address": mac_schema,
1054 "floating-ip": boolean_schema,
1055 }
1056 }
1057 }
1058 }
1059 }
1060 }
1061 },
1062 "networks": {
1063 "type": "object",
1064 "patternProperties": {
1065 ".": {
1066 "type": "object",
1067 "properties": {
1068 "vim-network-name": name_schema,
1069 "vim-network-id": name_schema,
1070 "ip-profile": ip_profile_schema,
1071 "name": name_schema,
1072 }
1073 }
1074 }
1075 },
1076 }
1077 }
1078 },
1079 },
1080 "networks":{ #mapping from scenario to datacenter
1081 "type": "object",
1082 "patternProperties":{
1083 ".": {
1084 "type": "object",
1085 "properties":{
1086 "interfaces":{
1087 "type":"array",
1088 "minLength":1,
1089 "items":{
1090 "type":"object",
1091 "properties":{
1092 "ip_address": ip_schema,
1093 "datacenter": name_schema,
1094 "vim-network-name": name_schema,
1095 "vim-network-id": name_schema
1096 },
1097 "patternProperties":{
1098 ".": {"type": "string"}
1099 }
1100 }
1101 },
1102 "wim_account": {"oneOf": [boolean_schema, id_schema, null_schema]},
1103 "ip-profile": ip_profile_schema,
1104 "use-network": {
1105 "type": "object",
1106 "properties": {
1107 "instance_scenario_id": id_schema,
1108 # "member_vnf_index": name_schema, # if not null, network inside VNF
1109 "osm_id": name_schema, # sce_network osm_id or name
1110 },
1111 "additionalProperties": False,
1112 "required": ["instance_scenario_id", "osm_id"]
1113 },
1114 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
1115 "sites": {
1116 "type":"array",
1117 "minLength":1,
1118 "items":{
1119 "type":"object",
1120 "properties":{
1121 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
1122 # for other networks openamno creates at VIM
1123 # Use netmap-create to force to create an external scenario network
1124 "netmap-create": {"oneOf":[name_schema,null_schema]}, #datacenter network to use. Null if must be created as an internal net
1125 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
1126 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
1127 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
1128 #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)
1129 "netmap-use": name_schema, #
1130 "vim-network-name": name_schema, #override network name
1131 "vim-network-id": name_schema,
1132 #"ip-profile": ip_profile_schema,
1133 "datacenter": name_schema,
1134 }
1135 }
1136 },
1137 }
1138 }
1139 },
1140 },
1141 },
1142 "additionalProperties": False,
1143 "required": ["name"]
1144 },
1145 },
1146 "required": ["instance"],
1147 "additionalProperties": False
1148 }
1149
1150 instance_scenario_action_schema = {
1151 "title": "instance scenario action information schema",
1152 "$schema": "http://json-schema.org/draft-04/schema#",
1153 "type": "object",
1154 "properties": {
1155 "start": null_schema,
1156 "pause": null_schema,
1157 "resume": null_schema,
1158 "shutoff": null_schema,
1159 "shutdown": null_schema,
1160 "forceOff": null_schema,
1161 "rebuild": null_schema,
1162 "reboot": {
1163 "type": ["object", "null"],
1164 },
1165 "add_public_key": {"type" : "string"},
1166 "user": nameshort_schema,
1167 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1168 "vdu-scaling": {
1169 "type": "array",
1170 "items": {
1171 "type": "object",
1172 "properties": {
1173 "vdu-id": id_schema,
1174 "osm_vdu_id": name_schema,
1175 "member-vnf-index": name_schema,
1176 "count": integer1_schema,
1177 "type": {"enum": ["create", "delete"]},
1178 "cloud_init": string_list,
1179 },
1180 "additionalProperties": False,
1181 "minProperties": 1,
1182 "required": ["type"]
1183 }
1184 },
1185 "vnfs": {"type": "array", "items": {"type": "string"}},
1186 "vms": {"type": "array", "items": {"type": "string"}}
1187 },
1188 "minProperties": 1,
1189 #"maxProperties": 1,
1190 "additionalProperties": False
1191 }
1192
1193 sdn_controller_properties={
1194 "name": name_schema,
1195 "dpid": {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"},
1196 "description": name_schema,
1197 "ip": ip_schema,
1198 "port": port_schema,
1199 "type": nameshort_schema,
1200 "url": name_schema,
1201 "version": {"type": "string", "minLength": 1, "maxLength": 12},
1202 "user": nameshort_schema,
1203 "password": passwd_schema,
1204 "config": object_schema,
1205 }
1206 sdn_controller_schema = {
1207 "title": "sdn controller information schema",
1208 "$schema": "http://json-schema.org/draft-04/schema#",
1209 "type": "object",
1210 "properties":{
1211 "sdn_controller":{
1212 "type": "object",
1213 "properties": sdn_controller_properties,
1214 "required": ["name", 'type'],
1215 "additionalProperties": False
1216 }
1217 },
1218 "required": ["sdn_controller"],
1219 "additionalProperties": False
1220 }
1221
1222 sdn_controller_edit_schema = {
1223 "title": "sdn controller update information schema",
1224 "$schema": "http://json-schema.org/draft-04/schema#",
1225 "type": "object",
1226 "properties": {
1227 "sdn_controller": {
1228 "type": "object",
1229 "properties": sdn_controller_properties,
1230 "additionalProperties": False
1231 }
1232 },
1233 "required": ["sdn_controller"],
1234 "additionalProperties": False
1235 }
1236
1237 sdn_port_mapping_schema = {
1238 "$schema": "http://json-schema.org/draft-04/schema#",
1239 "title":"sdn port mapping information schema",
1240 "type": "object",
1241 "properties": {
1242 "sdn_port_mapping": {
1243 "type": "array",
1244 "items": {
1245 "type": "object",
1246 "properties": {
1247 "compute_node": nameshort_schema,
1248 "ports": {
1249 "type": "array",
1250 "items": {
1251 "type": "object",
1252 "properties": {
1253 "pci": {"oneOf": [null_schema, pci_extended_schema]}, # pci_schema,
1254 "switch_port": nameshort_schema,
1255 "switch_id": nameshort_schema,
1256 "switch_dpid": nameshort_schema,
1257 "switch_mac": mac_schema
1258 },
1259 "required": ["pci"]
1260 }
1261 }
1262 },
1263 "required": ["compute_node", "ports"]
1264 }
1265 }
1266 },
1267 "required": ["sdn_port_mapping"]
1268 }
1269
1270 sdn_external_port_schema = {
1271 "$schema": "http://json-schema.org/draft-04/schema#",
1272 "title":"External port ingformation",
1273 "type": "object",
1274 "properties": {
1275 "port": {"type" : "string", "minLength":1, "maxLength":60},
1276 "vlan": vlan_schema,
1277 "mac": mac_schema
1278 },
1279 "required": ["port"]
1280 }