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