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