blob: ffbacd3adb68428bf143d227f9e6f295b8bbbea2 [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"]}
garciadeblasb69fa9f2016-09-28 12:04:10 +020057checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"}
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,
82 "vnf_repository": path_schema,
83 "db_host": nameshort_schema,
84 "db_user": nameshort_schema,
85 "db_passwd": {"type":"string"},
86 "db_name": nameshort_schema,
87 # Next fields will disappear once the MANO API includes appropriate primitives
88 "vim_url": http_schema,
89 "vim_url_admin": http_schema,
90 "vim_name": nameshort_schema,
91 "vim_tenant_name": nameshort_schema,
92 "mano_tenant_name": nameshort_schema,
93 "mano_tenant_id": id_schema,
tierno20fc2a22016-08-19 17:02:35 +020094 "http_console_proxy": {"type":"boolean"},
95 "http_console_host": nameshort_schema,
tierno7edb6752016-03-21 17:37:52 +010096 "http_console_ports": {
97 "type": "array",
98 "items": {"OneOf" : [
99 port_schema,
100 {"type":"object", "properties":{"from": port_schema, "to": port_schema}, "required": ["from","to"]}
101 ]}
102 },
tiernoae4a8d12016-07-08 12:30:39 +0200103 "log_level": log_level_schema,
tierno72f35a52016-07-15 13:18:30 +0200104 "log_socket_level": log_level_schema,
tiernoae4a8d12016-07-08 12:30:39 +0200105 "log_level_db": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200106 "log_level_vim": log_level_schema,
tiernof97fd272016-07-11 14:32:37 +0200107 "log_level_nfvo": log_level_schema,
tierno73ad9e42016-09-12 18:11:11 +0200108 "log_level_http": log_level_schema,
109 "log_file_db": path_schema,
110 "log_file_vim": path_schema,
111 "log_file_nfvo": path_schema,
112 "log_file_http": path_schema,
tierno72f35a52016-07-15 13:18:30 +0200113 "log_socket_host": nameshort_schema,
114 "log_socket_port": port_schema,
tiernof97fd272016-07-11 14:32:37 +0200115 "log_file": path_schema,
tierno7edb6752016-03-21 17:37:52 +0100116 },
117 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
118 "additionalProperties": False
119}
120
121tenant_schema = {
122 "title":"tenant information schema",
123 "$schema": "http://json-schema.org/draft-04/schema#",
124 "type":"object",
125 "properties":{
126 "tenant":{
127 "type":"object",
128 "properties":{
129 "name": nameshort_schema,
130 "description": description_schema,
131 },
132 "required": ["name"],
133 "additionalProperties": True
134 }
135 },
136 "required": ["tenant"],
137 "additionalProperties": False
138}
garciadeblasfec35df2016-08-25 11:33:57 +0200139
tierno7edb6752016-03-21 17:37:52 +0100140tenant_edit_schema = {
141 "title":"tenant edit information schema",
142 "$schema": "http://json-schema.org/draft-04/schema#",
143 "type":"object",
144 "properties":{
145 "tenant":{
146 "type":"object",
147 "properties":{
148 "name": name_schema,
149 "description": description_schema,
150 },
151 "additionalProperties": False
152 }
153 },
154 "required": ["tenant"],
155 "additionalProperties": False
156}
157
158datacenter_schema_properties={
garciadeblasfec35df2016-08-25 11:33:57 +0200159 "name": name_schema,
160 "description": description_schema,
161 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
162 "vim_url": description_schema,
163 "vim_url_admin": description_schema,
164 "config": { "type":"object" }
165}
tierno7edb6752016-03-21 17:37:52 +0100166
167datacenter_schema = {
168 "title":"datacenter information schema",
169 "$schema": "http://json-schema.org/draft-04/schema#",
170 "type":"object",
171 "properties":{
172 "datacenter":{
173 "type":"object",
174 "properties":datacenter_schema_properties,
175 "required": ["name", "vim_url"],
176 "additionalProperties": True
177 }
178 },
179 "required": ["datacenter"],
180 "additionalProperties": False
181}
182
183
184datacenter_edit_schema = {
185 "title":"datacenter edit nformation schema",
186 "$schema": "http://json-schema.org/draft-04/schema#",
187 "type":"object",
188 "properties":{
189 "datacenter":{
190 "type":"object",
191 "properties":datacenter_schema_properties,
192 "additionalProperties": False
193 }
194 },
195 "required": ["datacenter"],
196 "additionalProperties": False
197}
198
199
200netmap_new_schema = {
201 "title":"netmap new information schema",
202 "$schema": "http://json-schema.org/draft-04/schema#",
203 "type":"object",
204 "properties":{
205 "netmap":{ #delete from datacenter
206 "type":"object",
207 "properties":{
208 "name": name_schema, #name or uuid of net to change
209 "vim_id": id_schema,
210 "vim_name": name_schema
211 },
212 "minProperties": 1,
213 "additionalProperties": False
214 },
215 },
216 "required": ["netmap"],
217 "additionalProperties": False
218}
219
220netmap_edit_schema = {
221 "title":"netmap edit information schema",
222 "$schema": "http://json-schema.org/draft-04/schema#",
223 "type":"object",
224 "properties":{
225 "netmap":{ #delete from datacenter
226 "type":"object",
227 "properties":{
228 "name": name_schema, #name or uuid of net to change
229 },
230 "minProperties": 1,
231 "additionalProperties": False
232 },
233 },
234 "required": ["netmap"],
235 "additionalProperties": False
236}
237
238datacenter_action_schema = {
239 "title":"datacenter action information schema",
240 "$schema": "http://json-schema.org/draft-04/schema#",
241 "type":"object",
242 "properties":{
243 "net-update":{"type":"null",},
244 "net-edit":{
245 "type":"object",
246 "properties":{
247 "net": name_schema, #name or uuid of net to change
248 "name": name_schema,
249 "description": description_schema,
250 "shared": {"type": "boolean"}
251 },
252 "minProperties": 1,
253 "additionalProperties": False
254 },
255 "net-delete":{
256 "type":"object",
257 "properties":{
258 "net": name_schema, #name or uuid of net to change
259 },
260 "required": ["net"],
261 "additionalProperties": False
262 },
263 },
264 "minProperties": 1,
265 "maxProperties": 1,
266 "additionalProperties": False
267}
268
269
270datacenter_associate_schema={
271 "title":"datacenter associate information schema",
272 "$schema": "http://json-schema.org/draft-04/schema#",
273 "type":"object",
274 "properties":{
275 "datacenter":{
276 "type":"object",
277 "properties":{
tierno8008c3a2016-10-13 15:34:28 +0000278 "vim_tenant": name_schema,
279 "vim_tenant_name": name_schema,
tierno7edb6752016-03-21 17:37:52 +0100280 "vim_username": nameshort_schema,
281 "vim_password": nameshort_schema,
tierno8008c3a2016-10-13 15:34:28 +0000282 "config": {"type": "object"}
tierno7edb6752016-03-21 17:37:52 +0100283 },
284# "required": ["vim_tenant"],
285 "additionalProperties": True
286 }
287 },
288 "required": ["datacenter"],
289 "additionalProperties": False
290}
291
garciadeblasfec35df2016-08-25 11:33:57 +0200292dhcp_schema = {
293 "title":"DHCP schema",
294 "$schema": "http://json-schema.org/draft-04/schema#",
295 "type":"object",
296 "properties":{
297 "enabled": {"type": "boolean"},
298 "start-address": ip_schema,
299 "count": integer1_schema
garciadeblas9f8456e2016-09-05 05:02:59 +0200300 },
301 "required": ["enabled", "start-address", "count"],
garciadeblasfec35df2016-08-25 11:33:57 +0200302}
303
304ip_profile_schema = {
305 "title":"IP profile schema",
306 "$schema": "http://json-schema.org/draft-04/schema#",
307 "type":"object",
308 "properties":{
309 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
310 "subnet-address": ip_prefix_schema,
311 "gateway-address": ip_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200312 "dns-address": ip_schema,
313 "dhcp": dhcp_schema
314 },
315}
316
317key_pair_schema = {
318 "title": "Key-pair schema for cloud-init configuration schema",
319 "$schema": "http://json-schema.org/draft-04/schema#",
320 "type":"object",
321 "properties":{
322 "name": name_schema,
323 "key": {"type":"string"}
324 },
325 "required": ["key"],
326 "additionalProperties": False
327}
328
329cloud_config_user_schema = {
330 "title": "User schema for cloud-init configuration schema",
331 "$schema": "http://json-schema.org/draft-04/schema#",
332 "type":"object",
333 "properties":{
334 "name": nameshort_schema,
335 "user-info": {"type":"string"},
336 #"key-pairs": {"type" : "array", "items": key_pair_schema}
337 "key-pairs": {"type" : "array", "items": {"type":"string"}}
338 },
339 "required": ["name"],
340 "additionalProperties": False
341}
342
343cloud_config_schema = {
344 "title": "Cloud-init configuration schema",
345 "$schema": "http://json-schema.org/draft-04/schema#",
346 "type":"object",
347 "properties":{
348 #"key-pairs": {"type" : "array", "items": key_pair_schema},
349 "key-pairs": {"type" : "array", "items": {"type":"string"}},
350 "users": {"type" : "array", "items": cloud_config_user_schema}
351 },
352 "additionalProperties": False
353}
354
tierno7edb6752016-03-21 17:37:52 +0100355internal_connection_element_schema = {
356 "type":"object",
357 "properties":{
358 "VNFC": name_schema,
359 "local_iface_name": name_schema
360 }
361}
362
garciadeblasfec35df2016-08-25 11:33:57 +0200363internal_connection_element_schema_v02 = {
364 "type":"object",
365 "properties":{
366 "VNFC": name_schema,
367 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200368 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200369 }
370}
371
tierno7edb6752016-03-21 17:37:52 +0100372internal_connection_schema = {
373 "type":"object",
374 "properties":{
375 "name": name_schema,
376 "description":description_schema,
377 "type":{"type":"string", "enum":["bridge","data","ptp"]},
378 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
379 },
380 "required": ["name", "type", "elements"],
381 "additionalProperties": False
382}
383
garciadeblasfec35df2016-08-25 11:33:57 +0200384internal_connection_schema_v02 = {
385 "type":"object",
386 "properties":{
387 "name": name_schema,
388 "description":description_schema,
389 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200390 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200391 "ip-profile": ip_profile_schema,
392 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":2}
393 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200394 "required": ["name", "type", "implementation", "elements"],
garciadeblasfec35df2016-08-25 11:33:57 +0200395 "additionalProperties": False
396}
397
tierno7edb6752016-03-21 17:37:52 +0100398external_connection_schema = {
399 "type":"object",
400 "properties":{
401 "name": name_schema,
402 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
403 "VNFC": name_schema,
404 "local_iface_name": name_schema ,
405 "description":description_schema
406 },
407 "required": ["name", "type", "VNFC", "local_iface_name"],
408 "additionalProperties": False
409}
410
garciadeblas9f8456e2016-09-05 05:02:59 +0200411#Not yet used
garciadeblasfec35df2016-08-25 11:33:57 +0200412external_connection_schema_v02 = {
413 "type":"object",
414 "properties":{
415 "name": name_schema,
garciadeblas9f8456e2016-09-05 05:02:59 +0200416 "mgmt": {"type":"boolean"},
417 "type": {"type": "string", "enum":["e-line", "e-lan"]},
418 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200419 "VNFC": name_schema,
420 "local_iface_name": name_schema ,
421 "description":description_schema
422 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200423 "required": ["name", "type", "VNFC", "local_iface_name"],
garciadeblasfec35df2016-08-25 11:33:57 +0200424 "additionalProperties": False
425}
426
tierno7edb6752016-03-21 17:37:52 +0100427interfaces_schema={
428 "type":"array",
429 "items":{
430 "type":"object",
431 "properties":{
432 "name":name_schema,
433 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
434 "bandwidth":bandwidth_schema,
435 "vpci":pci_schema,
436 "mac_address": mac_schema
437 },
438 "additionalProperties": False,
439 "required": ["name","dedicated", "bandwidth"]
440 }
441}
442
443bridge_interfaces_schema={
444 "type":"array",
445 "items":{
446 "type":"object",
447 "properties":{
448 "name": name_schema,
449 "bandwidth":bandwidth_schema,
450 "vpci":pci_schema,
451 "mac_address": mac_schema,
452 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
453 },
454 "additionalProperties": False,
455 "required": ["name"]
456 }
457}
458
459devices_schema={
460 "type":"array",
461 "items":{
462 "type":"object",
463 "properties":{
464 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
465 "image": path_schema,
garciadeblasb69fa9f2016-09-28 12:04:10 +0200466 "image name": name_schema,
467 "image checksum": checksum_schema,
tierno7edb6752016-03-21 17:37:52 +0100468 "image metadata": metadata_schema,
469 "vpci":pci_schema,
470 "xml":xml_text_schema,
471 },
472 "additionalProperties": False,
473 "required": ["type"]
474 }
475}
476
477
478numa_schema = {
479 "type": "object",
480 "properties": {
481 "memory":integer1_schema,
482 "cores":integer1_schema,
483 "paired-threads":integer1_schema,
484 "threads":integer1_schema,
485 "cores-id":{"type":"array","items":integer0_schema},
486 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
487 "threads-id":{"type":"array","items":integer0_schema},
488 "interfaces":interfaces_schema
489 },
490 "additionalProperties": False,
491 #"required": ["memory"]
492}
493
494vnfc_schema = {
495 "type":"object",
496 "properties":{
497 "name": name_schema,
498 "description": description_schema,
499 "VNFC image": {"oneOf": [path_schema, http_schema]},
garciadeblasb69fa9f2016-09-28 12:04:10 +0200500 "image name": name_schema,
501 "image checksum": checksum_schema,
tierno7edb6752016-03-21 17:37:52 +0100502 "image metadata": metadata_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200503 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
tierno7edb6752016-03-21 17:37:52 +0100504 "processor": {
505 "type":"object",
506 "properties":{
507 "model":description_schema,
508 "features":{"type":"array","items":nameshort_schema}
509 },
510 "required": ["model"],
511 "additionalProperties": False
512 },
513 "hypervisor": {
514 "type":"object",
515 "properties":{
516 "type":nameshort_schema,
517 "version":description_schema
518 },
519 },
520 "ram":integer0_schema,
521 "vcpus":integer0_schema,
522 "disk": integer1_schema,
523 "numas": {
524 "type": "array",
garciadeblasfec35df2016-08-25 11:33:57 +0200525 "items": numa_schema
tierno7edb6752016-03-21 17:37:52 +0100526 },
527 "bridge-ifaces": bridge_interfaces_schema,
528 "devices": devices_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200529
tierno7edb6752016-03-21 17:37:52 +0100530 },
garciadeblasb69fa9f2016-09-28 12:04:10 +0200531 "required": ["name"],
532 "oneOf": [
533 {"required": ["VNFC image"]},
534 {"required": ["image name"]}
535 ],
tierno7edb6752016-03-21 17:37:52 +0100536 "additionalProperties": False
537}
538
539vnfd_schema_v01 = {
540 "title":"vnfd information schema v0.1",
541 "$schema": "http://json-schema.org/draft-04/schema#",
542 "type":"object",
543 "properties":{
544 "vnf":{
545 "type":"object",
546 "properties":{
547 "name": name_schema,
548 "description": description_schema,
549 "class": nameshort_schema,
550 "public": {"type" : "boolean"},
551 "physical": {"type" : "boolean"},
552 "tenant_id": id_schema, #only valid for admin
553 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
554 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
555 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
556 },
557 "required": ["name","external-connections"],
558 "additionalProperties": True
559 }
560 },
561 "required": ["vnf"],
562 "additionalProperties": False
563}
564
garciadeblasfec35df2016-08-25 11:33:57 +0200565#VNFD schema for OSM R1
tierno7edb6752016-03-21 17:37:52 +0100566vnfd_schema_v02 = {
567 "title":"vnfd information schema v0.2",
568 "$schema": "http://json-schema.org/draft-04/schema#",
569 "type":"object",
570 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200571 "schema_version": {"type": "string", "enum": ["0.2"]},
tierno7edb6752016-03-21 17:37:52 +0100572 "vnf":{
573 "type":"object",
574 "properties":{
575 "name": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200576 "description": description_schema,
577 "class": nameshort_schema,
578 "public": {"type" : "boolean"},
579 "physical": {"type" : "boolean"},
580 "tenant_id": id_schema, #only valid for admin
garciadeblas9f8456e2016-09-05 05:02:59 +0200581 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
garciadeblasfec35df2016-08-25 11:33:57 +0200582 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
583 # "cloud-config": cloud_config_schema, #common for all vnfcs
584 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
tierno7edb6752016-03-21 17:37:52 +0100585 },
586 "required": ["name"],
587 "additionalProperties": True
588 }
589 },
tierno392f2852016-05-13 12:28:55 +0200590 "required": ["vnf", "schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100591 "additionalProperties": False
592}
593
594#vnfd_schema = vnfd_schema_v01
595#{
596# "title":"vnfd information schema v0.2",
597# "$schema": "http://json-schema.org/draft-04/schema#",
598# "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
599#}
600
601graph_schema = {
602 "title":"graphical scenario descriptor information schema",
603 "$schema": "http://json-schema.org/draft-04/schema#",
604 "type":"object",
605 "properties":{
606 "x": integer0_schema,
607 "y": integer0_schema,
608 "ifaces": {
609 "type":"object",
610 "properties":{
611 "left": {"type":"array"},
612 "right": {"type":"array"},
613 "bottom": {"type":"array"},
614 }
615 }
616 },
617 "required": ["x","y"]
618}
619
620nsd_schema_v01 = {
621 "title":"network scenario descriptor information schema v0.1",
622 "$schema": "http://json-schema.org/draft-04/schema#",
623 "type":"object",
624 "properties":{
625 "name":name_schema,
626 "description": description_schema,
627 "tenant_id": id_schema, #only valid for admin
tierno392f2852016-05-13 12:28:55 +0200628 "public": {"type": "boolean"},
tierno7edb6752016-03-21 17:37:52 +0100629 "topology":{
630 "type":"object",
631 "properties":{
632 "nodes": {
633 "type":"object",
634 "patternProperties":{
635 ".": {
636 "type": "object",
637 "properties":{
638 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
639 "vnf_id": id_schema,
640 "graph": graph_schema,
641 },
642 "patternProperties":{
643 "^(VNF )?model$": {"type": "string"}
644 },
645 "required": ["type"]
646 }
647 }
648 },
649 "connections": {
650 "type":"object",
651 "patternProperties":{
652 ".": {
653 "type": "object",
654 "properties":{
655 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
656 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
657 "graph": graph_schema
658 },
659 "required": ["nodes"]
660 },
661 }
662 }
663 },
664 "required": ["nodes"],
665 "additionalProperties": False
666 }
667 },
668 "required": ["name","topology"],
669 "additionalProperties": False
670}
671
tierno7edb6752016-03-21 17:37:52 +0100672nsd_schema_v02 = {
673 "title":"network scenario descriptor information schema v0.2",
674 "$schema": "http://json-schema.org/draft-04/schema#",
675 "type":"object",
676 "properties":{
garciadeblas0c317ee2016-08-29 12:33:06 +0200677 "schema_version": schema_version_2,
tierno392f2852016-05-13 12:28:55 +0200678 "scenario":{
tierno7edb6752016-03-21 17:37:52 +0100679 "type":"object",
tierno392f2852016-05-13 12:28:55 +0200680 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200681 "name": name_schema,
tierno392f2852016-05-13 12:28:55 +0200682 "description": description_schema,
683 "tenant_id": id_schema, #only valid for admin
684 "public": {"type": "boolean"},
685 "vnfs": {
686 "type":"object",
687 "patternProperties":{
688 ".": {
689 "type": "object",
690 "properties":{
691 "vnf_id": id_schema,
692 "graph": graph_schema,
693 "vnf_name": name_schema,
694 },
695 }
tierno7edb6752016-03-21 17:37:52 +0100696 },
tierno392f2852016-05-13 12:28:55 +0200697 "minProperties": 1
tierno7edb6752016-03-21 17:37:52 +0100698 },
tierno392f2852016-05-13 12:28:55 +0200699 "networks": {
700 "type":"object",
701 "patternProperties":{
702 ".": {
703 "type": "object",
704 "properties":{
705 "interfaces":{"type":"array", "minLength":1},
706 "type": {"type": "string", "enum":["dataplane", "bridge"]},
707 "external" : {"type": "boolean"},
708 "graph": graph_schema
709 },
710 "required": ["interfaces"]
711 },
712 }
713 },
714
715 },
garciadeblasfec35df2016-08-25 11:33:57 +0200716 "required": ["vnfs", "name"],
717 "additionalProperties": False
718 }
719 },
720 "required": ["scenario","schema_version"],
721 "additionalProperties": False
722}
723
724#NSD schema for OSM R1
725nsd_schema_v03 = {
726 "title":"network scenario descriptor information schema v0.3",
727 "$schema": "http://json-schema.org/draft-04/schema#",
728 "type":"object",
729 "properties":{
730 "schema_version": {"type": "string", "enum": ["0.3"]},
731 "scenario":{
732 "type":"object",
733 "properties":{
734 "name": name_schema,
735 "description": description_schema,
736 "tenant_id": id_schema, #only valid for admin
737 "public": {"type": "boolean"},
738 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
garciadeblas0c317ee2016-08-29 12:33:06 +0200739 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200740 "vnfs": {
741 "type":"object",
742 "patternProperties":{
743 ".": {
744 "type": "object",
745 "properties":{
746 "vnf_id": id_schema,
747 "graph": graph_schema,
748 "vnf_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200749 #"cloud-config": cloud_config_schema, #particular for a vnf
750 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200751 "internal-connections": {
752 "type": "object",
753 "patternProperties": {
754 ".": {
755 "type": "object",
756 "properties": {
757 "ip-profile": ip_profile_schema,
758 "elements": {
759 "type" : "array",
760 "items":{
761 "type":"object",
762 "properties":{
763 "VNFC": name_schema,
764 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200765 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200766 },
767 "required": ["VNFC", "local_iface_name"],
768 }
769 }
770 }
771 }
772 }
773 }
774 },
775 }
776 },
777 "minProperties": 1
778 },
779 "networks": {
780 "type":"object",
781 "patternProperties":{
782 ".": {
783 "type": "object",
784 "properties":{
785 "interfaces":{
786 "type":"array",
787 "minLength":1,
788 "items":{
789 "type":"object",
790 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200791 "vnf": name_schema,
792 "vnf_interface": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200793 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200794 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200795 "required": ["vnf", "vnf_interface"],
garciadeblasfec35df2016-08-25 11:33:57 +0200796 }
797 },
798 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200799 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200800 "external" : {"type": "boolean"},
801 "graph": graph_schema,
802 "ip-profile": ip_profile_schema
803 },
804 "required": ["interfaces"]
805 },
806 }
807 },
808
809 },
tierno392f2852016-05-13 12:28:55 +0200810 "required": ["vnfs", "networks","name"],
811 "additionalProperties": False
812 }
tierno7edb6752016-03-21 17:37:52 +0100813 },
tierno392f2852016-05-13 12:28:55 +0200814 "required": ["scenario","schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100815 "additionalProperties": False
816}
817
818#scenario_new_schema = {
819# "title":"new scenario information schema",
820# "$schema": "http://json-schema.org/draft-04/schema#",
821# #"oneOf": [nsd_schema_v01, nsd_schema_v02]
822# "oneOf": [nsd_schema_v01]
823#}
824
825scenario_edit_schema = {
826 "title":"edit scenario information schema",
827 "$schema": "http://json-schema.org/draft-04/schema#",
828 "type":"object",
829 "properties":{
830 "name":name_schema,
831 "description": description_schema,
832 "topology":{
833 "type":"object",
834 "properties":{
835 "nodes": {
836 "type":"object",
837 "patternProperties":{
838 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
839 "type":"object",
840 "properties":{
841 "graph":{
842 "type": "object",
843 "properties":{
844 "x": integer0_schema,
845 "y": integer0_schema,
846 "ifaces":{ "type": "object"}
847 }
848 },
849 "description": description_schema,
850 "name": name_schema
851 }
852 }
853 }
854 }
855 },
856 "required": ["nodes"],
857 "additionalProperties": False
858 }
859 },
860 "additionalProperties": False
861}
862
863scenario_action_schema = {
864 "title":"scenario action information schema",
865 "$schema": "http://json-schema.org/draft-04/schema#",
866 "type":"object",
867 "properties":{
868 "start":{
869 "type": "object",
870 "properties": {
871 "instance_name":name_schema,
872 "description":description_schema,
873 "datacenter": {"type": "string"}
874 },
875 "required": ["instance_name"]
876 },
877 "deploy":{
878 "type": "object",
879 "properties": {
880 "instance_name":name_schema,
881 "description":description_schema,
882 "datacenter": {"type": "string"}
883 },
884 "required": ["instance_name"]
885 },
886 "reserve":{
887 "type": "object",
888 "properties": {
889 "instance_name":name_schema,
890 "description":description_schema,
891 "datacenter": {"type": "string"}
892 },
893 "required": ["instance_name"]
894 },
895 "verify":{
896 "type": "object",
897 "properties": {
898 "instance_name":name_schema,
899 "description":description_schema,
900 "datacenter": {"type": "string"}
901 },
902 "required": ["instance_name"]
903 }
904 },
905 "minProperties": 1,
906 "maxProperties": 1,
907 "additionalProperties": False
908}
909
garciadeblasfec35df2016-08-25 11:33:57 +0200910instance_scenario_create_schema_v01 = {
tierno7edb6752016-03-21 17:37:52 +0100911 "title":"instance scenario create information schema v0.1",
912 "$schema": "http://json-schema.org/draft-04/schema#",
913 "type":"object",
914 "properties":{
915 "schema_version": {"type": "string", "enum": ["0.1"]},
916 "instance":{
917 "type":"object",
918 "properties":{
919 "name":name_schema,
920 "description":description_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200921 "datacenter": name_schema,
922 "scenario" : name_schema, #can be an UUID or name
tierno7edb6752016-03-21 17:37:52 +0100923 "action":{"enum": ["deploy","reserve","verify" ]},
garciadeblasfec35df2016-08-25 11:33:57 +0200924 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
925 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
tierno7edb6752016-03-21 17:37:52 +0100926 "vnfs":{ #mapping from scenario to datacenter
927 "type": "object",
928 "patternProperties":{
929 ".": {
930 "type": "object",
931 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200932 "name": name_schema, #override vnf name
garciadeblas0c317ee2016-08-29 12:33:06 +0200933 "datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200934 #"metadata": {"type": "object"},
935 #"user_data": {"type": "string"}
garciadeblas0c317ee2016-08-29 12:33:06 +0200936 #"cloud-config": cloud_config_schema, #particular for a vnf
garciadeblasfec35df2016-08-25 11:33:57 +0200937 "external-connections": {
938 "type": "object",
939 "patternProperties": {
940 ".": {
941 "type": "object",
942 "properties": {
943 "vim-network-name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200944 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200945 }
946 }
947 }
948 },
949 "internal-connections": {
950 "type": "object",
951 "patternProperties": {
952 ".": {
953 "type": "object",
954 "properties": {
955 "ip-profile": ip_profile_schema,
956 "elements": {
957 "type" : "array",
958 "items":{
959 "type":"object",
960 "properties":{
961 "VNFC": name_schema,
962 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200963 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200964 },
965 "required": ["VNFC", "local_iface_name"],
966 }
967 }
968 }
969 }
970 }
971 }
tierno7edb6752016-03-21 17:37:52 +0100972 }
973 }
974 },
975 },
976 "networks":{ #mapping from scenario to datacenter
977 "type": "object",
978 "patternProperties":{
979 ".": {
980 "type": "object",
981 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200982 "interfaces":{
983 "type":"array",
984 "minLength":1,
985 "items":{
986 "type":"object",
987 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200988 "ip_address": ip_schema,
989 "datacenter": name_schema,
990 "vim-network-name": name_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200991 },
992 "patternProperties":{
993 ".": {"type": "string"}
994 }
995 }
996 },
garciadeblasfec35df2016-08-25 11:33:57 +0200997 "ip-profile": ip_profile_schema,
tiernobe41e222016-09-02 15:16:13 +0200998 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
999 "sites": {
1000 "type":"array",
1001 "minLength":1,
1002 "items":{
1003 "type":"object",
1004 "properties":{
1005 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
1006 # for other networks openamno creates at VIM
1007 # Use netmap-create to force to create an external scenario network
1008 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
1009 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
1010 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
1011 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
1012 #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)
1013 "netmap-use": name_schema, #
1014 "vim-network-name": name_schema, #override network name
1015 #"ip-profile": ip_profile_schema,
1016 "datacenter": name_schema,
1017 }
1018 }
1019 },
1020
1021
1022
tierno7edb6752016-03-21 17:37:52 +01001023 }
1024 }
1025 },
1026 },
1027 },
1028 "additionalProperties": False,
garciadeblasfec35df2016-08-25 11:33:57 +02001029 "required": ["name"]
tierno7edb6752016-03-21 17:37:52 +01001030 },
1031 },
1032 "required": ["instance"],
1033 "additionalProperties": False
tierno7edb6752016-03-21 17:37:52 +01001034}
1035
1036instance_scenario_action_schema = {
1037 "title":"instance scenario action information schema",
1038 "$schema": "http://json-schema.org/draft-04/schema#",
1039 "type":"object",
1040 "properties":{
1041 "start":{"type": "null"},
1042 "pause":{"type": "null"},
1043 "resume":{"type": "null"},
1044 "shutoff":{"type": "null"},
1045 "shutdown":{"type": "null"},
1046 "forceOff":{"type": "null"},
1047 "rebuild":{"type": "null"},
1048 "reboot":{
1049 "type": ["object","null"],
1050 },
1051 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1052 "vnfs":{"type": "array", "items":{"type":"string"}},
1053 "vms":{"type": "array", "items":{"type":"string"}}
1054 },
1055 "minProperties": 1,
1056 #"maxProperties": 1,
1057 "additionalProperties": False
1058}