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