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