blob: 14fb6523d1f4045b92d3170bfc9327ccc940feb5 [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
31passwd_schema={"type" : "string", "minLength":1, "maxLength":60}
32nameshort_schema={"type" : "string", "minLength":1, "maxLength":60, "pattern" : "^[^,;()'\"]+$"}
33name_schema={"type" : "string", "minLength":1, "maxLength":255, "pattern" : "^[^,;()'\"]+$"}
34xml_text_schema={"type" : "string", "minLength":1, "maxLength":1000, "pattern" : "^[^']+$"}
35description_schema={"type" : ["string","null"], "maxLength":255, "pattern" : "^[^'\"]+$"}
36id_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}$"
37id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
38pci_schema={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
39http_schema={"type":"string", "pattern":"^https?://[^'\"=]+$"}
40bandwidth_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
41memory_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
42integer0_schema={"type":"integer","minimum":0}
43integer1_schema={"type":"integer","minimum":1}
tierno392f2852016-05-13 12:28:55 +020044path_schema={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
tierno7edb6752016-03-21 17:37:52 +010045vlan_schema={"type":"integer","minimum":1,"maximum":4095}
46vlan1000_schema={"type":"integer","minimum":1000,"maximum":4095}
47mac_schema={"type":"string", "pattern":"^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$"} #must be unicast LSB bit of MSB byte ==0
48#mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
garciadeblasfec35df2016-08-25 11:33:57 +020049ip_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]?)$"}
50ip_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 +010051port_schema={"type":"integer","minimum":1,"maximum":65534}
52object_schema={"type":"object"}
tierno392f2852016-05-13 12:28:55 +020053schema_version_2={"type":"integer","minimum":2,"maximum":2}
garciadeblasfec35df2016-08-25 11:33:57 +020054#schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
tiernoae4a8d12016-07-08 12:30:39 +020055log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
garciadeblasb69fa9f2016-09-28 12:04:10 +020056checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"}
montesmoreno0c8def02016-12-22 12:16:23 +000057size_schema={"type":"integer","minimum":1,"maximum":100}
tierno7edb6752016-03-21 17:37:52 +010058
59metadata_schema={
60 "type":"object",
61 "properties":{
62 "architecture": {"type":"string"},
63 "use_incremental": {"type":"string","enum":["yes","no"]},
64 "vpci": pci_schema,
65 "os_distro": {"type":"string"},
66 "os_type": {"type":"string"},
67 "os_version": {"type":"string"},
68 "bus": {"type":"string"},
69 "topology": {"type":"string", "enum": ["oneSocket"]}
70 }
71}
72
73#Schema for the configuration file
74config_schema = {
75 "title":"configuration response information schema",
76 "$schema": "http://json-schema.org/draft-04/schema#",
77 "type":"object",
78 "properties":{
79 "http_port": port_schema,
80 "http_admin_port": port_schema,
81 "http_host": nameshort_schema,
tiernod29b1d32017-01-25 11:02:52 +010082 "auto_push_VNF_to_VIMs": {"type":"boolean"},
tierno7edb6752016-03-21 17:37:52 +010083 "vnf_repository": path_schema,
84 "db_host": nameshort_schema,
85 "db_user": nameshort_schema,
86 "db_passwd": {"type":"string"},
87 "db_name": nameshort_schema,
88 # Next fields will disappear once the MANO API includes appropriate primitives
89 "vim_url": http_schema,
90 "vim_url_admin": http_schema,
91 "vim_name": nameshort_schema,
92 "vim_tenant_name": nameshort_schema,
93 "mano_tenant_name": nameshort_schema,
94 "mano_tenant_id": id_schema,
tierno20fc2a22016-08-19 17:02:35 +020095 "http_console_proxy": {"type":"boolean"},
96 "http_console_host": nameshort_schema,
tierno7edb6752016-03-21 17:37:52 +010097 "http_console_ports": {
98 "type": "array",
99 "items": {"OneOf" : [
100 port_schema,
101 {"type":"object", "properties":{"from": port_schema, "to": port_schema}, "required": ["from","to"]}
102 ]}
103 },
tiernoae4a8d12016-07-08 12:30:39 +0200104 "log_level": log_level_schema,
tierno72f35a52016-07-15 13:18:30 +0200105 "log_socket_level": log_level_schema,
tiernoae4a8d12016-07-08 12:30:39 +0200106 "log_level_db": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200107 "log_level_vim": log_level_schema,
tiernof97fd272016-07-11 14:32:37 +0200108 "log_level_nfvo": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200109 "log_level_http": log_level_schema,
tierno1ae51342017-01-16 12:48:30 +0000110 "log_level_console": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200111 "log_file_db": path_schema,
112 "log_file_vim": path_schema,
113 "log_file_nfvo": path_schema,
114 "log_file_http": path_schema,
tierno1ae51342017-01-16 12:48:30 +0000115 "log_file_console": path_schema,
tierno72f35a52016-07-15 13:18:30 +0200116 "log_socket_host": nameshort_schema,
117 "log_socket_port": port_schema,
tiernof97fd272016-07-11 14:32:37 +0200118 "log_file": path_schema,
tierno7edb6752016-03-21 17:37:52 +0100119 },
120 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
121 "additionalProperties": False
122}
123
124tenant_schema = {
125 "title":"tenant information schema",
126 "$schema": "http://json-schema.org/draft-04/schema#",
127 "type":"object",
128 "properties":{
129 "tenant":{
130 "type":"object",
131 "properties":{
132 "name": nameshort_schema,
133 "description": description_schema,
134 },
135 "required": ["name"],
136 "additionalProperties": True
137 }
138 },
139 "required": ["tenant"],
140 "additionalProperties": False
141}
garciadeblasfec35df2016-08-25 11:33:57 +0200142
tierno7edb6752016-03-21 17:37:52 +0100143tenant_edit_schema = {
144 "title":"tenant edit information schema",
145 "$schema": "http://json-schema.org/draft-04/schema#",
146 "type":"object",
147 "properties":{
148 "tenant":{
149 "type":"object",
150 "properties":{
151 "name": name_schema,
152 "description": description_schema,
153 },
154 "additionalProperties": False
155 }
156 },
157 "required": ["tenant"],
158 "additionalProperties": False
159}
160
161datacenter_schema_properties={
garciadeblasfec35df2016-08-25 11:33:57 +0200162 "name": name_schema,
163 "description": description_schema,
164 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
165 "vim_url": description_schema,
166 "vim_url_admin": description_schema,
167 "config": { "type":"object" }
168}
tierno7edb6752016-03-21 17:37:52 +0100169
170datacenter_schema = {
171 "title":"datacenter information schema",
172 "$schema": "http://json-schema.org/draft-04/schema#",
173 "type":"object",
174 "properties":{
175 "datacenter":{
176 "type":"object",
177 "properties":datacenter_schema_properties,
178 "required": ["name", "vim_url"],
179 "additionalProperties": True
180 }
181 },
182 "required": ["datacenter"],
183 "additionalProperties": False
184}
185
186
187datacenter_edit_schema = {
188 "title":"datacenter edit nformation schema",
189 "$schema": "http://json-schema.org/draft-04/schema#",
190 "type":"object",
191 "properties":{
192 "datacenter":{
193 "type":"object",
194 "properties":datacenter_schema_properties,
195 "additionalProperties": False
196 }
197 },
198 "required": ["datacenter"],
199 "additionalProperties": False
200}
201
202
203netmap_new_schema = {
204 "title":"netmap new information schema",
205 "$schema": "http://json-schema.org/draft-04/schema#",
206 "type":"object",
207 "properties":{
208 "netmap":{ #delete from datacenter
209 "type":"object",
210 "properties":{
211 "name": name_schema, #name or uuid of net to change
212 "vim_id": id_schema,
213 "vim_name": name_schema
214 },
215 "minProperties": 1,
216 "additionalProperties": False
217 },
218 },
219 "required": ["netmap"],
220 "additionalProperties": False
221}
222
223netmap_edit_schema = {
224 "title":"netmap edit information schema",
225 "$schema": "http://json-schema.org/draft-04/schema#",
226 "type":"object",
227 "properties":{
228 "netmap":{ #delete from datacenter
229 "type":"object",
230 "properties":{
231 "name": name_schema, #name or uuid of net to change
232 },
233 "minProperties": 1,
234 "additionalProperties": False
235 },
236 },
237 "required": ["netmap"],
238 "additionalProperties": False
239}
240
241datacenter_action_schema = {
242 "title":"datacenter action information schema",
243 "$schema": "http://json-schema.org/draft-04/schema#",
244 "type":"object",
245 "properties":{
246 "net-update":{"type":"null",},
247 "net-edit":{
248 "type":"object",
249 "properties":{
250 "net": name_schema, #name or uuid of net to change
251 "name": name_schema,
252 "description": description_schema,
253 "shared": {"type": "boolean"}
254 },
255 "minProperties": 1,
256 "additionalProperties": False
257 },
258 "net-delete":{
259 "type":"object",
260 "properties":{
261 "net": name_schema, #name or uuid of net to change
262 },
263 "required": ["net"],
264 "additionalProperties": False
265 },
266 },
267 "minProperties": 1,
268 "maxProperties": 1,
269 "additionalProperties": False
270}
271
272
273datacenter_associate_schema={
274 "title":"datacenter associate information schema",
275 "$schema": "http://json-schema.org/draft-04/schema#",
276 "type":"object",
277 "properties":{
278 "datacenter":{
279 "type":"object",
280 "properties":{
tierno8008c3a2016-10-13 15:34:28 +0000281 "vim_tenant": name_schema,
282 "vim_tenant_name": name_schema,
tierno7edb6752016-03-21 17:37:52 +0100283 "vim_username": nameshort_schema,
284 "vim_password": nameshort_schema,
tierno8008c3a2016-10-13 15:34:28 +0000285 "config": {"type": "object"}
tierno7edb6752016-03-21 17:37:52 +0100286 },
287# "required": ["vim_tenant"],
288 "additionalProperties": True
289 }
290 },
291 "required": ["datacenter"],
292 "additionalProperties": False
293}
294
garciadeblasfec35df2016-08-25 11:33:57 +0200295dhcp_schema = {
296 "title":"DHCP schema",
297 "$schema": "http://json-schema.org/draft-04/schema#",
298 "type":"object",
299 "properties":{
300 "enabled": {"type": "boolean"},
301 "start-address": ip_schema,
302 "count": integer1_schema
garciadeblas9f8456e2016-09-05 05:02:59 +0200303 },
304 "required": ["enabled", "start-address", "count"],
garciadeblasfec35df2016-08-25 11:33:57 +0200305}
306
307ip_profile_schema = {
308 "title":"IP profile schema",
309 "$schema": "http://json-schema.org/draft-04/schema#",
310 "type":"object",
311 "properties":{
312 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
313 "subnet-address": ip_prefix_schema,
314 "gateway-address": ip_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200315 "dns-address": ip_schema,
316 "dhcp": dhcp_schema
317 },
318}
319
320key_pair_schema = {
321 "title": "Key-pair schema for cloud-init configuration schema",
322 "$schema": "http://json-schema.org/draft-04/schema#",
323 "type":"object",
324 "properties":{
325 "name": name_schema,
326 "key": {"type":"string"}
327 },
328 "required": ["key"],
329 "additionalProperties": False
330}
331
332cloud_config_user_schema = {
333 "title": "User schema for cloud-init configuration schema",
334 "$schema": "http://json-schema.org/draft-04/schema#",
335 "type":"object",
336 "properties":{
337 "name": nameshort_schema,
338 "user-info": {"type":"string"},
339 #"key-pairs": {"type" : "array", "items": key_pair_schema}
340 "key-pairs": {"type" : "array", "items": {"type":"string"}}
341 },
342 "required": ["name"],
343 "additionalProperties": False
344}
345
346cloud_config_schema = {
347 "title": "Cloud-init configuration schema",
348 "$schema": "http://json-schema.org/draft-04/schema#",
349 "type":"object",
350 "properties":{
351 #"key-pairs": {"type" : "array", "items": key_pair_schema},
352 "key-pairs": {"type" : "array", "items": {"type":"string"}},
353 "users": {"type" : "array", "items": cloud_config_user_schema}
354 },
355 "additionalProperties": False
356}
357
tierno7edb6752016-03-21 17:37:52 +0100358internal_connection_element_schema = {
359 "type":"object",
360 "properties":{
361 "VNFC": name_schema,
362 "local_iface_name": name_schema
363 }
364}
365
garciadeblasfec35df2016-08-25 11:33:57 +0200366internal_connection_element_schema_v02 = {
367 "type":"object",
368 "properties":{
369 "VNFC": name_schema,
370 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200371 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200372 }
373}
374
tierno7edb6752016-03-21 17:37:52 +0100375internal_connection_schema = {
376 "type":"object",
377 "properties":{
378 "name": name_schema,
379 "description":description_schema,
380 "type":{"type":"string", "enum":["bridge","data","ptp"]},
381 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
382 },
383 "required": ["name", "type", "elements"],
384 "additionalProperties": False
385}
386
garciadeblasfec35df2016-08-25 11:33:57 +0200387internal_connection_schema_v02 = {
388 "type":"object",
389 "properties":{
390 "name": name_schema,
391 "description":description_schema,
392 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200393 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200394 "ip-profile": ip_profile_schema,
395 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":2}
396 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200397 "required": ["name", "type", "implementation", "elements"],
garciadeblasfec35df2016-08-25 11:33:57 +0200398 "additionalProperties": False
399}
400
tierno7edb6752016-03-21 17:37:52 +0100401external_connection_schema = {
402 "type":"object",
403 "properties":{
404 "name": name_schema,
405 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
406 "VNFC": name_schema,
407 "local_iface_name": name_schema ,
408 "description":description_schema
409 },
410 "required": ["name", "type", "VNFC", "local_iface_name"],
411 "additionalProperties": False
412}
413
garciadeblas9f8456e2016-09-05 05:02:59 +0200414#Not yet used
garciadeblasfec35df2016-08-25 11:33:57 +0200415external_connection_schema_v02 = {
416 "type":"object",
417 "properties":{
418 "name": name_schema,
garciadeblas9f8456e2016-09-05 05:02:59 +0200419 "mgmt": {"type":"boolean"},
420 "type": {"type": "string", "enum":["e-line", "e-lan"]},
421 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200422 "VNFC": name_schema,
423 "local_iface_name": name_schema ,
424 "description":description_schema
425 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200426 "required": ["name", "type", "VNFC", "local_iface_name"],
garciadeblasfec35df2016-08-25 11:33:57 +0200427 "additionalProperties": False
428}
429
tierno7edb6752016-03-21 17:37:52 +0100430interfaces_schema={
431 "type":"array",
432 "items":{
433 "type":"object",
434 "properties":{
435 "name":name_schema,
436 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
437 "bandwidth":bandwidth_schema,
438 "vpci":pci_schema,
439 "mac_address": mac_schema
440 },
441 "additionalProperties": False,
442 "required": ["name","dedicated", "bandwidth"]
443 }
444}
445
446bridge_interfaces_schema={
447 "type":"array",
448 "items":{
449 "type":"object",
450 "properties":{
451 "name": name_schema,
452 "bandwidth":bandwidth_schema,
453 "vpci":pci_schema,
454 "mac_address": mac_schema,
montesmoreno2a1fc4e2017-01-09 16:46:04 +0000455 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]},
456 "port-security": {"type" : "boolean"},
457 "floating-ip": {"type" : "boolean"}
tierno7edb6752016-03-21 17:37:52 +0100458 },
459 "additionalProperties": False,
460 "required": ["name"]
461 }
462}
463
464devices_schema={
465 "type":"array",
466 "items":{
467 "type":"object",
468 "properties":{
469 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
470 "image": path_schema,
garciadeblasb69fa9f2016-09-28 12:04:10 +0200471 "image name": name_schema,
472 "image checksum": checksum_schema,
montesmoreno0c8def02016-12-22 12:16:23 +0000473 "image metadata": metadata_schema,
474 "size": size_schema,
tierno7edb6752016-03-21 17:37:52 +0100475 "vpci":pci_schema,
476 "xml":xml_text_schema,
477 },
478 "additionalProperties": False,
479 "required": ["type"]
480 }
481}
482
483
484numa_schema = {
485 "type": "object",
486 "properties": {
487 "memory":integer1_schema,
488 "cores":integer1_schema,
489 "paired-threads":integer1_schema,
490 "threads":integer1_schema,
491 "cores-id":{"type":"array","items":integer0_schema},
492 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
493 "threads-id":{"type":"array","items":integer0_schema},
494 "interfaces":interfaces_schema
495 },
496 "additionalProperties": False,
497 #"required": ["memory"]
498}
499
tierno36c0b172017-01-12 18:32:28 +0100500config_files_schema = {
501 "title": "Config files for cloud init schema",
502 "$schema": "http://json-schema.org/draft-04/schema#",
503 "type": "object",
504 "properties": {
505 "dest": path_schema,
506 "encoding": {"type": "string", "enum": ["b64", "base64", "gz", "gz+b64", "gz+base64", "gzip+b64", "gzip+base64"]}, #by default text
507 "content": {"type": "string"},
508 "permissions": {"type": "string"}, # tiypically octal notation '0644'
509 "owner": {"type": "string"}, # format: owner:group
510
511 },
512 "additionalProperties": False,
513 "required": ["dest", "content"],
514}
515
516boot_data_vdu_schema = {
517 "title": "Boot data (Cloud-init) configuration schema",
518 "$schema": "http://json-schema.org/draft-04/schema#",
519 "type": "object",
520 "properties":{
521 "key-pairs": {"type" : "array", "items": {"type":"string"}},
522 "users": {"type" : "array", "items": cloud_config_user_schema},
523 "user-data": {"type" : "string"}, # scrip to run
524 "config-files": {"type": "array", "items": config_files_schema},
525 # NOTE: “user-data” are mutually exclusive with users and config-files because user/files are injected using user-data
526 "boot-data-drive": {"type": "boolean"},
527 },
528 "additionalProperties": False,
529}
530
tierno7edb6752016-03-21 17:37:52 +0100531vnfc_schema = {
532 "type":"object",
533 "properties":{
534 "name": name_schema,
535 "description": description_schema,
536 "VNFC image": {"oneOf": [path_schema, http_schema]},
garciadeblasb69fa9f2016-09-28 12:04:10 +0200537 "image name": name_schema,
538 "image checksum": checksum_schema,
tierno7edb6752016-03-21 17:37:52 +0100539 "image metadata": metadata_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200540 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
tierno7edb6752016-03-21 17:37:52 +0100541 "processor": {
542 "type":"object",
543 "properties":{
544 "model":description_schema,
545 "features":{"type":"array","items":nameshort_schema}
546 },
547 "required": ["model"],
548 "additionalProperties": False
549 },
550 "hypervisor": {
551 "type":"object",
552 "properties":{
553 "type":nameshort_schema,
554 "version":description_schema
555 },
556 },
557 "ram":integer0_schema,
558 "vcpus":integer0_schema,
559 "disk": integer1_schema,
560 "numas": {
561 "type": "array",
garciadeblasfec35df2016-08-25 11:33:57 +0200562 "items": numa_schema
tierno7edb6752016-03-21 17:37:52 +0100563 },
564 "bridge-ifaces": bridge_interfaces_schema,
tierno36c0b172017-01-12 18:32:28 +0100565 "devices": devices_schema,
566 "boot-data" : boot_data_vdu_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200567
tierno7edb6752016-03-21 17:37:52 +0100568 },
garciadeblasb69fa9f2016-09-28 12:04:10 +0200569 "required": ["name"],
570 "oneOf": [
571 {"required": ["VNFC image"]},
572 {"required": ["image name"]}
573 ],
tierno7edb6752016-03-21 17:37:52 +0100574 "additionalProperties": False
575}
576
577vnfd_schema_v01 = {
578 "title":"vnfd information schema v0.1",
579 "$schema": "http://json-schema.org/draft-04/schema#",
580 "type":"object",
581 "properties":{
582 "vnf":{
583 "type":"object",
584 "properties":{
585 "name": name_schema,
586 "description": description_schema,
587 "class": nameshort_schema,
588 "public": {"type" : "boolean"},
589 "physical": {"type" : "boolean"},
590 "tenant_id": id_schema, #only valid for admin
591 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
592 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
593 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
594 },
595 "required": ["name","external-connections"],
596 "additionalProperties": True
597 }
598 },
599 "required": ["vnf"],
600 "additionalProperties": False
601}
602
garciadeblasfec35df2016-08-25 11:33:57 +0200603#VNFD schema for OSM R1
tierno7edb6752016-03-21 17:37:52 +0100604vnfd_schema_v02 = {
605 "title":"vnfd information schema v0.2",
606 "$schema": "http://json-schema.org/draft-04/schema#",
607 "type":"object",
608 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200609 "schema_version": {"type": "string", "enum": ["0.2"]},
tierno7edb6752016-03-21 17:37:52 +0100610 "vnf":{
611 "type":"object",
612 "properties":{
613 "name": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200614 "description": description_schema,
615 "class": nameshort_schema,
616 "public": {"type" : "boolean"},
617 "physical": {"type" : "boolean"},
618 "tenant_id": id_schema, #only valid for admin
garciadeblas9f8456e2016-09-05 05:02:59 +0200619 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
garciadeblasfec35df2016-08-25 11:33:57 +0200620 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
621 # "cloud-config": cloud_config_schema, #common for all vnfcs
622 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
tierno7edb6752016-03-21 17:37:52 +0100623 },
624 "required": ["name"],
625 "additionalProperties": True
626 }
627 },
tierno392f2852016-05-13 12:28:55 +0200628 "required": ["vnf", "schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100629 "additionalProperties": False
630}
631
632#vnfd_schema = vnfd_schema_v01
633#{
634# "title":"vnfd information schema v0.2",
635# "$schema": "http://json-schema.org/draft-04/schema#",
636# "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
637#}
638
639graph_schema = {
640 "title":"graphical scenario descriptor information schema",
641 "$schema": "http://json-schema.org/draft-04/schema#",
642 "type":"object",
643 "properties":{
644 "x": integer0_schema,
645 "y": integer0_schema,
646 "ifaces": {
647 "type":"object",
648 "properties":{
649 "left": {"type":"array"},
650 "right": {"type":"array"},
651 "bottom": {"type":"array"},
652 }
653 }
654 },
655 "required": ["x","y"]
656}
657
658nsd_schema_v01 = {
659 "title":"network scenario descriptor information schema v0.1",
660 "$schema": "http://json-schema.org/draft-04/schema#",
661 "type":"object",
662 "properties":{
663 "name":name_schema,
664 "description": description_schema,
665 "tenant_id": id_schema, #only valid for admin
tierno392f2852016-05-13 12:28:55 +0200666 "public": {"type": "boolean"},
tierno7edb6752016-03-21 17:37:52 +0100667 "topology":{
668 "type":"object",
669 "properties":{
670 "nodes": {
671 "type":"object",
672 "patternProperties":{
673 ".": {
674 "type": "object",
675 "properties":{
676 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
677 "vnf_id": id_schema,
678 "graph": graph_schema,
679 },
680 "patternProperties":{
681 "^(VNF )?model$": {"type": "string"}
682 },
683 "required": ["type"]
684 }
685 }
686 },
687 "connections": {
688 "type":"object",
689 "patternProperties":{
690 ".": {
691 "type": "object",
692 "properties":{
693 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
694 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
695 "graph": graph_schema
696 },
697 "required": ["nodes"]
698 },
699 }
700 }
701 },
702 "required": ["nodes"],
703 "additionalProperties": False
704 }
705 },
706 "required": ["name","topology"],
707 "additionalProperties": False
708}
709
tierno7edb6752016-03-21 17:37:52 +0100710nsd_schema_v02 = {
711 "title":"network scenario descriptor information schema v0.2",
712 "$schema": "http://json-schema.org/draft-04/schema#",
713 "type":"object",
714 "properties":{
garciadeblas0c317ee2016-08-29 12:33:06 +0200715 "schema_version": schema_version_2,
tierno392f2852016-05-13 12:28:55 +0200716 "scenario":{
tierno7edb6752016-03-21 17:37:52 +0100717 "type":"object",
tierno392f2852016-05-13 12:28:55 +0200718 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200719 "name": name_schema,
tierno392f2852016-05-13 12:28:55 +0200720 "description": description_schema,
721 "tenant_id": id_schema, #only valid for admin
722 "public": {"type": "boolean"},
723 "vnfs": {
724 "type":"object",
725 "patternProperties":{
726 ".": {
727 "type": "object",
728 "properties":{
729 "vnf_id": id_schema,
730 "graph": graph_schema,
731 "vnf_name": name_schema,
732 },
733 }
tierno7edb6752016-03-21 17:37:52 +0100734 },
tierno392f2852016-05-13 12:28:55 +0200735 "minProperties": 1
tierno7edb6752016-03-21 17:37:52 +0100736 },
tierno392f2852016-05-13 12:28:55 +0200737 "networks": {
738 "type":"object",
739 "patternProperties":{
740 ".": {
741 "type": "object",
742 "properties":{
743 "interfaces":{"type":"array", "minLength":1},
744 "type": {"type": "string", "enum":["dataplane", "bridge"]},
745 "external" : {"type": "boolean"},
746 "graph": graph_schema
747 },
748 "required": ["interfaces"]
749 },
750 }
751 },
752
753 },
garciadeblasfec35df2016-08-25 11:33:57 +0200754 "required": ["vnfs", "name"],
755 "additionalProperties": False
756 }
757 },
758 "required": ["scenario","schema_version"],
759 "additionalProperties": False
760}
761
762#NSD schema for OSM R1
763nsd_schema_v03 = {
764 "title":"network scenario descriptor information schema v0.3",
765 "$schema": "http://json-schema.org/draft-04/schema#",
766 "type":"object",
767 "properties":{
768 "schema_version": {"type": "string", "enum": ["0.3"]},
769 "scenario":{
770 "type":"object",
771 "properties":{
772 "name": name_schema,
773 "description": description_schema,
774 "tenant_id": id_schema, #only valid for admin
775 "public": {"type": "boolean"},
776 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
garciadeblas0c317ee2016-08-29 12:33:06 +0200777 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200778 "vnfs": {
779 "type":"object",
780 "patternProperties":{
781 ".": {
782 "type": "object",
783 "properties":{
784 "vnf_id": id_schema,
785 "graph": graph_schema,
786 "vnf_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200787 #"cloud-config": cloud_config_schema, #particular for a vnf
788 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200789 "internal-connections": {
790 "type": "object",
791 "patternProperties": {
792 ".": {
793 "type": "object",
794 "properties": {
795 "ip-profile": ip_profile_schema,
796 "elements": {
797 "type" : "array",
798 "items":{
799 "type":"object",
800 "properties":{
801 "VNFC": name_schema,
802 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200803 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200804 },
805 "required": ["VNFC", "local_iface_name"],
806 }
807 }
808 }
809 }
810 }
811 }
812 },
813 }
814 },
815 "minProperties": 1
816 },
817 "networks": {
818 "type":"object",
819 "patternProperties":{
820 ".": {
821 "type": "object",
822 "properties":{
823 "interfaces":{
824 "type":"array",
825 "minLength":1,
826 "items":{
827 "type":"object",
828 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200829 "vnf": name_schema,
830 "vnf_interface": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200831 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200832 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200833 "required": ["vnf", "vnf_interface"],
garciadeblasfec35df2016-08-25 11:33:57 +0200834 }
835 },
836 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200837 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200838 "external" : {"type": "boolean"},
839 "graph": graph_schema,
840 "ip-profile": ip_profile_schema
841 },
842 "required": ["interfaces"]
843 },
844 }
845 },
846
847 },
tierno392f2852016-05-13 12:28:55 +0200848 "required": ["vnfs", "networks","name"],
849 "additionalProperties": False
850 }
tierno7edb6752016-03-21 17:37:52 +0100851 },
tierno392f2852016-05-13 12:28:55 +0200852 "required": ["scenario","schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100853 "additionalProperties": False
854}
855
856#scenario_new_schema = {
857# "title":"new scenario information schema",
858# "$schema": "http://json-schema.org/draft-04/schema#",
859# #"oneOf": [nsd_schema_v01, nsd_schema_v02]
860# "oneOf": [nsd_schema_v01]
861#}
862
863scenario_edit_schema = {
864 "title":"edit scenario information schema",
865 "$schema": "http://json-schema.org/draft-04/schema#",
866 "type":"object",
867 "properties":{
868 "name":name_schema,
869 "description": description_schema,
870 "topology":{
871 "type":"object",
872 "properties":{
873 "nodes": {
874 "type":"object",
875 "patternProperties":{
876 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
877 "type":"object",
878 "properties":{
879 "graph":{
880 "type": "object",
881 "properties":{
882 "x": integer0_schema,
883 "y": integer0_schema,
884 "ifaces":{ "type": "object"}
885 }
886 },
887 "description": description_schema,
888 "name": name_schema
889 }
890 }
891 }
892 }
893 },
894 "required": ["nodes"],
895 "additionalProperties": False
896 }
897 },
898 "additionalProperties": False
899}
900
901scenario_action_schema = {
902 "title":"scenario action information schema",
903 "$schema": "http://json-schema.org/draft-04/schema#",
904 "type":"object",
905 "properties":{
906 "start":{
907 "type": "object",
908 "properties": {
909 "instance_name":name_schema,
910 "description":description_schema,
911 "datacenter": {"type": "string"}
912 },
913 "required": ["instance_name"]
914 },
915 "deploy":{
916 "type": "object",
917 "properties": {
918 "instance_name":name_schema,
919 "description":description_schema,
920 "datacenter": {"type": "string"}
921 },
922 "required": ["instance_name"]
923 },
924 "reserve":{
925 "type": "object",
926 "properties": {
927 "instance_name":name_schema,
928 "description":description_schema,
929 "datacenter": {"type": "string"}
930 },
931 "required": ["instance_name"]
932 },
933 "verify":{
934 "type": "object",
935 "properties": {
936 "instance_name":name_schema,
937 "description":description_schema,
938 "datacenter": {"type": "string"}
939 },
940 "required": ["instance_name"]
941 }
942 },
943 "minProperties": 1,
944 "maxProperties": 1,
945 "additionalProperties": False
946}
947
garciadeblasfec35df2016-08-25 11:33:57 +0200948instance_scenario_create_schema_v01 = {
tierno7edb6752016-03-21 17:37:52 +0100949 "title":"instance scenario create information schema v0.1",
950 "$schema": "http://json-schema.org/draft-04/schema#",
951 "type":"object",
952 "properties":{
953 "schema_version": {"type": "string", "enum": ["0.1"]},
954 "instance":{
955 "type":"object",
956 "properties":{
957 "name":name_schema,
958 "description":description_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200959 "datacenter": name_schema,
960 "scenario" : name_schema, #can be an UUID or name
tierno7edb6752016-03-21 17:37:52 +0100961 "action":{"enum": ["deploy","reserve","verify" ]},
garciadeblasfec35df2016-08-25 11:33:57 +0200962 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
963 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
tierno7edb6752016-03-21 17:37:52 +0100964 "vnfs":{ #mapping from scenario to datacenter
965 "type": "object",
966 "patternProperties":{
967 ".": {
968 "type": "object",
969 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200970 "name": name_schema, #override vnf name
garciadeblas0c317ee2016-08-29 12:33:06 +0200971 "datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200972 #"metadata": {"type": "object"},
973 #"user_data": {"type": "string"}
garciadeblas0c317ee2016-08-29 12:33:06 +0200974 #"cloud-config": cloud_config_schema, #particular for a vnf
garciadeblasfec35df2016-08-25 11:33:57 +0200975 "external-connections": {
976 "type": "object",
977 "patternProperties": {
978 ".": {
979 "type": "object",
980 "properties": {
981 "vim-network-name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200982 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200983 }
984 }
985 }
986 },
987 "internal-connections": {
988 "type": "object",
989 "patternProperties": {
990 ".": {
991 "type": "object",
992 "properties": {
993 "ip-profile": ip_profile_schema,
994 "elements": {
995 "type" : "array",
996 "items":{
997 "type":"object",
998 "properties":{
999 "VNFC": name_schema,
1000 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +02001001 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +02001002 },
1003 "required": ["VNFC", "local_iface_name"],
1004 }
1005 }
1006 }
1007 }
1008 }
1009 }
tierno7edb6752016-03-21 17:37:52 +01001010 }
1011 }
1012 },
1013 },
1014 "networks":{ #mapping from scenario to datacenter
1015 "type": "object",
1016 "patternProperties":{
1017 ".": {
1018 "type": "object",
1019 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +02001020 "interfaces":{
1021 "type":"array",
1022 "minLength":1,
1023 "items":{
1024 "type":"object",
1025 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +02001026 "ip_address": ip_schema,
1027 "datacenter": name_schema,
1028 "vim-network-name": name_schema
garciadeblasfec35df2016-08-25 11:33:57 +02001029 },
1030 "patternProperties":{
1031 ".": {"type": "string"}
1032 }
1033 }
1034 },
garciadeblasfec35df2016-08-25 11:33:57 +02001035 "ip-profile": ip_profile_schema,
tiernobe41e222016-09-02 15:16:13 +02001036 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
1037 "sites": {
1038 "type":"array",
1039 "minLength":1,
1040 "items":{
1041 "type":"object",
1042 "properties":{
1043 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
1044 # for other networks openamno creates at VIM
1045 # Use netmap-create to force to create an external scenario network
1046 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
1047 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
1048 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
1049 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
1050 #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)
1051 "netmap-use": name_schema, #
1052 "vim-network-name": name_schema, #override network name
1053 #"ip-profile": ip_profile_schema,
1054 "datacenter": name_schema,
1055 }
1056 }
1057 },
1058
1059
1060
tierno7edb6752016-03-21 17:37:52 +01001061 }
1062 }
1063 },
1064 },
1065 },
1066 "additionalProperties": False,
garciadeblasfec35df2016-08-25 11:33:57 +02001067 "required": ["name"]
tierno7edb6752016-03-21 17:37:52 +01001068 },
1069 },
1070 "required": ["instance"],
1071 "additionalProperties": False
tierno7edb6752016-03-21 17:37:52 +01001072}
1073
1074instance_scenario_action_schema = {
1075 "title":"instance scenario action information schema",
1076 "$schema": "http://json-schema.org/draft-04/schema#",
1077 "type":"object",
1078 "properties":{
1079 "start":{"type": "null"},
1080 "pause":{"type": "null"},
1081 "resume":{"type": "null"},
1082 "shutoff":{"type": "null"},
1083 "shutdown":{"type": "null"},
1084 "forceOff":{"type": "null"},
1085 "rebuild":{"type": "null"},
1086 "reboot":{
1087 "type": ["object","null"],
1088 },
1089 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1090 "vnfs":{"type": "array", "items":{"type":"string"}},
1091 "vms":{"type": "array", "items":{"type":"string"}}
1092 },
1093 "minProperties": 1,
1094 #"maxProperties": 1,
1095 "additionalProperties": False
1096}