blob: 5b1b9425b1e5bf78604389cce9dc250d671d13ad [file] [log] [blame]
tierno7edb6752016-03-21 17:37:52 +01001# -*- 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'''
25JSON schemas used by openmano httpserver.py module to parse the different files and messages sent through the API
26'''
montesmoreno0c8def02016-12-22 12:16:23 +000027__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
tierno7edb6752016-03-21 17:37:52 +010028__date__ ="$09-oct-2014 09:09:48$"
29
30#Basis schemas
tierno392f2852016-05-13 12:28:55 +020031patern_name="^[ -~]+$"
tierno7edb6752016-03-21 17:37:52 +010032passwd_schema={"type" : "string", "minLength":1, "maxLength":60}
33nameshort_schema={"type" : "string", "minLength":1, "maxLength":60, "pattern" : "^[^,;()'\"]+$"}
34name_schema={"type" : "string", "minLength":1, "maxLength":255, "pattern" : "^[^,;()'\"]+$"}
35xml_text_schema={"type" : "string", "minLength":1, "maxLength":1000, "pattern" : "^[^']+$"}
36description_schema={"type" : ["string","null"], "maxLength":255, "pattern" : "^[^'\"]+$"}
37id_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}$"
38id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
39pci_schema={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
40http_schema={"type":"string", "pattern":"^https?://[^'\"=]+$"}
41bandwidth_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
42memory_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
43integer0_schema={"type":"integer","minimum":0}
44integer1_schema={"type":"integer","minimum":1}
tierno392f2852016-05-13 12:28:55 +020045path_schema={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
tierno7edb6752016-03-21 17:37:52 +010046vlan_schema={"type":"integer","minimum":1,"maximum":4095}
47vlan1000_schema={"type":"integer","minimum":1000,"maximum":4095}
48mac_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}$"}
garciadeblasfec35df2016-08-25 11:33:57 +020050ip_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]?)$"}
51ip_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])$"}
tierno7edb6752016-03-21 17:37:52 +010052port_schema={"type":"integer","minimum":1,"maximum":65534}
53object_schema={"type":"object"}
tierno392f2852016-05-13 12:28:55 +020054schema_version_2={"type":"integer","minimum":2,"maximum":2}
garciadeblasfec35df2016-08-25 11:33:57 +020055#schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
tiernoae4a8d12016-07-08 12:30:39 +020056log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
garciadeblasb69fa9f2016-09-28 12:04:10 +020057checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"}
montesmoreno0c8def02016-12-22 12:16:23 +000058size_schema={"type":"integer","minimum":1,"maximum":100}
tierno7edb6752016-03-21 17:37:52 +010059
60metadata_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
75config_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,
tiernod29b1d32017-01-25 11:02:52 +010083 "auto_push_VNF_to_VIMs": {"type":"boolean"},
tierno7edb6752016-03-21 17:37:52 +010084 "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 # Next fields will disappear once the MANO API includes appropriate primitives
90 "vim_url": http_schema,
91 "vim_url_admin": http_schema,
92 "vim_name": nameshort_schema,
93 "vim_tenant_name": nameshort_schema,
94 "mano_tenant_name": nameshort_schema,
95 "mano_tenant_id": id_schema,
tierno20fc2a22016-08-19 17:02:35 +020096 "http_console_proxy": {"type":"boolean"},
97 "http_console_host": nameshort_schema,
tierno7edb6752016-03-21 17:37:52 +010098 "http_console_ports": {
99 "type": "array",
100 "items": {"OneOf" : [
101 port_schema,
102 {"type":"object", "properties":{"from": port_schema, "to": port_schema}, "required": ["from","to"]}
103 ]}
104 },
tiernoae4a8d12016-07-08 12:30:39 +0200105 "log_level": log_level_schema,
tierno72f35a52016-07-15 13:18:30 +0200106 "log_socket_level": log_level_schema,
tiernoae4a8d12016-07-08 12:30:39 +0200107 "log_level_db": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200108 "log_level_vim": log_level_schema,
tiernof97fd272016-07-11 14:32:37 +0200109 "log_level_nfvo": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200110 "log_level_http": log_level_schema,
tierno1ae51342017-01-16 12:48:30 +0000111 "log_level_console": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200112 "log_file_db": path_schema,
113 "log_file_vim": path_schema,
114 "log_file_nfvo": path_schema,
115 "log_file_http": path_schema,
tierno1ae51342017-01-16 12:48:30 +0000116 "log_file_console": path_schema,
tierno72f35a52016-07-15 13:18:30 +0200117 "log_socket_host": nameshort_schema,
118 "log_socket_port": port_schema,
tiernof97fd272016-07-11 14:32:37 +0200119 "log_file": path_schema,
tierno7edb6752016-03-21 17:37:52 +0100120 },
121 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
122 "additionalProperties": False
123}
124
125tenant_schema = {
126 "title":"tenant information schema",
127 "$schema": "http://json-schema.org/draft-04/schema#",
128 "type":"object",
129 "properties":{
130 "tenant":{
131 "type":"object",
132 "properties":{
133 "name": nameshort_schema,
134 "description": description_schema,
135 },
136 "required": ["name"],
137 "additionalProperties": True
138 }
139 },
140 "required": ["tenant"],
141 "additionalProperties": False
142}
garciadeblasfec35df2016-08-25 11:33:57 +0200143
tierno7edb6752016-03-21 17:37:52 +0100144tenant_edit_schema = {
145 "title":"tenant edit information schema",
146 "$schema": "http://json-schema.org/draft-04/schema#",
147 "type":"object",
148 "properties":{
149 "tenant":{
150 "type":"object",
151 "properties":{
152 "name": name_schema,
153 "description": description_schema,
154 },
155 "additionalProperties": False
156 }
157 },
158 "required": ["tenant"],
159 "additionalProperties": False
160}
161
162datacenter_schema_properties={
garciadeblasfec35df2016-08-25 11:33:57 +0200163 "name": name_schema,
164 "description": description_schema,
165 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
166 "vim_url": description_schema,
167 "vim_url_admin": description_schema,
168 "config": { "type":"object" }
169}
tierno7edb6752016-03-21 17:37:52 +0100170
171datacenter_schema = {
172 "title":"datacenter information schema",
173 "$schema": "http://json-schema.org/draft-04/schema#",
174 "type":"object",
175 "properties":{
176 "datacenter":{
177 "type":"object",
178 "properties":datacenter_schema_properties,
179 "required": ["name", "vim_url"],
180 "additionalProperties": True
181 }
182 },
183 "required": ["datacenter"],
184 "additionalProperties": False
185}
186
187
188datacenter_edit_schema = {
189 "title":"datacenter edit nformation schema",
190 "$schema": "http://json-schema.org/draft-04/schema#",
191 "type":"object",
192 "properties":{
193 "datacenter":{
194 "type":"object",
195 "properties":datacenter_schema_properties,
196 "additionalProperties": False
197 }
198 },
199 "required": ["datacenter"],
200 "additionalProperties": False
201}
202
203
204netmap_new_schema = {
205 "title":"netmap new information schema",
206 "$schema": "http://json-schema.org/draft-04/schema#",
207 "type":"object",
208 "properties":{
209 "netmap":{ #delete from datacenter
210 "type":"object",
211 "properties":{
212 "name": name_schema, #name or uuid of net to change
213 "vim_id": id_schema,
214 "vim_name": name_schema
215 },
216 "minProperties": 1,
217 "additionalProperties": False
218 },
219 },
220 "required": ["netmap"],
221 "additionalProperties": False
222}
223
224netmap_edit_schema = {
225 "title":"netmap edit information schema",
226 "$schema": "http://json-schema.org/draft-04/schema#",
227 "type":"object",
228 "properties":{
229 "netmap":{ #delete from datacenter
230 "type":"object",
231 "properties":{
232 "name": name_schema, #name or uuid of net to change
233 },
234 "minProperties": 1,
235 "additionalProperties": False
236 },
237 },
238 "required": ["netmap"],
239 "additionalProperties": False
240}
241
242datacenter_action_schema = {
243 "title":"datacenter action information schema",
244 "$schema": "http://json-schema.org/draft-04/schema#",
245 "type":"object",
246 "properties":{
247 "net-update":{"type":"null",},
248 "net-edit":{
249 "type":"object",
250 "properties":{
251 "net": name_schema, #name or uuid of net to change
252 "name": name_schema,
253 "description": description_schema,
254 "shared": {"type": "boolean"}
255 },
256 "minProperties": 1,
257 "additionalProperties": False
258 },
259 "net-delete":{
260 "type":"object",
261 "properties":{
262 "net": name_schema, #name or uuid of net to change
263 },
264 "required": ["net"],
265 "additionalProperties": False
266 },
267 },
268 "minProperties": 1,
269 "maxProperties": 1,
270 "additionalProperties": False
271}
272
273
274datacenter_associate_schema={
275 "title":"datacenter associate information schema",
276 "$schema": "http://json-schema.org/draft-04/schema#",
277 "type":"object",
278 "properties":{
279 "datacenter":{
280 "type":"object",
281 "properties":{
tierno8008c3a2016-10-13 15:34:28 +0000282 "vim_tenant": name_schema,
283 "vim_tenant_name": name_schema,
tierno7edb6752016-03-21 17:37:52 +0100284 "vim_username": nameshort_schema,
285 "vim_password": nameshort_schema,
tierno8008c3a2016-10-13 15:34:28 +0000286 "config": {"type": "object"}
tierno7edb6752016-03-21 17:37:52 +0100287 },
288# "required": ["vim_tenant"],
289 "additionalProperties": True
290 }
291 },
292 "required": ["datacenter"],
293 "additionalProperties": False
294}
295
garciadeblasfec35df2016-08-25 11:33:57 +0200296dhcp_schema = {
297 "title":"DHCP schema",
298 "$schema": "http://json-schema.org/draft-04/schema#",
299 "type":"object",
300 "properties":{
301 "enabled": {"type": "boolean"},
302 "start-address": ip_schema,
303 "count": integer1_schema
garciadeblas9f8456e2016-09-05 05:02:59 +0200304 },
305 "required": ["enabled", "start-address", "count"],
garciadeblasfec35df2016-08-25 11:33:57 +0200306}
307
308ip_profile_schema = {
309 "title":"IP profile schema",
310 "$schema": "http://json-schema.org/draft-04/schema#",
311 "type":"object",
312 "properties":{
313 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
314 "subnet-address": ip_prefix_schema,
315 "gateway-address": ip_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200316 "dns-address": ip_schema,
317 "dhcp": dhcp_schema
318 },
319}
320
321key_pair_schema = {
322 "title": "Key-pair schema for cloud-init configuration schema",
323 "$schema": "http://json-schema.org/draft-04/schema#",
324 "type":"object",
325 "properties":{
326 "name": name_schema,
327 "key": {"type":"string"}
328 },
329 "required": ["key"],
330 "additionalProperties": False
331}
332
333cloud_config_user_schema = {
334 "title": "User schema for cloud-init configuration schema",
335 "$schema": "http://json-schema.org/draft-04/schema#",
336 "type":"object",
337 "properties":{
338 "name": nameshort_schema,
339 "user-info": {"type":"string"},
340 #"key-pairs": {"type" : "array", "items": key_pair_schema}
341 "key-pairs": {"type" : "array", "items": {"type":"string"}}
342 },
343 "required": ["name"],
344 "additionalProperties": False
345}
346
347cloud_config_schema = {
348 "title": "Cloud-init configuration schema",
349 "$schema": "http://json-schema.org/draft-04/schema#",
350 "type":"object",
351 "properties":{
352 #"key-pairs": {"type" : "array", "items": key_pair_schema},
353 "key-pairs": {"type" : "array", "items": {"type":"string"}},
354 "users": {"type" : "array", "items": cloud_config_user_schema}
355 },
356 "additionalProperties": False
357}
358
tierno7edb6752016-03-21 17:37:52 +0100359internal_connection_element_schema = {
360 "type":"object",
361 "properties":{
362 "VNFC": name_schema,
363 "local_iface_name": name_schema
364 }
365}
366
garciadeblasfec35df2016-08-25 11:33:57 +0200367internal_connection_element_schema_v02 = {
368 "type":"object",
369 "properties":{
370 "VNFC": name_schema,
371 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200372 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200373 }
374}
375
tierno7edb6752016-03-21 17:37:52 +0100376internal_connection_schema = {
377 "type":"object",
378 "properties":{
379 "name": name_schema,
380 "description":description_schema,
381 "type":{"type":"string", "enum":["bridge","data","ptp"]},
382 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
383 },
384 "required": ["name", "type", "elements"],
385 "additionalProperties": False
386}
387
garciadeblasfec35df2016-08-25 11:33:57 +0200388internal_connection_schema_v02 = {
389 "type":"object",
390 "properties":{
391 "name": name_schema,
392 "description":description_schema,
393 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200394 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200395 "ip-profile": ip_profile_schema,
396 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":2}
397 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200398 "required": ["name", "type", "implementation", "elements"],
garciadeblasfec35df2016-08-25 11:33:57 +0200399 "additionalProperties": False
400}
401
tierno7edb6752016-03-21 17:37:52 +0100402external_connection_schema = {
403 "type":"object",
404 "properties":{
405 "name": name_schema,
406 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
407 "VNFC": name_schema,
408 "local_iface_name": name_schema ,
409 "description":description_schema
410 },
411 "required": ["name", "type", "VNFC", "local_iface_name"],
412 "additionalProperties": False
413}
414
garciadeblas9f8456e2016-09-05 05:02:59 +0200415#Not yet used
garciadeblasfec35df2016-08-25 11:33:57 +0200416external_connection_schema_v02 = {
417 "type":"object",
418 "properties":{
419 "name": name_schema,
garciadeblas9f8456e2016-09-05 05:02:59 +0200420 "mgmt": {"type":"boolean"},
421 "type": {"type": "string", "enum":["e-line", "e-lan"]},
422 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200423 "VNFC": name_schema,
424 "local_iface_name": name_schema ,
425 "description":description_schema
426 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200427 "required": ["name", "type", "VNFC", "local_iface_name"],
garciadeblasfec35df2016-08-25 11:33:57 +0200428 "additionalProperties": False
429}
430
tierno7edb6752016-03-21 17:37:52 +0100431interfaces_schema={
432 "type":"array",
433 "items":{
434 "type":"object",
435 "properties":{
436 "name":name_schema,
437 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
438 "bandwidth":bandwidth_schema,
439 "vpci":pci_schema,
440 "mac_address": mac_schema
441 },
442 "additionalProperties": False,
443 "required": ["name","dedicated", "bandwidth"]
444 }
445}
446
447bridge_interfaces_schema={
448 "type":"array",
449 "items":{
450 "type":"object",
451 "properties":{
452 "name": name_schema,
453 "bandwidth":bandwidth_schema,
454 "vpci":pci_schema,
455 "mac_address": mac_schema,
montesmoreno2a1fc4e2017-01-09 16:46:04 +0000456 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]},
457 "port-security": {"type" : "boolean"},
458 "floating-ip": {"type" : "boolean"}
tierno7edb6752016-03-21 17:37:52 +0100459 },
460 "additionalProperties": False,
461 "required": ["name"]
462 }
463}
464
465devices_schema={
466 "type":"array",
467 "items":{
468 "type":"object",
469 "properties":{
470 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
471 "image": path_schema,
garciadeblasb69fa9f2016-09-28 12:04:10 +0200472 "image name": name_schema,
473 "image checksum": checksum_schema,
montesmoreno0c8def02016-12-22 12:16:23 +0000474 "image metadata": metadata_schema,
475 "size": size_schema,
tierno7edb6752016-03-21 17:37:52 +0100476 "vpci":pci_schema,
477 "xml":xml_text_schema,
478 },
479 "additionalProperties": False,
480 "required": ["type"]
481 }
482}
483
484
485numa_schema = {
486 "type": "object",
487 "properties": {
488 "memory":integer1_schema,
489 "cores":integer1_schema,
490 "paired-threads":integer1_schema,
491 "threads":integer1_schema,
492 "cores-id":{"type":"array","items":integer0_schema},
493 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
494 "threads-id":{"type":"array","items":integer0_schema},
495 "interfaces":interfaces_schema
496 },
497 "additionalProperties": False,
498 #"required": ["memory"]
499}
500
tierno36c0b172017-01-12 18:32:28 +0100501config_files_schema = {
502 "title": "Config files for cloud init schema",
503 "$schema": "http://json-schema.org/draft-04/schema#",
504 "type": "object",
505 "properties": {
506 "dest": path_schema,
507 "encoding": {"type": "string", "enum": ["b64", "base64", "gz", "gz+b64", "gz+base64", "gzip+b64", "gzip+base64"]}, #by default text
508 "content": {"type": "string"},
509 "permissions": {"type": "string"}, # tiypically octal notation '0644'
510 "owner": {"type": "string"}, # format: owner:group
511
512 },
513 "additionalProperties": False,
514 "required": ["dest", "content"],
515}
516
517boot_data_vdu_schema = {
518 "title": "Boot data (Cloud-init) configuration schema",
519 "$schema": "http://json-schema.org/draft-04/schema#",
520 "type": "object",
521 "properties":{
522 "key-pairs": {"type" : "array", "items": {"type":"string"}},
523 "users": {"type" : "array", "items": cloud_config_user_schema},
524 "user-data": {"type" : "string"}, # scrip to run
525 "config-files": {"type": "array", "items": config_files_schema},
526 # NOTE: “user-data” are mutually exclusive with users and config-files because user/files are injected using user-data
527 "boot-data-drive": {"type": "boolean"},
528 },
529 "additionalProperties": False,
530}
531
tierno7edb6752016-03-21 17:37:52 +0100532vnfc_schema = {
533 "type":"object",
534 "properties":{
535 "name": name_schema,
536 "description": description_schema,
537 "VNFC image": {"oneOf": [path_schema, http_schema]},
garciadeblasb69fa9f2016-09-28 12:04:10 +0200538 "image name": name_schema,
539 "image checksum": checksum_schema,
tierno7edb6752016-03-21 17:37:52 +0100540 "image metadata": metadata_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200541 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
tierno7edb6752016-03-21 17:37:52 +0100542 "processor": {
543 "type":"object",
544 "properties":{
545 "model":description_schema,
546 "features":{"type":"array","items":nameshort_schema}
547 },
548 "required": ["model"],
549 "additionalProperties": False
550 },
551 "hypervisor": {
552 "type":"object",
553 "properties":{
554 "type":nameshort_schema,
555 "version":description_schema
556 },
557 },
558 "ram":integer0_schema,
559 "vcpus":integer0_schema,
560 "disk": integer1_schema,
561 "numas": {
562 "type": "array",
garciadeblasfec35df2016-08-25 11:33:57 +0200563 "items": numa_schema
tierno7edb6752016-03-21 17:37:52 +0100564 },
565 "bridge-ifaces": bridge_interfaces_schema,
tierno36c0b172017-01-12 18:32:28 +0100566 "devices": devices_schema,
567 "boot-data" : boot_data_vdu_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200568
tierno7edb6752016-03-21 17:37:52 +0100569 },
garciadeblasb69fa9f2016-09-28 12:04:10 +0200570 "required": ["name"],
571 "oneOf": [
572 {"required": ["VNFC image"]},
573 {"required": ["image name"]}
574 ],
tierno7edb6752016-03-21 17:37:52 +0100575 "additionalProperties": False
576}
577
578vnfd_schema_v01 = {
579 "title":"vnfd information schema v0.1",
580 "$schema": "http://json-schema.org/draft-04/schema#",
581 "type":"object",
582 "properties":{
583 "vnf":{
584 "type":"object",
585 "properties":{
586 "name": name_schema,
587 "description": description_schema,
588 "class": nameshort_schema,
589 "public": {"type" : "boolean"},
590 "physical": {"type" : "boolean"},
591 "tenant_id": id_schema, #only valid for admin
592 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
593 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
594 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
595 },
596 "required": ["name","external-connections"],
597 "additionalProperties": True
598 }
599 },
600 "required": ["vnf"],
601 "additionalProperties": False
602}
603
garciadeblasfec35df2016-08-25 11:33:57 +0200604#VNFD schema for OSM R1
tierno7edb6752016-03-21 17:37:52 +0100605vnfd_schema_v02 = {
606 "title":"vnfd information schema v0.2",
607 "$schema": "http://json-schema.org/draft-04/schema#",
608 "type":"object",
609 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200610 "schema_version": {"type": "string", "enum": ["0.2"]},
tierno7edb6752016-03-21 17:37:52 +0100611 "vnf":{
612 "type":"object",
613 "properties":{
614 "name": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200615 "description": description_schema,
616 "class": nameshort_schema,
617 "public": {"type" : "boolean"},
618 "physical": {"type" : "boolean"},
619 "tenant_id": id_schema, #only valid for admin
garciadeblas9f8456e2016-09-05 05:02:59 +0200620 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
garciadeblasfec35df2016-08-25 11:33:57 +0200621 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
622 # "cloud-config": cloud_config_schema, #common for all vnfcs
623 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
tierno7edb6752016-03-21 17:37:52 +0100624 },
625 "required": ["name"],
626 "additionalProperties": True
627 }
628 },
tierno392f2852016-05-13 12:28:55 +0200629 "required": ["vnf", "schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100630 "additionalProperties": False
631}
632
633#vnfd_schema = vnfd_schema_v01
634#{
635# "title":"vnfd information schema v0.2",
636# "$schema": "http://json-schema.org/draft-04/schema#",
637# "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
638#}
639
640graph_schema = {
641 "title":"graphical scenario descriptor information schema",
642 "$schema": "http://json-schema.org/draft-04/schema#",
643 "type":"object",
644 "properties":{
645 "x": integer0_schema,
646 "y": integer0_schema,
647 "ifaces": {
648 "type":"object",
649 "properties":{
650 "left": {"type":"array"},
651 "right": {"type":"array"},
652 "bottom": {"type":"array"},
653 }
654 }
655 },
656 "required": ["x","y"]
657}
658
659nsd_schema_v01 = {
660 "title":"network scenario descriptor information schema v0.1",
661 "$schema": "http://json-schema.org/draft-04/schema#",
662 "type":"object",
663 "properties":{
664 "name":name_schema,
665 "description": description_schema,
666 "tenant_id": id_schema, #only valid for admin
tierno392f2852016-05-13 12:28:55 +0200667 "public": {"type": "boolean"},
tierno7edb6752016-03-21 17:37:52 +0100668 "topology":{
669 "type":"object",
670 "properties":{
671 "nodes": {
672 "type":"object",
673 "patternProperties":{
674 ".": {
675 "type": "object",
676 "properties":{
677 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
678 "vnf_id": id_schema,
679 "graph": graph_schema,
680 },
681 "patternProperties":{
682 "^(VNF )?model$": {"type": "string"}
683 },
684 "required": ["type"]
685 }
686 }
687 },
688 "connections": {
689 "type":"object",
690 "patternProperties":{
691 ".": {
692 "type": "object",
693 "properties":{
694 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
695 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
696 "graph": graph_schema
697 },
698 "required": ["nodes"]
699 },
700 }
701 }
702 },
703 "required": ["nodes"],
704 "additionalProperties": False
705 }
706 },
707 "required": ["name","topology"],
708 "additionalProperties": False
709}
710
tierno7edb6752016-03-21 17:37:52 +0100711nsd_schema_v02 = {
712 "title":"network scenario descriptor information schema v0.2",
713 "$schema": "http://json-schema.org/draft-04/schema#",
714 "type":"object",
715 "properties":{
garciadeblas0c317ee2016-08-29 12:33:06 +0200716 "schema_version": schema_version_2,
tierno392f2852016-05-13 12:28:55 +0200717 "scenario":{
tierno7edb6752016-03-21 17:37:52 +0100718 "type":"object",
tierno392f2852016-05-13 12:28:55 +0200719 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200720 "name": name_schema,
tierno392f2852016-05-13 12:28:55 +0200721 "description": description_schema,
722 "tenant_id": id_schema, #only valid for admin
723 "public": {"type": "boolean"},
724 "vnfs": {
725 "type":"object",
726 "patternProperties":{
727 ".": {
728 "type": "object",
729 "properties":{
730 "vnf_id": id_schema,
731 "graph": graph_schema,
732 "vnf_name": name_schema,
733 },
734 }
tierno7edb6752016-03-21 17:37:52 +0100735 },
tierno392f2852016-05-13 12:28:55 +0200736 "minProperties": 1
tierno7edb6752016-03-21 17:37:52 +0100737 },
tierno392f2852016-05-13 12:28:55 +0200738 "networks": {
739 "type":"object",
740 "patternProperties":{
741 ".": {
742 "type": "object",
743 "properties":{
744 "interfaces":{"type":"array", "minLength":1},
745 "type": {"type": "string", "enum":["dataplane", "bridge"]},
746 "external" : {"type": "boolean"},
747 "graph": graph_schema
748 },
749 "required": ["interfaces"]
750 },
751 }
752 },
753
754 },
garciadeblasfec35df2016-08-25 11:33:57 +0200755 "required": ["vnfs", "name"],
756 "additionalProperties": False
757 }
758 },
759 "required": ["scenario","schema_version"],
760 "additionalProperties": False
761}
762
763#NSD schema for OSM R1
764nsd_schema_v03 = {
765 "title":"network scenario descriptor information schema v0.3",
766 "$schema": "http://json-schema.org/draft-04/schema#",
767 "type":"object",
768 "properties":{
769 "schema_version": {"type": "string", "enum": ["0.3"]},
770 "scenario":{
771 "type":"object",
772 "properties":{
773 "name": name_schema,
774 "description": description_schema,
775 "tenant_id": id_schema, #only valid for admin
776 "public": {"type": "boolean"},
777 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
garciadeblas0c317ee2016-08-29 12:33:06 +0200778 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200779 "vnfs": {
780 "type":"object",
781 "patternProperties":{
782 ".": {
783 "type": "object",
784 "properties":{
785 "vnf_id": id_schema,
786 "graph": graph_schema,
787 "vnf_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200788 #"cloud-config": cloud_config_schema, #particular for a vnf
789 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200790 "internal-connections": {
791 "type": "object",
792 "patternProperties": {
793 ".": {
794 "type": "object",
795 "properties": {
796 "ip-profile": ip_profile_schema,
797 "elements": {
798 "type" : "array",
799 "items":{
800 "type":"object",
801 "properties":{
802 "VNFC": name_schema,
803 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200804 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200805 },
806 "required": ["VNFC", "local_iface_name"],
807 }
808 }
809 }
810 }
811 }
812 }
813 },
814 }
815 },
816 "minProperties": 1
817 },
818 "networks": {
819 "type":"object",
820 "patternProperties":{
821 ".": {
822 "type": "object",
823 "properties":{
824 "interfaces":{
825 "type":"array",
826 "minLength":1,
827 "items":{
828 "type":"object",
829 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200830 "vnf": name_schema,
831 "vnf_interface": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200832 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200833 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200834 "required": ["vnf", "vnf_interface"],
garciadeblasfec35df2016-08-25 11:33:57 +0200835 }
836 },
837 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200838 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200839 "external" : {"type": "boolean"},
840 "graph": graph_schema,
841 "ip-profile": ip_profile_schema
842 },
843 "required": ["interfaces"]
844 },
845 }
846 },
847
848 },
tierno392f2852016-05-13 12:28:55 +0200849 "required": ["vnfs", "networks","name"],
850 "additionalProperties": False
851 }
tierno7edb6752016-03-21 17:37:52 +0100852 },
tierno392f2852016-05-13 12:28:55 +0200853 "required": ["scenario","schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100854 "additionalProperties": False
855}
856
857#scenario_new_schema = {
858# "title":"new scenario information schema",
859# "$schema": "http://json-schema.org/draft-04/schema#",
860# #"oneOf": [nsd_schema_v01, nsd_schema_v02]
861# "oneOf": [nsd_schema_v01]
862#}
863
864scenario_edit_schema = {
865 "title":"edit scenario information schema",
866 "$schema": "http://json-schema.org/draft-04/schema#",
867 "type":"object",
868 "properties":{
869 "name":name_schema,
870 "description": description_schema,
871 "topology":{
872 "type":"object",
873 "properties":{
874 "nodes": {
875 "type":"object",
876 "patternProperties":{
877 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
878 "type":"object",
879 "properties":{
880 "graph":{
881 "type": "object",
882 "properties":{
883 "x": integer0_schema,
884 "y": integer0_schema,
885 "ifaces":{ "type": "object"}
886 }
887 },
888 "description": description_schema,
889 "name": name_schema
890 }
891 }
892 }
893 }
894 },
895 "required": ["nodes"],
896 "additionalProperties": False
897 }
898 },
899 "additionalProperties": False
900}
901
902scenario_action_schema = {
903 "title":"scenario action information schema",
904 "$schema": "http://json-schema.org/draft-04/schema#",
905 "type":"object",
906 "properties":{
907 "start":{
908 "type": "object",
909 "properties": {
910 "instance_name":name_schema,
911 "description":description_schema,
912 "datacenter": {"type": "string"}
913 },
914 "required": ["instance_name"]
915 },
916 "deploy":{
917 "type": "object",
918 "properties": {
919 "instance_name":name_schema,
920 "description":description_schema,
921 "datacenter": {"type": "string"}
922 },
923 "required": ["instance_name"]
924 },
925 "reserve":{
926 "type": "object",
927 "properties": {
928 "instance_name":name_schema,
929 "description":description_schema,
930 "datacenter": {"type": "string"}
931 },
932 "required": ["instance_name"]
933 },
934 "verify":{
935 "type": "object",
936 "properties": {
937 "instance_name":name_schema,
938 "description":description_schema,
939 "datacenter": {"type": "string"}
940 },
941 "required": ["instance_name"]
942 }
943 },
944 "minProperties": 1,
945 "maxProperties": 1,
946 "additionalProperties": False
947}
948
garciadeblasfec35df2016-08-25 11:33:57 +0200949instance_scenario_create_schema_v01 = {
tierno7edb6752016-03-21 17:37:52 +0100950 "title":"instance scenario create information schema v0.1",
951 "$schema": "http://json-schema.org/draft-04/schema#",
952 "type":"object",
953 "properties":{
954 "schema_version": {"type": "string", "enum": ["0.1"]},
955 "instance":{
956 "type":"object",
957 "properties":{
958 "name":name_schema,
959 "description":description_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200960 "datacenter": name_schema,
961 "scenario" : name_schema, #can be an UUID or name
tierno7edb6752016-03-21 17:37:52 +0100962 "action":{"enum": ["deploy","reserve","verify" ]},
garciadeblasfec35df2016-08-25 11:33:57 +0200963 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
964 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
tierno7edb6752016-03-21 17:37:52 +0100965 "vnfs":{ #mapping from scenario to datacenter
966 "type": "object",
967 "patternProperties":{
968 ".": {
969 "type": "object",
970 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200971 "name": name_schema, #override vnf name
garciadeblas0c317ee2016-08-29 12:33:06 +0200972 "datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200973 #"metadata": {"type": "object"},
974 #"user_data": {"type": "string"}
garciadeblas0c317ee2016-08-29 12:33:06 +0200975 #"cloud-config": cloud_config_schema, #particular for a vnf
garciadeblasfec35df2016-08-25 11:33:57 +0200976 "external-connections": {
977 "type": "object",
978 "patternProperties": {
979 ".": {
980 "type": "object",
981 "properties": {
982 "vim-network-name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200983 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200984 }
985 }
986 }
987 },
988 "internal-connections": {
989 "type": "object",
990 "patternProperties": {
991 ".": {
992 "type": "object",
993 "properties": {
994 "ip-profile": ip_profile_schema,
995 "elements": {
996 "type" : "array",
997 "items":{
998 "type":"object",
999 "properties":{
1000 "VNFC": name_schema,
1001 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +02001002 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +02001003 },
1004 "required": ["VNFC", "local_iface_name"],
1005 }
1006 }
1007 }
1008 }
1009 }
1010 }
tierno7edb6752016-03-21 17:37:52 +01001011 }
1012 }
1013 },
1014 },
1015 "networks":{ #mapping from scenario to datacenter
1016 "type": "object",
1017 "patternProperties":{
1018 ".": {
1019 "type": "object",
1020 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +02001021 "interfaces":{
1022 "type":"array",
1023 "minLength":1,
1024 "items":{
1025 "type":"object",
1026 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +02001027 "ip_address": ip_schema,
1028 "datacenter": name_schema,
1029 "vim-network-name": name_schema
garciadeblasfec35df2016-08-25 11:33:57 +02001030 },
1031 "patternProperties":{
1032 ".": {"type": "string"}
1033 }
1034 }
1035 },
garciadeblasfec35df2016-08-25 11:33:57 +02001036 "ip-profile": ip_profile_schema,
tiernobe41e222016-09-02 15:16:13 +02001037 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
1038 "sites": {
1039 "type":"array",
1040 "minLength":1,
1041 "items":{
1042 "type":"object",
1043 "properties":{
1044 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
1045 # for other networks openamno creates at VIM
1046 # Use netmap-create to force to create an external scenario network
1047 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
1048 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
1049 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
1050 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
1051 #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)
1052 "netmap-use": name_schema, #
1053 "vim-network-name": name_schema, #override network name
1054 #"ip-profile": ip_profile_schema,
1055 "datacenter": name_schema,
1056 }
1057 }
1058 },
1059
1060
1061
tierno7edb6752016-03-21 17:37:52 +01001062 }
1063 }
1064 },
1065 },
1066 },
1067 "additionalProperties": False,
garciadeblasfec35df2016-08-25 11:33:57 +02001068 "required": ["name"]
tierno7edb6752016-03-21 17:37:52 +01001069 },
1070 },
1071 "required": ["instance"],
1072 "additionalProperties": False
tierno7edb6752016-03-21 17:37:52 +01001073}
1074
1075instance_scenario_action_schema = {
1076 "title":"instance scenario action information schema",
1077 "$schema": "http://json-schema.org/draft-04/schema#",
1078 "type":"object",
1079 "properties":{
1080 "start":{"type": "null"},
1081 "pause":{"type": "null"},
1082 "resume":{"type": "null"},
1083 "shutoff":{"type": "null"},
1084 "shutdown":{"type": "null"},
1085 "forceOff":{"type": "null"},
1086 "rebuild":{"type": "null"},
1087 "reboot":{
1088 "type": ["object","null"],
1089 },
1090 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1091 "vnfs":{"type": "array", "items":{"type":"string"}},
1092 "vms":{"type": "array", "items":{"type":"string"}}
1093 },
1094 "minProperties": 1,
1095 #"maxProperties": 1,
1096 "additionalProperties": False
1097}
Pablo Montes Moreno3fbff9b2017-03-08 11:28:15 +01001098
1099sdn_controller_properties={
1100 "name": name_schema,
1101 "dpid": {"type":"string", "pattern":"^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){7}$"},
1102 "ip": ip_schema,
1103 "port": port_schema,
1104 "type": {"type": "string", "enum": ["opendaylight","floodlight","onos"]},
1105 "version": {"type" : "string", "minLength":1, "maxLength":12},
1106 "user": nameshort_schema,
1107 "password": passwd_schema
1108}
1109sdn_controller_schema = {
1110 "title":"sdn controller information schema",
1111 "$schema": "http://json-schema.org/draft-04/schema#",
1112 "type":"object",
1113 "properties":{
1114 "sdn_controller":{
1115 "type":"object",
1116 "properties":sdn_controller_properties,
1117 "required": ["name", "port", 'ip', 'dpid', 'type'],
1118 "additionalProperties": False
1119 }
1120 },
1121 "required": ["sdn_controller"],
1122 "additionalProperties": False
1123}
1124
1125sdn_controller_edit_schema = {
1126 "title":"sdn controller update information schema",
1127 "$schema": "http://json-schema.org/draft-04/schema#",
1128 "type":"object",
1129 "properties":{
1130 "sdn_controller":{
1131 "type":"object",
1132 "properties":sdn_controller_properties,
1133 "additionalProperties": False
1134 }
1135 },
1136 "required": ["sdn_controller"],
1137 "additionalProperties": False
1138}
1139
1140sdn_port_mapping_schema = {
1141 "$schema": "http://json-schema.org/draft-04/schema#",
1142 "title":"sdn port mapping information schema",
1143 "type": "object",
1144 "properties": {
1145 "sdn_port_mapping": {
1146 "type": "array",
1147 "items": {
1148 "type": "object",
1149 "properties": {
1150 "compute_node": nameshort_schema,
1151 "ports": {
1152 "type": "array",
1153 "items": {
1154 "type": "object",
1155 "properties": {
1156 "pci": pci_schema,
1157 "switch_port": nameshort_schema,
1158 "switch_mac": mac_schema
1159 },
1160 "required": ["pci"]
1161 }
1162 }
1163 },
1164 "required": ["compute_node", "ports"]
1165 }
1166 }
1167 },
1168 "required": ["sdn_port_mapping"]
1169}