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