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