2014-07-18 00:28:02 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2014 GNS3 Technologies Inc.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
2018-04-02 18:27:12 +03:00
|
|
|
from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
|
|
|
|
|
|
|
|
2014-07-18 00:28:02 +03:00
|
|
|
VBOX_CREATE_SCHEMA = {
|
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "Request validation to create a new VirtualBox VM instance",
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2016-05-11 20:35:36 +03:00
|
|
|
"node_id": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Node UUID",
|
2015-02-09 03:10:04 +02:00
|
|
|
"oneOf": [
|
|
|
|
{"type": "string",
|
|
|
|
"minLength": 36,
|
|
|
|
"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}$"},
|
|
|
|
{"type": "integer"} # for legacy projects
|
|
|
|
]
|
2015-01-31 04:36:05 +02:00
|
|
|
},
|
|
|
|
"linked_clone": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Whether the VM is a linked clone or not",
|
2015-01-31 04:36:05 +02:00
|
|
|
"type": "boolean"
|
|
|
|
},
|
|
|
|
"name": {
|
|
|
|
"description": "VirtualBox VM instance name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2018-12-21 10:54:13 +02:00
|
|
|
"usage": {
|
|
|
|
"description": "How to use the VirtualBox VM",
|
|
|
|
"type": "string",
|
|
|
|
},
|
2015-01-31 04:36:05 +02:00
|
|
|
"vmname": {
|
|
|
|
"description": "VirtualBox VM name (in VirtualBox itself)",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
|
|
|
"adapters": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Number of adapters",
|
2015-01-31 04:36:05 +02:00
|
|
|
"type": "integer",
|
|
|
|
"minimum": 0,
|
|
|
|
"maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
|
|
|
|
},
|
2015-02-07 02:31:13 +02:00
|
|
|
"use_any_adapter": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Allow GNS3 to use any VirtualBox adapter",
|
2015-02-07 02:31:13 +02:00
|
|
|
"type": "boolean",
|
2015-01-31 04:36:05 +02:00
|
|
|
},
|
|
|
|
"adapter_type": {
|
|
|
|
"description": "VirtualBox adapter type",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2015-01-24 01:38:46 +02:00
|
|
|
"console": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Console TCP port",
|
2015-01-24 01:38:46 +02:00
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
2018-03-24 14:11:21 +03:00
|
|
|
"type": ["integer", "null"]
|
2015-01-24 01:38:46 +02:00
|
|
|
},
|
2016-11-07 12:16:51 +02:00
|
|
|
"console_type": {
|
|
|
|
"description": "Console type",
|
2018-03-24 14:11:21 +03:00
|
|
|
"enum": ["telnet", "none"]
|
2016-11-07 12:16:51 +02:00
|
|
|
},
|
2015-03-14 01:13:36 +02:00
|
|
|
"ram": {
|
|
|
|
"description": "Amount of RAM",
|
|
|
|
"minimum": 0,
|
|
|
|
"maximum": 65535,
|
|
|
|
"type": "integer"
|
|
|
|
},
|
2015-01-31 04:36:05 +02:00
|
|
|
"headless": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Headless mode",
|
2015-01-31 04:36:05 +02:00
|
|
|
"type": "boolean"
|
|
|
|
},
|
2018-03-30 17:18:44 +03:00
|
|
|
"on_close": {
|
|
|
|
"description": "Action to execute on the VM is closed",
|
|
|
|
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
|
|
|
},
|
2018-04-02 18:27:12 +03:00
|
|
|
"custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
2014-07-18 00:28:02 +03:00
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
2016-10-24 17:47:45 +03:00
|
|
|
"required": ["name", "vmname"],
|
2014-07-18 00:28:02 +03:00
|
|
|
}
|
|
|
|
|
2015-01-24 03:33:49 +02:00
|
|
|
|
2015-01-20 03:30:57 +02:00
|
|
|
VBOX_OBJECT_SCHEMA = {
|
2014-07-18 00:28:02 +03:00
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
2015-01-20 03:30:57 +02:00
|
|
|
"description": "VirtualBox VM instance",
|
2014-07-18 00:28:02 +03:00
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"name": {
|
|
|
|
"description": "VirtualBox VM instance name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2016-05-11 20:35:36 +03:00
|
|
|
"node_id": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Node UUID",
|
2014-07-18 00:28:02 +03:00
|
|
|
"type": "string",
|
2015-01-20 03:30:57 +02:00
|
|
|
"minLength": 36,
|
|
|
|
"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}$"
|
2014-07-18 00:28:02 +03:00
|
|
|
},
|
2015-02-04 03:40:13 +02:00
|
|
|
"project_id": {
|
2015-01-21 00:28:40 +02:00
|
|
|
"description": "Project UUID",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 36,
|
|
|
|
"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}$"
|
|
|
|
},
|
2018-12-21 10:54:13 +02:00
|
|
|
"usage": {
|
|
|
|
"description": "How to use the VirtualBox VM",
|
|
|
|
"type": "string",
|
|
|
|
},
|
2015-01-23 04:07:09 +02:00
|
|
|
"vmname": {
|
|
|
|
"description": "VirtualBox VM name (in VirtualBox itself)",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2016-05-17 20:51:06 +03:00
|
|
|
"status": {
|
|
|
|
"description": "VM status",
|
|
|
|
"enum": ["started", "stopped", "suspended"]
|
|
|
|
},
|
2016-05-12 11:39:50 +03:00
|
|
|
"node_directory": {
|
2017-03-06 15:25:53 +02:00
|
|
|
"description": "Path to the VM working directory",
|
2015-06-26 18:09:19 +03:00
|
|
|
"type": ["string", "null"]
|
|
|
|
},
|
2015-01-23 04:07:09 +02:00
|
|
|
"headless": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Headless mode",
|
2015-01-23 04:07:09 +02:00
|
|
|
"type": "boolean"
|
|
|
|
},
|
2018-03-30 17:18:44 +03:00
|
|
|
"on_close": {
|
|
|
|
"description": "Action to execute on the VM is closed",
|
|
|
|
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
2015-06-03 01:30:35 +03:00
|
|
|
},
|
2015-01-23 06:31:26 +02:00
|
|
|
"adapters": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Number of adapters",
|
2015-01-23 06:31:26 +02:00
|
|
|
"type": "integer",
|
|
|
|
"minimum": 0,
|
|
|
|
"maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
|
|
|
|
},
|
2015-02-07 02:31:13 +02:00
|
|
|
"use_any_adapter": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Allow GNS3 to use any VirtualBox adapter",
|
2015-02-07 02:31:13 +02:00
|
|
|
"type": "boolean",
|
2015-01-23 06:31:26 +02:00
|
|
|
},
|
|
|
|
"adapter_type": {
|
|
|
|
"description": "VirtualBox adapter type",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2014-07-18 00:28:02 +03:00
|
|
|
"console": {
|
2016-05-13 04:07:25 +03:00
|
|
|
"description": "Console TCP port",
|
2014-07-18 00:28:02 +03:00
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
2018-03-24 14:11:21 +03:00
|
|
|
"type": ["integer", "null"]
|
2014-07-18 00:28:02 +03:00
|
|
|
},
|
2016-11-07 12:16:51 +02:00
|
|
|
"console_type": {
|
|
|
|
"description": "Console type",
|
2018-03-24 14:11:21 +03:00
|
|
|
"enum": ["telnet", "none"]
|
2016-11-07 12:16:51 +02:00
|
|
|
},
|
2015-03-14 01:13:36 +02:00
|
|
|
"ram": {
|
|
|
|
"description": "Amount of RAM",
|
|
|
|
"minimum": 0,
|
|
|
|
"maximum": 65535,
|
|
|
|
"type": "integer"
|
|
|
|
},
|
2016-07-12 17:22:55 +03:00
|
|
|
"linked_clone": {
|
|
|
|
"description": "Whether the VM is a linked clone or not",
|
|
|
|
"type": "boolean"
|
2018-04-02 18:27:12 +03:00
|
|
|
},
|
|
|
|
"custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
2014-07-18 00:28:02 +03:00
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
|
|
|
}
|