blob: 013234f5ff6c061c1c45dc158b0bcf01a0d09873 [file] [log] [blame]
tierno7edb6752016-03-21 17:37:52 +01001# -*- coding: utf-8 -*-
2
3##
4# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5# This file is part of openmano
6# All Rights Reserved.
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License. You may obtain
10# a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17# License for the specific language governing permissions and limitations
18# under the License.
19#
20# For those usages not covered by the Apache License, Version 2.0 please
21# contact with: nfvlabs@tid.es
22##
23
24'''
25JSON schemas used by openmano httpserver.py module to parse the different files and messages sent through the API
26'''
montesmoreno0c8def02016-12-22 12:16:23 +000027__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
tierno7edb6752016-03-21 17:37:52 +010028__date__ ="$09-oct-2014 09:09:48$"
29
30#Basis schemas
tierno392f2852016-05-13 12:28:55 +020031patern_name="^[ -~]+$"
tierno7edb6752016-03-21 17:37:52 +010032passwd_schema={"type" : "string", "minLength":1, "maxLength":60}
33nameshort_schema={"type" : "string", "minLength":1, "maxLength":60, "pattern" : "^[^,;()'\"]+$"}
34name_schema={"type" : "string", "minLength":1, "maxLength":255, "pattern" : "^[^,;()'\"]+$"}
35xml_text_schema={"type" : "string", "minLength":1, "maxLength":1000, "pattern" : "^[^']+$"}
36description_schema={"type" : ["string","null"], "maxLength":255, "pattern" : "^[^'\"]+$"}
37id_schema_fake = {"type" : "string", "minLength":2, "maxLength":36 } #"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
38id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
39pci_schema={"type":"string", "pattern":"^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
40http_schema={"type":"string", "pattern":"^https?://[^'\"=]+$"}
41bandwidth_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]bps)?$"}
42memory_schema={"type":"string", "pattern" : "^[0-9]+ *([MG]i?[Bb])?$"}
43integer0_schema={"type":"integer","minimum":0}
44integer1_schema={"type":"integer","minimum":1}
tierno392f2852016-05-13 12:28:55 +020045path_schema={"type":"string", "pattern":"^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
tierno7edb6752016-03-21 17:37:52 +010046vlan_schema={"type":"integer","minimum":1,"maximum":4095}
47vlan1000_schema={"type":"integer","minimum":1000,"maximum":4095}
48mac_schema={"type":"string", "pattern":"^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$"} #must be unicast LSB bit of MSB byte ==0
49#mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
garciadeblasfec35df2016-08-25 11:33:57 +020050ip_schema={"type":"string","pattern":"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"}
51ip_prefix_schema={"type":"string","pattern":"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$"}
tierno7edb6752016-03-21 17:37:52 +010052port_schema={"type":"integer","minimum":1,"maximum":65534}
53object_schema={"type":"object"}
tierno392f2852016-05-13 12:28:55 +020054schema_version_2={"type":"integer","minimum":2,"maximum":2}
garciadeblasfec35df2016-08-25 11:33:57 +020055#schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]}
tiernoae4a8d12016-07-08 12:30:39 +020056log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]}
garciadeblasb69fa9f2016-09-28 12:04:10 +020057checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"}
montesmoreno0c8def02016-12-22 12:16:23 +000058size_schema={"type":"integer","minimum":1,"maximum":100}
tierno7edb6752016-03-21 17:37:52 +010059
60metadata_schema={
61 "type":"object",
62 "properties":{
63 "architecture": {"type":"string"},
64 "use_incremental": {"type":"string","enum":["yes","no"]},
65 "vpci": pci_schema,
66 "os_distro": {"type":"string"},
67 "os_type": {"type":"string"},
68 "os_version": {"type":"string"},
69 "bus": {"type":"string"},
70 "topology": {"type":"string", "enum": ["oneSocket"]}
71 }
72}
73
74#Schema for the configuration file
75config_schema = {
76 "title":"configuration response information schema",
77 "$schema": "http://json-schema.org/draft-04/schema#",
78 "type":"object",
79 "properties":{
80 "http_port": port_schema,
81 "http_admin_port": port_schema,
82 "http_host": nameshort_schema,
83 "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,
110 "log_file_db": path_schema,
111 "log_file_vim": path_schema,
112 "log_file_nfvo": path_schema,
113 "log_file_http": path_schema,
tierno72f35a52016-07-15 13:18:30 +0200114 "log_socket_host": nameshort_schema,
115 "log_socket_port": port_schema,
tiernof97fd272016-07-11 14:32:37 +0200116 "log_file": path_schema,
tierno7edb6752016-03-21 17:37:52 +0100117 },
118 "required": ['db_host', 'db_user', 'db_passwd', 'db_name'],
119 "additionalProperties": False
120}
121
122tenant_schema = {
123 "title":"tenant information schema",
124 "$schema": "http://json-schema.org/draft-04/schema#",
125 "type":"object",
126 "properties":{
127 "tenant":{
128 "type":"object",
129 "properties":{
130 "name": nameshort_schema,
131 "description": description_schema,
132 },
133 "required": ["name"],
134 "additionalProperties": True
135 }
136 },
137 "required": ["tenant"],
138 "additionalProperties": False
139}
garciadeblasfec35df2016-08-25 11:33:57 +0200140
tierno7edb6752016-03-21 17:37:52 +0100141tenant_edit_schema = {
142 "title":"tenant edit information schema",
143 "$schema": "http://json-schema.org/draft-04/schema#",
144 "type":"object",
145 "properties":{
146 "tenant":{
147 "type":"object",
148 "properties":{
149 "name": name_schema,
150 "description": description_schema,
151 },
152 "additionalProperties": False
153 }
154 },
155 "required": ["tenant"],
156 "additionalProperties": False
157}
158
159datacenter_schema_properties={
garciadeblasfec35df2016-08-25 11:33:57 +0200160 "name": name_schema,
161 "description": description_schema,
162 "type": nameshort_schema, #currently "openvim" or "openstack", can be enlarged with plugins
163 "vim_url": description_schema,
164 "vim_url_admin": description_schema,
165 "config": { "type":"object" }
166}
tierno7edb6752016-03-21 17:37:52 +0100167
168datacenter_schema = {
169 "title":"datacenter information schema",
170 "$schema": "http://json-schema.org/draft-04/schema#",
171 "type":"object",
172 "properties":{
173 "datacenter":{
174 "type":"object",
175 "properties":datacenter_schema_properties,
176 "required": ["name", "vim_url"],
177 "additionalProperties": True
178 }
179 },
180 "required": ["datacenter"],
181 "additionalProperties": False
182}
183
184
185datacenter_edit_schema = {
186 "title":"datacenter edit nformation schema",
187 "$schema": "http://json-schema.org/draft-04/schema#",
188 "type":"object",
189 "properties":{
190 "datacenter":{
191 "type":"object",
192 "properties":datacenter_schema_properties,
193 "additionalProperties": False
194 }
195 },
196 "required": ["datacenter"],
197 "additionalProperties": False
198}
199
200
201netmap_new_schema = {
202 "title":"netmap new information schema",
203 "$schema": "http://json-schema.org/draft-04/schema#",
204 "type":"object",
205 "properties":{
206 "netmap":{ #delete from datacenter
207 "type":"object",
208 "properties":{
209 "name": name_schema, #name or uuid of net to change
210 "vim_id": id_schema,
211 "vim_name": name_schema
212 },
213 "minProperties": 1,
214 "additionalProperties": False
215 },
216 },
217 "required": ["netmap"],
218 "additionalProperties": False
219}
220
221netmap_edit_schema = {
222 "title":"netmap edit information schema",
223 "$schema": "http://json-schema.org/draft-04/schema#",
224 "type":"object",
225 "properties":{
226 "netmap":{ #delete from datacenter
227 "type":"object",
228 "properties":{
229 "name": name_schema, #name or uuid of net to change
230 },
231 "minProperties": 1,
232 "additionalProperties": False
233 },
234 },
235 "required": ["netmap"],
236 "additionalProperties": False
237}
238
239datacenter_action_schema = {
240 "title":"datacenter action information schema",
241 "$schema": "http://json-schema.org/draft-04/schema#",
242 "type":"object",
243 "properties":{
244 "net-update":{"type":"null",},
245 "net-edit":{
246 "type":"object",
247 "properties":{
248 "net": name_schema, #name or uuid of net to change
249 "name": name_schema,
250 "description": description_schema,
251 "shared": {"type": "boolean"}
252 },
253 "minProperties": 1,
254 "additionalProperties": False
255 },
256 "net-delete":{
257 "type":"object",
258 "properties":{
259 "net": name_schema, #name or uuid of net to change
260 },
261 "required": ["net"],
262 "additionalProperties": False
263 },
264 },
265 "minProperties": 1,
266 "maxProperties": 1,
267 "additionalProperties": False
268}
269
270
271datacenter_associate_schema={
272 "title":"datacenter associate information schema",
273 "$schema": "http://json-schema.org/draft-04/schema#",
274 "type":"object",
275 "properties":{
276 "datacenter":{
277 "type":"object",
278 "properties":{
tierno8008c3a2016-10-13 15:34:28 +0000279 "vim_tenant": name_schema,
280 "vim_tenant_name": name_schema,
tierno7edb6752016-03-21 17:37:52 +0100281 "vim_username": nameshort_schema,
282 "vim_password": nameshort_schema,
tierno8008c3a2016-10-13 15:34:28 +0000283 "config": {"type": "object"}
tierno7edb6752016-03-21 17:37:52 +0100284 },
285# "required": ["vim_tenant"],
286 "additionalProperties": True
287 }
288 },
289 "required": ["datacenter"],
290 "additionalProperties": False
291}
292
garciadeblasfec35df2016-08-25 11:33:57 +0200293dhcp_schema = {
294 "title":"DHCP schema",
295 "$schema": "http://json-schema.org/draft-04/schema#",
296 "type":"object",
297 "properties":{
298 "enabled": {"type": "boolean"},
299 "start-address": ip_schema,
300 "count": integer1_schema
garciadeblas9f8456e2016-09-05 05:02:59 +0200301 },
302 "required": ["enabled", "start-address", "count"],
garciadeblasfec35df2016-08-25 11:33:57 +0200303}
304
305ip_profile_schema = {
306 "title":"IP profile schema",
307 "$schema": "http://json-schema.org/draft-04/schema#",
308 "type":"object",
309 "properties":{
310 "ip-version": {"type":"string", "enum":["IPv4","IPv6"]},
311 "subnet-address": ip_prefix_schema,
312 "gateway-address": ip_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200313 "dns-address": ip_schema,
314 "dhcp": dhcp_schema
315 },
316}
317
318key_pair_schema = {
319 "title": "Key-pair schema for cloud-init configuration schema",
320 "$schema": "http://json-schema.org/draft-04/schema#",
321 "type":"object",
322 "properties":{
323 "name": name_schema,
324 "key": {"type":"string"}
325 },
326 "required": ["key"],
327 "additionalProperties": False
328}
329
330cloud_config_user_schema = {
331 "title": "User schema for cloud-init configuration schema",
332 "$schema": "http://json-schema.org/draft-04/schema#",
333 "type":"object",
334 "properties":{
335 "name": nameshort_schema,
336 "user-info": {"type":"string"},
337 #"key-pairs": {"type" : "array", "items": key_pair_schema}
338 "key-pairs": {"type" : "array", "items": {"type":"string"}}
339 },
340 "required": ["name"],
341 "additionalProperties": False
342}
343
344cloud_config_schema = {
345 "title": "Cloud-init configuration schema",
346 "$schema": "http://json-schema.org/draft-04/schema#",
347 "type":"object",
348 "properties":{
349 #"key-pairs": {"type" : "array", "items": key_pair_schema},
350 "key-pairs": {"type" : "array", "items": {"type":"string"}},
351 "users": {"type" : "array", "items": cloud_config_user_schema}
352 },
353 "additionalProperties": False
354}
355
tierno7edb6752016-03-21 17:37:52 +0100356internal_connection_element_schema = {
357 "type":"object",
358 "properties":{
359 "VNFC": name_schema,
360 "local_iface_name": name_schema
361 }
362}
363
garciadeblasfec35df2016-08-25 11:33:57 +0200364internal_connection_element_schema_v02 = {
365 "type":"object",
366 "properties":{
367 "VNFC": name_schema,
368 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200369 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200370 }
371}
372
tierno7edb6752016-03-21 17:37:52 +0100373internal_connection_schema = {
374 "type":"object",
375 "properties":{
376 "name": name_schema,
377 "description":description_schema,
378 "type":{"type":"string", "enum":["bridge","data","ptp"]},
379 "elements": {"type" : "array", "items": internal_connection_element_schema, "minItems":2}
380 },
381 "required": ["name", "type", "elements"],
382 "additionalProperties": False
383}
384
garciadeblasfec35df2016-08-25 11:33:57 +0200385internal_connection_schema_v02 = {
386 "type":"object",
387 "properties":{
388 "name": name_schema,
389 "description":description_schema,
390 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200391 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200392 "ip-profile": ip_profile_schema,
393 "elements": {"type" : "array", "items": internal_connection_element_schema_v02, "minItems":2}
394 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200395 "required": ["name", "type", "implementation", "elements"],
garciadeblasfec35df2016-08-25 11:33:57 +0200396 "additionalProperties": False
397}
398
tierno7edb6752016-03-21 17:37:52 +0100399external_connection_schema = {
400 "type":"object",
401 "properties":{
402 "name": name_schema,
403 "type":{"type":"string", "enum":["mgmt","bridge","data"]},
404 "VNFC": name_schema,
405 "local_iface_name": name_schema ,
406 "description":description_schema
407 },
408 "required": ["name", "type", "VNFC", "local_iface_name"],
409 "additionalProperties": False
410}
411
garciadeblas9f8456e2016-09-05 05:02:59 +0200412#Not yet used
garciadeblasfec35df2016-08-25 11:33:57 +0200413external_connection_schema_v02 = {
414 "type":"object",
415 "properties":{
416 "name": name_schema,
garciadeblas9f8456e2016-09-05 05:02:59 +0200417 "mgmt": {"type":"boolean"},
418 "type": {"type": "string", "enum":["e-line", "e-lan"]},
419 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200420 "VNFC": name_schema,
421 "local_iface_name": name_schema ,
422 "description":description_schema
423 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200424 "required": ["name", "type", "VNFC", "local_iface_name"],
garciadeblasfec35df2016-08-25 11:33:57 +0200425 "additionalProperties": False
426}
427
tierno7edb6752016-03-21 17:37:52 +0100428interfaces_schema={
429 "type":"array",
430 "items":{
431 "type":"object",
432 "properties":{
433 "name":name_schema,
434 "dedicated":{"type":"string","enum":["yes","no","yes:sriov"]},
435 "bandwidth":bandwidth_schema,
436 "vpci":pci_schema,
437 "mac_address": mac_schema
438 },
439 "additionalProperties": False,
440 "required": ["name","dedicated", "bandwidth"]
441 }
442}
443
444bridge_interfaces_schema={
445 "type":"array",
446 "items":{
447 "type":"object",
448 "properties":{
449 "name": name_schema,
450 "bandwidth":bandwidth_schema,
451 "vpci":pci_schema,
452 "mac_address": mac_schema,
453 "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}
454 },
455 "additionalProperties": False,
456 "required": ["name"]
457 }
458}
459
460devices_schema={
461 "type":"array",
462 "items":{
463 "type":"object",
464 "properties":{
465 "type":{"type":"string", "enum":["disk","cdrom","xml"] },
466 "image": path_schema,
garciadeblasb69fa9f2016-09-28 12:04:10 +0200467 "image name": name_schema,
468 "image checksum": checksum_schema,
montesmoreno0c8def02016-12-22 12:16:23 +0000469 "image metadata": metadata_schema,
470 "size": size_schema,
tierno7edb6752016-03-21 17:37:52 +0100471 "vpci":pci_schema,
472 "xml":xml_text_schema,
473 },
474 "additionalProperties": False,
475 "required": ["type"]
476 }
477}
478
479
480numa_schema = {
481 "type": "object",
482 "properties": {
483 "memory":integer1_schema,
484 "cores":integer1_schema,
485 "paired-threads":integer1_schema,
486 "threads":integer1_schema,
487 "cores-id":{"type":"array","items":integer0_schema},
488 "paired-threads-id":{"type":"array","items":{"type":"array","minItems":2,"maxItems":2,"items":integer0_schema}},
489 "threads-id":{"type":"array","items":integer0_schema},
490 "interfaces":interfaces_schema
491 },
492 "additionalProperties": False,
493 #"required": ["memory"]
494}
495
496vnfc_schema = {
497 "type":"object",
498 "properties":{
499 "name": name_schema,
500 "description": description_schema,
501 "VNFC image": {"oneOf": [path_schema, http_schema]},
garciadeblasb69fa9f2016-09-28 12:04:10 +0200502 "image name": name_schema,
503 "image checksum": checksum_schema,
tierno7edb6752016-03-21 17:37:52 +0100504 "image metadata": metadata_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200505 #"cloud-config": cloud_config_schema, #common for all vnfs in the scenario
tierno7edb6752016-03-21 17:37:52 +0100506 "processor": {
507 "type":"object",
508 "properties":{
509 "model":description_schema,
510 "features":{"type":"array","items":nameshort_schema}
511 },
512 "required": ["model"],
513 "additionalProperties": False
514 },
515 "hypervisor": {
516 "type":"object",
517 "properties":{
518 "type":nameshort_schema,
519 "version":description_schema
520 },
521 },
522 "ram":integer0_schema,
523 "vcpus":integer0_schema,
524 "disk": integer1_schema,
525 "numas": {
526 "type": "array",
garciadeblasfec35df2016-08-25 11:33:57 +0200527 "items": numa_schema
tierno7edb6752016-03-21 17:37:52 +0100528 },
529 "bridge-ifaces": bridge_interfaces_schema,
530 "devices": devices_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200531
tierno7edb6752016-03-21 17:37:52 +0100532 },
garciadeblasb69fa9f2016-09-28 12:04:10 +0200533 "required": ["name"],
534 "oneOf": [
535 {"required": ["VNFC image"]},
536 {"required": ["image name"]}
537 ],
tierno7edb6752016-03-21 17:37:52 +0100538 "additionalProperties": False
539}
540
541vnfd_schema_v01 = {
542 "title":"vnfd information schema v0.1",
543 "$schema": "http://json-schema.org/draft-04/schema#",
544 "type":"object",
545 "properties":{
546 "vnf":{
547 "type":"object",
548 "properties":{
549 "name": name_schema,
550 "description": description_schema,
551 "class": nameshort_schema,
552 "public": {"type" : "boolean"},
553 "physical": {"type" : "boolean"},
554 "tenant_id": id_schema, #only valid for admin
555 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
556 "internal-connections": {"type" : "array", "items": internal_connection_schema, "minItems":1},
557 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
558 },
559 "required": ["name","external-connections"],
560 "additionalProperties": True
561 }
562 },
563 "required": ["vnf"],
564 "additionalProperties": False
565}
566
garciadeblasfec35df2016-08-25 11:33:57 +0200567#VNFD schema for OSM R1
tierno7edb6752016-03-21 17:37:52 +0100568vnfd_schema_v02 = {
569 "title":"vnfd information schema v0.2",
570 "$schema": "http://json-schema.org/draft-04/schema#",
571 "type":"object",
572 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200573 "schema_version": {"type": "string", "enum": ["0.2"]},
tierno7edb6752016-03-21 17:37:52 +0100574 "vnf":{
575 "type":"object",
576 "properties":{
577 "name": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200578 "description": description_schema,
579 "class": nameshort_schema,
580 "public": {"type" : "boolean"},
581 "physical": {"type" : "boolean"},
582 "tenant_id": id_schema, #only valid for admin
garciadeblas9f8456e2016-09-05 05:02:59 +0200583 "external-connections": {"type" : "array", "items": external_connection_schema, "minItems":1},
garciadeblasfec35df2016-08-25 11:33:57 +0200584 "internal-connections": {"type" : "array", "items": internal_connection_schema_v02, "minItems":1},
585 # "cloud-config": cloud_config_schema, #common for all vnfcs
586 "VNFC":{"type" : "array", "items": vnfc_schema, "minItems":1}
tierno7edb6752016-03-21 17:37:52 +0100587 },
588 "required": ["name"],
589 "additionalProperties": True
590 }
591 },
tierno392f2852016-05-13 12:28:55 +0200592 "required": ["vnf", "schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100593 "additionalProperties": False
594}
595
596#vnfd_schema = vnfd_schema_v01
597#{
598# "title":"vnfd information schema v0.2",
599# "$schema": "http://json-schema.org/draft-04/schema#",
600# "oneOf": [vnfd_schema_v01, vnfd_schema_v02]
601#}
602
603graph_schema = {
604 "title":"graphical scenario descriptor information schema",
605 "$schema": "http://json-schema.org/draft-04/schema#",
606 "type":"object",
607 "properties":{
608 "x": integer0_schema,
609 "y": integer0_schema,
610 "ifaces": {
611 "type":"object",
612 "properties":{
613 "left": {"type":"array"},
614 "right": {"type":"array"},
615 "bottom": {"type":"array"},
616 }
617 }
618 },
619 "required": ["x","y"]
620}
621
622nsd_schema_v01 = {
623 "title":"network scenario descriptor information schema v0.1",
624 "$schema": "http://json-schema.org/draft-04/schema#",
625 "type":"object",
626 "properties":{
627 "name":name_schema,
628 "description": description_schema,
629 "tenant_id": id_schema, #only valid for admin
tierno392f2852016-05-13 12:28:55 +0200630 "public": {"type": "boolean"},
tierno7edb6752016-03-21 17:37:52 +0100631 "topology":{
632 "type":"object",
633 "properties":{
634 "nodes": {
635 "type":"object",
636 "patternProperties":{
637 ".": {
638 "type": "object",
639 "properties":{
640 "type":{"type":"string", "enum":["VNF", "other_network", "network", "external_network"]},
641 "vnf_id": id_schema,
642 "graph": graph_schema,
643 },
644 "patternProperties":{
645 "^(VNF )?model$": {"type": "string"}
646 },
647 "required": ["type"]
648 }
649 }
650 },
651 "connections": {
652 "type":"object",
653 "patternProperties":{
654 ".": {
655 "type": "object",
656 "properties":{
657 "nodes":{"oneOf":[{"type":"object", "minProperties":2}, {"type":"array", "minLength":1}]},
658 "type": {"type": "string", "enum":["link", "external_network", "dataplane_net", "bridge_net"]},
659 "graph": graph_schema
660 },
661 "required": ["nodes"]
662 },
663 }
664 }
665 },
666 "required": ["nodes"],
667 "additionalProperties": False
668 }
669 },
670 "required": ["name","topology"],
671 "additionalProperties": False
672}
673
tierno7edb6752016-03-21 17:37:52 +0100674nsd_schema_v02 = {
675 "title":"network scenario descriptor information schema v0.2",
676 "$schema": "http://json-schema.org/draft-04/schema#",
677 "type":"object",
678 "properties":{
garciadeblas0c317ee2016-08-29 12:33:06 +0200679 "schema_version": schema_version_2,
tierno392f2852016-05-13 12:28:55 +0200680 "scenario":{
tierno7edb6752016-03-21 17:37:52 +0100681 "type":"object",
tierno392f2852016-05-13 12:28:55 +0200682 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200683 "name": name_schema,
tierno392f2852016-05-13 12:28:55 +0200684 "description": description_schema,
685 "tenant_id": id_schema, #only valid for admin
686 "public": {"type": "boolean"},
687 "vnfs": {
688 "type":"object",
689 "patternProperties":{
690 ".": {
691 "type": "object",
692 "properties":{
693 "vnf_id": id_schema,
694 "graph": graph_schema,
695 "vnf_name": name_schema,
696 },
697 }
tierno7edb6752016-03-21 17:37:52 +0100698 },
tierno392f2852016-05-13 12:28:55 +0200699 "minProperties": 1
tierno7edb6752016-03-21 17:37:52 +0100700 },
tierno392f2852016-05-13 12:28:55 +0200701 "networks": {
702 "type":"object",
703 "patternProperties":{
704 ".": {
705 "type": "object",
706 "properties":{
707 "interfaces":{"type":"array", "minLength":1},
708 "type": {"type": "string", "enum":["dataplane", "bridge"]},
709 "external" : {"type": "boolean"},
710 "graph": graph_schema
711 },
712 "required": ["interfaces"]
713 },
714 }
715 },
716
717 },
garciadeblasfec35df2016-08-25 11:33:57 +0200718 "required": ["vnfs", "name"],
719 "additionalProperties": False
720 }
721 },
722 "required": ["scenario","schema_version"],
723 "additionalProperties": False
724}
725
726#NSD schema for OSM R1
727nsd_schema_v03 = {
728 "title":"network scenario descriptor information schema v0.3",
729 "$schema": "http://json-schema.org/draft-04/schema#",
730 "type":"object",
731 "properties":{
732 "schema_version": {"type": "string", "enum": ["0.3"]},
733 "scenario":{
734 "type":"object",
735 "properties":{
736 "name": name_schema,
737 "description": description_schema,
738 "tenant_id": id_schema, #only valid for admin
739 "public": {"type": "boolean"},
740 "cloud-config": cloud_config_schema, #common for all vnfs in the scenario
garciadeblas0c317ee2016-08-29 12:33:06 +0200741 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200742 "vnfs": {
743 "type":"object",
744 "patternProperties":{
745 ".": {
746 "type": "object",
747 "properties":{
748 "vnf_id": id_schema,
749 "graph": graph_schema,
750 "vnf_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200751 #"cloud-config": cloud_config_schema, #particular for a vnf
752 #"datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200753 "internal-connections": {
754 "type": "object",
755 "patternProperties": {
756 ".": {
757 "type": "object",
758 "properties": {
759 "ip-profile": ip_profile_schema,
760 "elements": {
761 "type" : "array",
762 "items":{
763 "type":"object",
764 "properties":{
765 "VNFC": name_schema,
766 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200767 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200768 },
769 "required": ["VNFC", "local_iface_name"],
770 }
771 }
772 }
773 }
774 }
775 }
776 },
777 }
778 },
779 "minProperties": 1
780 },
781 "networks": {
782 "type":"object",
783 "patternProperties":{
784 ".": {
785 "type": "object",
786 "properties":{
787 "interfaces":{
788 "type":"array",
789 "minLength":1,
790 "items":{
791 "type":"object",
792 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200793 "vnf": name_schema,
794 "vnf_interface": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200795 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200796 },
garciadeblas9f8456e2016-09-05 05:02:59 +0200797 "required": ["vnf", "vnf_interface"],
garciadeblasfec35df2016-08-25 11:33:57 +0200798 }
799 },
800 "type": {"type": "string", "enum":["e-line", "e-lan"]},
garciadeblas9f8456e2016-09-05 05:02:59 +0200801 "implementation": {"type": "string", "enum":["overlay", "underlay"]},
garciadeblasfec35df2016-08-25 11:33:57 +0200802 "external" : {"type": "boolean"},
803 "graph": graph_schema,
804 "ip-profile": ip_profile_schema
805 },
806 "required": ["interfaces"]
807 },
808 }
809 },
810
811 },
tierno392f2852016-05-13 12:28:55 +0200812 "required": ["vnfs", "networks","name"],
813 "additionalProperties": False
814 }
tierno7edb6752016-03-21 17:37:52 +0100815 },
tierno392f2852016-05-13 12:28:55 +0200816 "required": ["scenario","schema_version"],
tierno7edb6752016-03-21 17:37:52 +0100817 "additionalProperties": False
818}
819
820#scenario_new_schema = {
821# "title":"new scenario information schema",
822# "$schema": "http://json-schema.org/draft-04/schema#",
823# #"oneOf": [nsd_schema_v01, nsd_schema_v02]
824# "oneOf": [nsd_schema_v01]
825#}
826
827scenario_edit_schema = {
828 "title":"edit scenario information schema",
829 "$schema": "http://json-schema.org/draft-04/schema#",
830 "type":"object",
831 "properties":{
832 "name":name_schema,
833 "description": description_schema,
834 "topology":{
835 "type":"object",
836 "properties":{
837 "nodes": {
838 "type":"object",
839 "patternProperties":{
840 "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$": {
841 "type":"object",
842 "properties":{
843 "graph":{
844 "type": "object",
845 "properties":{
846 "x": integer0_schema,
847 "y": integer0_schema,
848 "ifaces":{ "type": "object"}
849 }
850 },
851 "description": description_schema,
852 "name": name_schema
853 }
854 }
855 }
856 }
857 },
858 "required": ["nodes"],
859 "additionalProperties": False
860 }
861 },
862 "additionalProperties": False
863}
864
865scenario_action_schema = {
866 "title":"scenario action information schema",
867 "$schema": "http://json-schema.org/draft-04/schema#",
868 "type":"object",
869 "properties":{
870 "start":{
871 "type": "object",
872 "properties": {
873 "instance_name":name_schema,
874 "description":description_schema,
875 "datacenter": {"type": "string"}
876 },
877 "required": ["instance_name"]
878 },
879 "deploy":{
880 "type": "object",
881 "properties": {
882 "instance_name":name_schema,
883 "description":description_schema,
884 "datacenter": {"type": "string"}
885 },
886 "required": ["instance_name"]
887 },
888 "reserve":{
889 "type": "object",
890 "properties": {
891 "instance_name":name_schema,
892 "description":description_schema,
893 "datacenter": {"type": "string"}
894 },
895 "required": ["instance_name"]
896 },
897 "verify":{
898 "type": "object",
899 "properties": {
900 "instance_name":name_schema,
901 "description":description_schema,
902 "datacenter": {"type": "string"}
903 },
904 "required": ["instance_name"]
905 }
906 },
907 "minProperties": 1,
908 "maxProperties": 1,
909 "additionalProperties": False
910}
911
garciadeblasfec35df2016-08-25 11:33:57 +0200912instance_scenario_create_schema_v01 = {
tierno7edb6752016-03-21 17:37:52 +0100913 "title":"instance scenario create information schema v0.1",
914 "$schema": "http://json-schema.org/draft-04/schema#",
915 "type":"object",
916 "properties":{
917 "schema_version": {"type": "string", "enum": ["0.1"]},
918 "instance":{
919 "type":"object",
920 "properties":{
921 "name":name_schema,
922 "description":description_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200923 "datacenter": name_schema,
924 "scenario" : name_schema, #can be an UUID or name
tierno7edb6752016-03-21 17:37:52 +0100925 "action":{"enum": ["deploy","reserve","verify" ]},
garciadeblasfec35df2016-08-25 11:33:57 +0200926 "connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
927 "cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario
tierno7edb6752016-03-21 17:37:52 +0100928 "vnfs":{ #mapping from scenario to datacenter
929 "type": "object",
930 "patternProperties":{
931 ".": {
932 "type": "object",
933 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200934 "name": name_schema, #override vnf name
garciadeblas0c317ee2016-08-29 12:33:06 +0200935 "datacenter": name_schema,
garciadeblasfec35df2016-08-25 11:33:57 +0200936 #"metadata": {"type": "object"},
937 #"user_data": {"type": "string"}
garciadeblas0c317ee2016-08-29 12:33:06 +0200938 #"cloud-config": cloud_config_schema, #particular for a vnf
garciadeblasfec35df2016-08-25 11:33:57 +0200939 "external-connections": {
940 "type": "object",
941 "patternProperties": {
942 ".": {
943 "type": "object",
944 "properties": {
945 "vim-network-name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200946 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200947 }
948 }
949 }
950 },
951 "internal-connections": {
952 "type": "object",
953 "patternProperties": {
954 ".": {
955 "type": "object",
956 "properties": {
957 "ip-profile": ip_profile_schema,
958 "elements": {
959 "type" : "array",
960 "items":{
961 "type":"object",
962 "properties":{
963 "VNFC": name_schema,
964 "local_iface_name": name_schema,
garciadeblas0c317ee2016-08-29 12:33:06 +0200965 "ip_address": ip_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200966 },
967 "required": ["VNFC", "local_iface_name"],
968 }
969 }
970 }
971 }
972 }
973 }
tierno7edb6752016-03-21 17:37:52 +0100974 }
975 }
976 },
977 },
978 "networks":{ #mapping from scenario to datacenter
979 "type": "object",
980 "patternProperties":{
981 ".": {
982 "type": "object",
983 "properties":{
garciadeblasfec35df2016-08-25 11:33:57 +0200984 "interfaces":{
985 "type":"array",
986 "minLength":1,
987 "items":{
988 "type":"object",
989 "properties":{
garciadeblas9f8456e2016-09-05 05:02:59 +0200990 "ip_address": ip_schema,
991 "datacenter": name_schema,
992 "vim-network-name": name_schema
garciadeblasfec35df2016-08-25 11:33:57 +0200993 },
994 "patternProperties":{
995 ".": {"type": "string"}
996 }
997 }
998 },
garciadeblasfec35df2016-08-25 11:33:57 +0200999 "ip-profile": ip_profile_schema,
tiernobe41e222016-09-02 15:16:13 +02001000 #if the network connects VNFs deployed at different sites, you must specify one entry per site that this network connect to
1001 "sites": {
1002 "type":"array",
1003 "minLength":1,
1004 "items":{
1005 "type":"object",
1006 "properties":{
1007 # By default for an scenario 'external' network openmano looks for an existing VIM network to map this external scenario network,
1008 # for other networks openamno creates at VIM
1009 # Use netmap-create to force to create an external scenario network
1010 "netmap-create": {"oneOf":[name_schema,{"type": "null"}]}, #datacenter network to use. Null if must be created as an internal net
1011 #netmap-use: Indicates an existing VIM network that must be used for this scenario network.
1012 #Can use both the VIM network name (if it is not ambiguous) or the VIM net UUID
1013 #If both 'netmap-create' and 'netmap-use'are supplied, netmap-use precedes, but if fails openmano follows the netmap-create
1014 #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)
1015 "netmap-use": name_schema, #
1016 "vim-network-name": name_schema, #override network name
1017 #"ip-profile": ip_profile_schema,
1018 "datacenter": name_schema,
1019 }
1020 }
1021 },
1022
1023
1024
tierno7edb6752016-03-21 17:37:52 +01001025 }
1026 }
1027 },
1028 },
1029 },
1030 "additionalProperties": False,
garciadeblasfec35df2016-08-25 11:33:57 +02001031 "required": ["name"]
tierno7edb6752016-03-21 17:37:52 +01001032 },
1033 },
1034 "required": ["instance"],
1035 "additionalProperties": False
tierno7edb6752016-03-21 17:37:52 +01001036}
1037
1038instance_scenario_action_schema = {
1039 "title":"instance scenario action information schema",
1040 "$schema": "http://json-schema.org/draft-04/schema#",
1041 "type":"object",
1042 "properties":{
1043 "start":{"type": "null"},
1044 "pause":{"type": "null"},
1045 "resume":{"type": "null"},
1046 "shutoff":{"type": "null"},
1047 "shutdown":{"type": "null"},
1048 "forceOff":{"type": "null"},
1049 "rebuild":{"type": "null"},
1050 "reboot":{
1051 "type": ["object","null"],
1052 },
1053 "console": {"type": ["string", "null"], "enum": ["novnc", "xvpvnc", "rdp-html5", "spice-html5", None]},
1054 "vnfs":{"type": "array", "items":{"type":"string"}},
1055 "vms":{"type": "array", "items":{"type":"string"}}
1056 },
1057 "minProperties": 1,
1058 #"maxProperties": 1,
1059 "additionalProperties": False
1060}