blob: 3d95dc7d088f101fb5b65ee9fcd8b03bd4544c5a [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'''
27__author__="Alfonso Tierno, Gerardo Garcia"
28__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"]}
tierno7edb6752016-03-21 17:37:52 +010057
58metadata_schema={
59 "type":"object",
60 "properties":{
61 "architecture": {"type":"string"},
62 "use_incremental": {"type":"string","enum":["yes","no"]},
63 "vpci": pci_schema,
64 "os_distro": {"type":"string"},
65 "os_type": {"type":"string"},
66 "os_version": {"type":"string"},
67 "bus": {"type":"string"},
68 "topology": {"type":"string", "enum": ["oneSocket"]}
69 }
70}
71
72#Schema for the configuration file
73config_schema = {
74 "title":"configuration response information schema",
75 "$schema": "http://json-schema.org/draft-04/schema#",
76 "type":"object",
77 "properties":{
78 "http_port": port_schema,
79 "http_admin_port": port_schema,
80 "http_host": nameshort_schema,
81 "vnf_repository": path_schema,
82 "db_host": nameshort_schema,
83 "db_user": nameshort_schema,
84 "db_passwd": {"type":"string"},
85 "db_name": nameshort_schema,
86 # Next fields will disappear once the MANO API includes appropriate primitives
87 "vim_url": http_schema,
88 "vim_url_admin": http_schema,
89 "vim_name": nameshort_schema,
90 "vim_tenant_name": nameshort_schema,
91 "mano_tenant_name": nameshort_schema,
92 "mano_tenant_id": id_schema,
tierno20fc2a22016-08-19 17:02:35 +020093 "http_console_proxy": {"type":"boolean"},
94 "http_console_host": nameshort_schema,
tierno7edb6752016-03-21 17:37:52 +010095 "http_console_ports": {
96 "type": "array",
97 "items": {"OneOf" : [
98 port_schema,
99 {"type":"object", "properties":{"from": port_schema, "to": port_schema}, "required": ["from","to"]}
100 ]}
101 },
tiernoae4a8d12016-07-08 12:30:39 +0200102 "log_level": log_level_schema,
tierno72f35a52016-07-15 13:18:30 +0200103 "log_socket_level": log_level_schema,
tiernoae4a8d12016-07-08 12:30:39 +0200104 "log_level_db": log_level_schema,
tiernof97fd272016-07-11 14:32:37 +0200105 "log_level_vimconn": log_level_schema,
106 "log_level_nfvo": log_level_schema,
tierno72f35a52016-07-15 13:18:30 +0200107 "log_socket_host": nameshort_schema,
108 "log_socket_port": port_schema,
tiernof97fd272016-07-11 14:32:37 +0200109 "log_file": path_schema,
tierno7edb6752016-03-21 17:37:52 +0100110 },
111 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
112 "additionalProperties": False
113}
114
115tenant_schema = {
116 "title":"tenant information schema",
117 "$schema": "http://json-schema.org/draft-04/schema#",
118 "type":"object",
119 "properties":{
120 "tenant":{
121 "type":"object",
122 "properties":{
123 "name": nameshort_schema,
124 "description": description_schema,
125 },
126 "required": ["name"],
127 "additionalProperties": True
128 }
129 },
130 "required": ["tenant"],
131 "additionalProperties": False
132}
garciadeblasfec35df2016-08-25 11:33:57 +0200133
tierno7edb6752016-03-21 17:37:52 +0100134tenant_edit_schema = {
135 "title":"tenant edit information schema",
136 "$schema": "http://json-schema.org/draft-04/schema#",
137 "type":"object",
138 "properties":{
139 "tenant":{
140 "type":"object",
141 "properties":{
142 "name": name_schema,
143 "description": description_schema,
144 },
145 "additionalProperties": False
146 }
147 },
148 "required": ["tenant"],
149 "additionalProperties": False
150}
151
152datacenter_schema_properties={
garciadeblasfec35df2016-08-25 11:33:57 +0200153 "name": name_schema,
154 "description": description_schema,
155 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
156 "vim_url": description_schema,
157 "vim_url_admin": description_schema,
158 "config": { "type":"object" }
159}
tierno7edb6752016-03-21 17:37:52 +0100160
161datacenter_schema = {
162 "title":"datacenter information schema",
163 "$schema": "http://json-schema.org/draft-04/schema#",
164 "type":"object",
165 "properties":{
166 "datacenter":{
167 "type":"object",
168 "properties":datacenter_schema_properties,
169 "required": ["name", "vim_url"],
170 "additionalProperties": True
171 }
172 },
173 "required": ["datacenter"],
174 "additionalProperties": False
175}
176
177
178datacenter_edit_schema = {
179 "title":"datacenter edit nformation schema",
180 "$schema": "http://json-schema.org/draft-04/schema#",
181 "type":"object",
182 "properties":{
183 "datacenter":{
184 "type":"object",
185 "properties":datacenter_schema_properties,
186 "additionalProperties": False
187 }
188 },
189 "required": ["datacenter"],
190 "additionalProperties": False
191}
192
193
194netmap_new_schema = {
195 "title":"netmap new information schema",
196 "$schema": "http://json-schema.org/draft-04/schema#",
197 "type":"object",
198 "properties":{
199 "netmap":{ #delete from datacenter
200 "type":"object",
201 "properties":{
202 "name": name_schema, #name or uuid of net to change
203 "vim_id": id_schema,
204 "vim_name": name_schema
205 },
206 "minProperties": 1,
207 "additionalProperties": False
208 },
209 },
210 "required": ["netmap"],
211 "additionalProperties": False
212}
213
214netmap_edit_schema = {
215 "title":"netmap edit information schema",
216 "$schema": "http://json-schema.org/draft-04/schema#",
217 "type":"object",
218 "properties":{
219 "netmap":{ #delete from datacenter
220 "type":"object",
221 "properties":{
222 "name": name_schema, #name or uuid of net to change
223 },
224 "minProperties": 1,
225 "additionalProperties": False
226 },
227 },
228 "required": ["netmap"],
229 "additionalProperties": False
230}
231
232datacenter_action_schema = {
233 "title":"datacenter action information schema",
234 "$schema": "http://json-schema.org/draft-04/schema#",
235 "type":"object",
236 "properties":{
237 "net-update":{"type":"null",},
238 "net-edit":{
239 "type":"object",
240 "properties":{
241 "net": name_schema, #name or uuid of net to change
242 "name": name_schema,
243 "description": description_schema,
244 "shared": {"type": "boolean"}
245 },
246 "minProperties": 1,
247 "additionalProperties": False
248 },
249 "net-delete":{
250 "type":"object",
251 "properties":{
252 "net": name_schema, #name or uuid of net to change
253 },
254 "required": ["net"],
255 "additionalProperties": False
256 },
257 },
258 "minProperties": 1,
259 "maxProperties": 1,
260 "additionalProperties": False
261}
262
263
264datacenter_associate_schema={
265 "title":"datacenter associate information schema",
266 "$schema": "http://json-schema.org/draft-04/schema#",
267 "type":"object",
268 "properties":{
269 "datacenter":{
270 "type":"object",
271 "properties":{
272 "vim_tenant": id_schema,
273 "vim_tenant_name": nameshort_schema,
274 "vim_username": nameshort_schema,
275 "vim_password": nameshort_schema,
276 },
277# "required": ["vim_tenant"],
278 "additionalProperties": True
279 }
280 },
281 "required": ["datacenter"],
282 "additionalProperties": False
283}
284
garciadeblasfec35df2016-08-25 11:33:57 +0200285dhcp_schema = {
286 "title":"DHCP schema",
287 "$schema": "http://json-schema.org/draft-04/schema#",
288 "type":"object",
289 "properties":{
290 "enabled": {"type": "boolean"},
291 "start-address": ip_schema,
292 "count": integer1_schema
garciadeblas9f8456e2016-09-05 05:02:59 +0200293 },
294 "required": ["enabled", "start-address", "count"],
garciadeblasfec35df2016-08-25 11:33:57 +0200295}
296
297ip_profile_schema = {
298 "title":"IP profile schema",
299 "$schema": "http://json-schema.org/draft-04/schema#",
300 "type":"object",
301 "properties":{
302 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
303 "subnet-address": ip_prefix_schema,
304 "gateway-address": ip_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200305 "dns-address": ip_schema,
306 "dhcp": dhcp_schema
307 },
308}
309
310key_pair_schema = {
311 "title": "Key-pair schema for cloud-init configuration schema",
312 "$schema": "http://json-schema.org/draft-04/schema#",
313 "type":"object",
314 "properties":{
315 "name": name_schema,
316 "key": {"type":"string"}
317 },
318 "required": ["key"],
319 "additionalProperties": False
320}
321
322cloud_config_user_schema = {
323 "title": "User schema for cloud-init configuration schema",
324 "$schema": "http://json-schema.org/draft-04/schema#",
325 "type":"object",
326 "properties":{
327 "name": nameshort_schema,
328 "user-info": {"type":"string"},
329 #"key-pairs": {"type" : "array", "items": key_pair_schema}
330 "key-pairs": {"type" : "array", "items": {"type":"string"}}
331 },
332 "required": ["name"],
333 "additionalProperties": False
334}
335
336cloud_config_schema = {
337 "title": "Cloud-init configuration schema",
338 "$schema": "http://json-schema.org/draft-04/schema#",
339 "type":"object",
340 "properties":{
341 #"key-pairs": {"type" : "array", "items": key_pair_schema},
342 "key-pairs": {"type" : "array", "items": {"type":"string"}},
343 "users": {"type" : "array", "items": cloud_config_user_schema}
344 },
345 "additionalProperties": False
346}
347
tierno7edb6752016-03-21 17:37:52 +0100348internal_connection_element_schema = {
349 "type":"object",
350 "properties":{
351 "VNFC": name_schema,
352 "local_iface_name": name_schema
353 }
354}
355
garciadeblasfec35df2016-08-25 11:33:57 +0200356internal_connection_element_schema_v02 = {
357 "type":"object",
358 "properties":{
359 "VNFC": name_schema,
360 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200361 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200362 }
363}
364
tierno7edb6752016-03-21 17:37:52 +0100365internal_connection_schema = {
366 "type":"object",
367 "properties":{
368 "name": name_schema,
369 "description":description_schema,
370 "type":{"type":"string", "enum":["bridge","data","ptp"]},
371 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
372 },
373 "required": ["name", "type", "elements"],
374 "additionalProperties": False
375}
376
garciadeblasfec35df2016-08-25 11:33:57 +0200377internal_connection_schema_v02 = {
378 "type":"object",
379 "properties":{
380 "name": name_schema,
381 "description":description_schema,
382 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200383 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200384 "ip-profile": ip_profile_schema,
385 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":2}
386 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200387 "required": ["name", "type", "implementation", "elements"],
garciadeblasfec35df2016-08-25 11:33:57 +0200388 "additionalProperties": False
389}
390
tierno7edb6752016-03-21 17:37:52 +0100391external_connection_schema = {
392 "type":"object",
393 "properties":{
394 "name": name_schema,
395 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
396 "VNFC": name_schema,
397 "local_iface_name": name_schema ,
398 "description":description_schema
399 },
400 "required": ["name", "type", "VNFC", "local_iface_name"],
401 "additionalProperties": False
402}
403
garciadeblas9f8456e2016-09-05 05:02:59 +0200404#Not yet used
garciadeblasfec35df2016-08-25 11:33:57 +0200405external_connection_schema_v02 = {
406 "type":"object",
407 "properties":{
408 "name": name_schema,
garciadeblas9f8456e2016-09-05 05:02:59 +0200409 "mgmt": {"type":"boolean"},
410 "type": {"type": "string", "enum":["e-line", "e-lan"]},
411 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200412 "VNFC": name_schema,
413 "local_iface_name": name_schema ,
414 "description":description_schema
415 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200416 "required": ["name", "type", "VNFC", "local_iface_name"],
garciadeblasfec35df2016-08-25 11:33:57 +0200417 "additionalProperties": False
418}
419
tierno7edb6752016-03-21 17:37:52 +0100420interfaces_schema={
421 "type":"array",
422 "items":{
423 "type":"object",
424 "properties":{
425 "name":name_schema,
426 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
427 "bandwidth":bandwidth_schema,
428 "vpci":pci_schema,
429 "mac_address": mac_schema
430 },
431 "additionalProperties": False,
432 "required": ["name","dedicated", "bandwidth"]
433 }
434}
435
436bridge_interfaces_schema={
437 "type":"array",
438 "items":{
439 "type":"object",
440 "properties":{
441 "name": name_schema,
442 "bandwidth":bandwidth_schema,
443 "vpci":pci_schema,
444 "mac_address": mac_schema,
445 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
446 },
447 "additionalProperties": False,
448 "required": ["name"]
449 }
450}
451
452devices_schema={
453 "type":"array",
454 "items":{
455 "type":"object",
456 "properties":{
457 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
458 "image": path_schema,
459 "image metadata": metadata_schema,
460 "vpci":pci_schema,
461 "xml":xml_text_schema,
462 },
463 "additionalProperties": False,
464 "required": ["type"]
465 }
466}
467
468
469numa_schema = {
470 "type": "object",
471 "properties": {
472 "memory":integer1_schema,
473 "cores":integer1_schema,
474 "paired-threads":integer1_schema,
475 "threads":integer1_schema,
476 "cores-id":{"type":"array","items":integer0_schema},
477 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
478 "threads-id":{"type":"array","items":integer0_schema},
479 "interfaces":interfaces_schema
480 },
481 "additionalProperties": False,
482 #"required": ["memory"]
483}
484
485vnfc_schema = {
486 "type":"object",
487 "properties":{
488 "name": name_schema,
489 "description": description_schema,
490 "VNFC image": {"oneOf": [path_schema, http_schema]},
491 "image metadata": metadata_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200492 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
tierno7edb6752016-03-21 17:37:52 +0100493 "processor": {
494 "type":"object",
495 "properties":{
496 "model":description_schema,
497 "features":{"type":"array","items":nameshort_schema}
498 },
499 "required": ["model"],
500 "additionalProperties": False
501 },
502 "hypervisor": {
503 "type":"object",
504 "properties":{
505 "type":nameshort_schema,
506 "version":description_schema
507 },
508 },
509 "ram":integer0_schema,
510 "vcpus":integer0_schema,
511 "disk": integer1_schema,
512 "numas": {
513 "type": "array",
garciadeblasfec35df2016-08-25 11:33:57 +0200514 "items": numa_schema
tierno7edb6752016-03-21 17:37:52 +0100515 },
516 "bridge-ifaces": bridge_interfaces_schema,
517 "devices": devices_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200518
tierno7edb6752016-03-21 17:37:52 +0100519 },
520 "required": ["name", "VNFC image"],
521 "additionalProperties": False
522}
523
524vnfd_schema_v01 = {
525 "title":"vnfd information schema v0.1",
526 "$schema": "http://json-schema.org/draft-04/schema#",
527 "type":"object",
528 "properties":{
529 "vnf":{
530 "type":"object",
531 "properties":{
532 "name": name_schema,
533 "description": description_schema,
534 "class": nameshort_schema,
535 "public": {"type" : "boolean"},
536 "physical": {"type" : "boolean"},
537 "tenant_id": id_schema, #only valid for admin
538 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
539 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
540 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
541 },
542 "required": ["name","external-connections"],
543 "additionalProperties": True
544 }
545 },
546 "required": ["vnf"],
547 "additionalProperties": False
548}
549
garciadeblasfec35df2016-08-25 11:33:57 +0200550#VNFD schema for OSM R1
tierno7edb6752016-03-21 17:37:52 +0100551vnfd_schema_v02 = {
552 "title":"vnfd information schema v0.2",
553 "$schema": "http://json-schema.org/draft-04/schema#",
554 "type":"object",
555 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200556 "schema_version": {"type": "string", "enum": ["0.2"]},
tierno7edb6752016-03-21 17:37:52 +0100557 "vnf":{
558 "type":"object",
559 "properties":{
560 "name": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200561 "description": description_schema,
562 "class": nameshort_schema,
563 "public": {"type" : "boolean"},
564 "physical": {"type" : "boolean"},
565 "tenant_id": id_schema, #only valid for admin
garciadeblas9f8456e2016-09-05 05:02:59 +0200566 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
garciadeblasfec35df2016-08-25 11:33:57 +0200567 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
568 # "cloud-config": cloud_config_schema, #common for all vnfcs
569 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
tierno7edb6752016-03-21 17:37:52 +0100570 },
571 "required": ["name"],
572 "additionalProperties": True
573 }
574 },
tierno392f2852016-05-13 12:28:55 +0200575 "required": ["vnf", "schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100576 "additionalProperties": False
577}
578
579#vnfd_schema = vnfd_schema_v01
580#{
581# "title":"vnfd information schema v0.2",
582# "$schema": "http://json-schema.org/draft-04/schema#",
583# "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
584#}
585
586graph_schema = {
587 "title":"graphical scenario descriptor information schema",
588 "$schema": "http://json-schema.org/draft-04/schema#",
589 "type":"object",
590 "properties":{
591 "x": integer0_schema,
592 "y": integer0_schema,
593 "ifaces": {
594 "type":"object",
595 "properties":{
596 "left": {"type":"array"},
597 "right": {"type":"array"},
598 "bottom": {"type":"array"},
599 }
600 }
601 },
602 "required": ["x","y"]
603}
604
605nsd_schema_v01 = {
606 "title":"network scenario descriptor information schema v0.1",
607 "$schema": "http://json-schema.org/draft-04/schema#",
608 "type":"object",
609 "properties":{
610 "name":name_schema,
611 "description": description_schema,
612 "tenant_id": id_schema, #only valid for admin
tierno392f2852016-05-13 12:28:55 +0200613 "public": {"type": "boolean"},
tierno7edb6752016-03-21 17:37:52 +0100614 "topology":{
615 "type":"object",
616 "properties":{
617 "nodes": {
618 "type":"object",
619 "patternProperties":{
620 ".": {
621 "type": "object",
622 "properties":{
623 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
624 "vnf_id": id_schema,
625 "graph": graph_schema,
626 },
627 "patternProperties":{
628 "^(VNF )?model$": {"type": "string"}
629 },
630 "required": ["type"]
631 }
632 }
633 },
634 "connections": {
635 "type":"object",
636 "patternProperties":{
637 ".": {
638 "type": "object",
639 "properties":{
640 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
641 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
642 "graph": graph_schema
643 },
644 "required": ["nodes"]
645 },
646 }
647 }
648 },
649 "required": ["nodes"],
650 "additionalProperties": False
651 }
652 },
653 "required": ["name","topology"],
654 "additionalProperties": False
655}
656
tierno7edb6752016-03-21 17:37:52 +0100657nsd_schema_v02 = {
658 "title":"network scenario descriptor information schema v0.2",
659 "$schema": "http://json-schema.org/draft-04/schema#",
660 "type":"object",
661 "properties":{
garciadeblas0c317ee2016-08-29 12:33:06 +0200662 "schema_version": schema_version_2,
tierno392f2852016-05-13 12:28:55 +0200663 "scenario":{
tierno7edb6752016-03-21 17:37:52 +0100664 "type":"object",
tierno392f2852016-05-13 12:28:55 +0200665 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200666 "name": name_schema,
tierno392f2852016-05-13 12:28:55 +0200667 "description": description_schema,
668 "tenant_id": id_schema, #only valid for admin
669 "public": {"type": "boolean"},
670 "vnfs": {
671 "type":"object",
672 "patternProperties":{
673 ".": {
674 "type": "object",
675 "properties":{
676 "vnf_id": id_schema,
677 "graph": graph_schema,
678 "vnf_name": name_schema,
679 },
680 }
tierno7edb6752016-03-21 17:37:52 +0100681 },
tierno392f2852016-05-13 12:28:55 +0200682 "minProperties": 1
tierno7edb6752016-03-21 17:37:52 +0100683 },
tierno392f2852016-05-13 12:28:55 +0200684 "networks": {
685 "type":"object",
686 "patternProperties":{
687 ".": {
688 "type": "object",
689 "properties":{
690 "interfaces":{"type":"array", "minLength":1},
691 "type": {"type": "string", "enum":["dataplane", "bridge"]},
692 "external" : {"type": "boolean"},
693 "graph": graph_schema
694 },
695 "required": ["interfaces"]
696 },
697 }
698 },
699
700 },
garciadeblasfec35df2016-08-25 11:33:57 +0200701 "required": ["vnfs", "name"],
702 "additionalProperties": False
703 }
704 },
705 "required": ["scenario","schema_version"],
706 "additionalProperties": False
707}
708
709#NSD schema for OSM R1
710nsd_schema_v03 = {
711 "title":"network scenario descriptor information schema v0.3",
712 "$schema": "http://json-schema.org/draft-04/schema#",
713 "type":"object",
714 "properties":{
715 "schema_version": {"type": "string", "enum": ["0.3"]},
716 "scenario":{
717 "type":"object",
718 "properties":{
719 "name": name_schema,
720 "description": description_schema,
721 "tenant_id": id_schema, #only valid for admin
722 "public": {"type": "boolean"},
723 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
garciadeblas0c317ee2016-08-29 12:33:06 +0200724 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200725 "vnfs": {
726 "type":"object",
727 "patternProperties":{
728 ".": {
729 "type": "object",
730 "properties":{
731 "vnf_id": id_schema,
732 "graph": graph_schema,
733 "vnf_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200734 #"cloud-config": cloud_config_schema, #particular for a vnf
735 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200736 "internal-connections": {
737 "type": "object",
738 "patternProperties": {
739 ".": {
740 "type": "object",
741 "properties": {
742 "ip-profile": ip_profile_schema,
743 "elements": {
744 "type" : "array",
745 "items":{
746 "type":"object",
747 "properties":{
748 "VNFC": name_schema,
749 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200750 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200751 },
752 "required": ["VNFC", "local_iface_name"],
753 }
754 }
755 }
756 }
757 }
758 }
759 },
760 }
761 },
762 "minProperties": 1
763 },
764 "networks": {
765 "type":"object",
766 "patternProperties":{
767 ".": {
768 "type": "object",
769 "properties":{
770 "interfaces":{
771 "type":"array",
772 "minLength":1,
773 "items":{
774 "type":"object",
775 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200776 "vnf": name_schema,
777 "vnf_interface": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200778 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200779 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200780 "required": ["vnf", "vnf_interface"],
garciadeblasfec35df2016-08-25 11:33:57 +0200781 }
782 },
783 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200784 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200785 "external" : {"type": "boolean"},
786 "graph": graph_schema,
787 "ip-profile": ip_profile_schema
788 },
789 "required": ["interfaces"]
790 },
791 }
792 },
793
794 },
tierno392f2852016-05-13 12:28:55 +0200795 "required": ["vnfs", "networks","name"],
796 "additionalProperties": False
797 }
tierno7edb6752016-03-21 17:37:52 +0100798 },
tierno392f2852016-05-13 12:28:55 +0200799 "required": ["scenario","schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100800 "additionalProperties": False
801}
802
803#scenario_new_schema = {
804# "title":"new scenario information schema",
805# "$schema": "http://json-schema.org/draft-04/schema#",
806# #"oneOf": [nsd_schema_v01, nsd_schema_v02]
807# "oneOf": [nsd_schema_v01]
808#}
809
810scenario_edit_schema = {
811 "title":"edit scenario information schema",
812 "$schema": "http://json-schema.org/draft-04/schema#",
813 "type":"object",
814 "properties":{
815 "name":name_schema,
816 "description": description_schema,
817 "topology":{
818 "type":"object",
819 "properties":{
820 "nodes": {
821 "type":"object",
822 "patternProperties":{
823 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
824 "type":"object",
825 "properties":{
826 "graph":{
827 "type": "object",
828 "properties":{
829 "x": integer0_schema,
830 "y": integer0_schema,
831 "ifaces":{ "type": "object"}
832 }
833 },
834 "description": description_schema,
835 "name": name_schema
836 }
837 }
838 }
839 }
840 },
841 "required": ["nodes"],
842 "additionalProperties": False
843 }
844 },
845 "additionalProperties": False
846}
847
848scenario_action_schema = {
849 "title":"scenario action information schema",
850 "$schema": "http://json-schema.org/draft-04/schema#",
851 "type":"object",
852 "properties":{
853 "start":{
854 "type": "object",
855 "properties": {
856 "instance_name":name_schema,
857 "description":description_schema,
858 "datacenter": {"type": "string"}
859 },
860 "required": ["instance_name"]
861 },
862 "deploy":{
863 "type": "object",
864 "properties": {
865 "instance_name":name_schema,
866 "description":description_schema,
867 "datacenter": {"type": "string"}
868 },
869 "required": ["instance_name"]
870 },
871 "reserve":{
872 "type": "object",
873 "properties": {
874 "instance_name":name_schema,
875 "description":description_schema,
876 "datacenter": {"type": "string"}
877 },
878 "required": ["instance_name"]
879 },
880 "verify":{
881 "type": "object",
882 "properties": {
883 "instance_name":name_schema,
884 "description":description_schema,
885 "datacenter": {"type": "string"}
886 },
887 "required": ["instance_name"]
888 }
889 },
890 "minProperties": 1,
891 "maxProperties": 1,
892 "additionalProperties": False
893}
894
garciadeblasfec35df2016-08-25 11:33:57 +0200895instance_scenario_create_schema_v01 = {
tierno7edb6752016-03-21 17:37:52 +0100896 "title":"instance scenario create information schema v0.1",
897 "$schema": "http://json-schema.org/draft-04/schema#",
898 "type":"object",
899 "properties":{
900 "schema_version": {"type": "string", "enum": ["0.1"]},
901 "instance":{
902 "type":"object",
903 "properties":{
904 "name":name_schema,
905 "description":description_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200906 "datacenter": name_schema,
907 "scenario" : name_schema, #can be an UUID or name
tierno7edb6752016-03-21 17:37:52 +0100908 "action":{"enum": ["deploy","reserve","verify" ]},
garciadeblasfec35df2016-08-25 11:33:57 +0200909 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
910 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
tierno7edb6752016-03-21 17:37:52 +0100911 "vnfs":{ #mapping from scenario to datacenter
912 "type": "object",
913 "patternProperties":{
914 ".": {
915 "type": "object",
916 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200917 "name": name_schema, #override vnf name
garciadeblas0c317ee2016-08-29 12:33:06 +0200918 "datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200919 #"metadata": {"type": "object"},
920 #"user_data": {"type": "string"}
garciadeblas0c317ee2016-08-29 12:33:06 +0200921 #"cloud-config": cloud_config_schema, #particular for a vnf
garciadeblasfec35df2016-08-25 11:33:57 +0200922 "external-connections": {
923 "type": "object",
924 "patternProperties": {
925 ".": {
926 "type": "object",
927 "properties": {
928 "vim-network-name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200929 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200930 }
931 }
932 }
933 },
934 "internal-connections": {
935 "type": "object",
936 "patternProperties": {
937 ".": {
938 "type": "object",
939 "properties": {
940 "ip-profile": ip_profile_schema,
941 "elements": {
942 "type" : "array",
943 "items":{
944 "type":"object",
945 "properties":{
946 "VNFC": name_schema,
947 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200948 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200949 },
950 "required": ["VNFC", "local_iface_name"],
951 }
952 }
953 }
954 }
955 }
956 }
tierno7edb6752016-03-21 17:37:52 +0100957 }
958 }
959 },
960 },
961 "networks":{ #mapping from scenario to datacenter
962 "type": "object",
963 "patternProperties":{
964 ".": {
965 "type": "object",
966 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200967 "interfaces":{
968 "type":"array",
969 "minLength":1,
970 "items":{
971 "type":"object",
972 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200973 "ip_address": ip_schema,
974 "datacenter": name_schema,
975 "vim-network-name": name_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200976 },
977 "patternProperties":{
978 ".": {"type": "string"}
979 }
980 }
981 },
garciadeblasfec35df2016-08-25 11:33:57 +0200982 "ip-profile": ip_profile_schema,
tiernobe41e222016-09-02 15:16:13 +0200983 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
984 "sites": {
985 "type":"array",
986 "minLength":1,
987 "items":{
988 "type":"object",
989 "properties":{
990 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
991 # for other networks openamno creates at VIM
992 # Use netmap-create to force to create an external scenario network
993 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
994 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
995 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
996 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
997 #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)
998 "netmap-use": name_schema, #
999 "vim-network-name": name_schema, #override network name
1000 #"ip-profile": ip_profile_schema,
1001 "datacenter": name_schema,
1002 }
1003 }
1004 },
1005
1006
1007
tierno7edb6752016-03-21 17:37:52 +01001008 }
1009 }
1010 },
1011 },
1012 },
1013 "additionalProperties": False,
garciadeblasfec35df2016-08-25 11:33:57 +02001014 "required": ["name"]
tierno7edb6752016-03-21 17:37:52 +01001015 },
1016 },
1017 "required": ["instance"],
1018 "additionalProperties": False
tierno7edb6752016-03-21 17:37:52 +01001019}
1020
1021instance_scenario_action_schema = {
1022 "title":"instance scenario action information schema",
1023 "$schema": "http://json-schema.org/draft-04/schema#",
1024 "type":"object",
1025 "properties":{
1026 "start":{"type": "null"},
1027 "pause":{"type": "null"},
1028 "resume":{"type": "null"},
1029 "shutoff":{"type": "null"},
1030 "shutdown":{"type": "null"},
1031 "forceOff":{"type": "null"},
1032 "rebuild":{"type": "null"},
1033 "reboot":{
1034 "type": ["object","null"],
1035 },
1036 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1037 "vnfs":{"type": "array", "items":{"type":"string"}},
1038 "vms":{"type": "array", "items":{"type":"string"}}
1039 },
1040 "minProperties": 1,
1041 #"maxProperties": 1,
1042 "additionalProperties": False
1043}