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