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