gns3-server/gns3server/schemas/virtualbox.py

265 lines
8.2 KiB
Python
Raw Normal View History

2014-07-17 21:28:02 +00: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/>.
VBOX_CREATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to create a new VirtualBox VM instance",
"type": "object",
"properties": {
"vm_id": {
"description": "VirtualBox VM instance identifier",
2015-02-09 01:10:04 +00: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
]
},
"linked_clone": {
"description": "either the VM is a linked clone or not",
"type": "boolean"
},
"name": {
"description": "VirtualBox VM instance name",
"type": "string",
"minLength": 1,
},
"vmname": {
"description": "VirtualBox VM name (in VirtualBox itself)",
"type": "string",
"minLength": 1,
},
"adapters": {
"description": "number of adapters",
"type": "integer",
"minimum": 0,
"maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
},
2015-02-07 00:31:13 +00:00
"use_any_adapter": {
"description": "allow GNS3 to use any VirtualBox adapter",
"type": "boolean",
},
"adapter_type": {
"description": "VirtualBox adapter type",
"type": "string",
"minLength": 1,
},
2015-01-23 23:38:46 +00:00
"console": {
"description": "console TCP port",
"minimum": 1,
"maximum": 65535,
"type": "integer"
},
"enable_remote_console": {
"description": "enable the remote console",
"type": "boolean"
},
"ram": {
"description": "Amount of RAM",
"minimum": 0,
"maximum": 65535,
"type": "integer"
},
"headless": {
"description": "headless mode",
"type": "boolean"
},
2014-07-17 21:28:02 +00:00
},
"additionalProperties": False,
2015-02-05 00:13:35 +00:00
"required": ["name", "vmname", "linked_clone"],
2014-07-17 21:28:02 +00:00
}
2015-01-23 23:38:46 +00:00
VBOX_UPDATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to update a VirtualBox VM instance",
"type": "object",
"properties": {
"name": {
"description": "VirtualBox VM instance name",
"type": "string",
"minLength": 1,
},
"vmname": {
"description": "VirtualBox VM name (in VirtualBox itself)",
"type": "string",
"minLength": 1,
},
"adapters": {
"description": "number of adapters",
"type": "integer",
"minimum": 0,
"maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
},
2015-02-07 00:31:13 +00:00
"use_any_adapter": {
"description": "allow GNS3 to use any VirtualBox adapter",
"type": "boolean",
2015-01-23 23:38:46 +00:00
},
"adapter_type": {
"description": "VirtualBox adapter type",
"type": "string",
"minLength": 1,
},
"console": {
"description": "console TCP port",
"minimum": 1,
"maximum": 65535,
"type": "integer"
},
"enable_remote_console": {
"description": "enable the remote console",
"type": "boolean"
},
"ram": {
"description": "Amount of RAM",
"minimum": 0,
"maximum": 65535,
"type": "integer"
},
2015-01-23 23:38:46 +00:00
"headless": {
"description": "headless mode",
"type": "boolean"
},
},
"additionalProperties": False,
}
VBOX_NIO_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to add a NIO for a VirtualBox VM instance",
"type": "object",
"definitions": {
"UDP": {
"description": "UDP Network Input/Output",
"properties": {
"type": {
"enum": ["nio_udp"]
},
"lport": {
"description": "Local port",
"type": "integer",
"minimum": 1,
"maximum": 65535
},
"rhost": {
"description": "Remote host",
"type": "string",
"minLength": 1
},
"rport": {
"description": "Remote port",
"type": "integer",
"minimum": 1,
"maximum": 65535
}
},
"required": ["type", "lport", "rhost", "rport"],
"additionalProperties": False
},
},
"oneOf": [
{"$ref": "#/definitions/UDP"},
],
"additionalProperties": True,
"required": ["type"]
}
2015-01-24 01:33:49 +00:00
VBOX_CAPTURE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to start a packet capture on a VirtualBox VM instance port",
"type": "object",
"properties": {
2015-02-08 21:44:56 +00:00
"capture_file_name": {
2015-01-24 01:33:49 +00:00
"description": "Capture file name",
"type": "string",
"minLength": 1,
},
},
"additionalProperties": False,
2015-02-08 21:44:56 +00:00
"required": ["capture_file_name"]
2015-01-24 01:33:49 +00:00
}
VBOX_OBJECT_SCHEMA = {
2014-07-17 21:28:02 +00:00
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "VirtualBox VM instance",
2014-07-17 21:28:02 +00:00
"type": "object",
"properties": {
"name": {
"description": "VirtualBox VM instance name",
"type": "string",
"minLength": 1,
},
"vm_id": {
"description": "VirtualBox VM instance UUID",
2014-07-17 21:28:02 +00:00
"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}$"
2014-07-17 21:28:02 +00:00
},
"project_id": {
2015-01-20 22:28:40 +00: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}$"
},
2015-01-23 02:07:09 +00:00
"vmname": {
"description": "VirtualBox VM name (in VirtualBox itself)",
"type": "string",
"minLength": 1,
},
"enable_remote_console": {
"description": "enable the remote console",
"type": "boolean"
},
"headless": {
"description": "headless mode",
"type": "boolean"
},
2015-01-23 04:31:26 +00:00
"adapters": {
"description": "number of adapters",
"type": "integer",
"minimum": 0,
"maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
},
2015-02-07 00:31:13 +00:00
"use_any_adapter": {
"description": "allow GNS3 to use any VirtualBox adapter",
"type": "boolean",
2015-01-23 04:31:26 +00:00
},
"adapter_type": {
"description": "VirtualBox adapter type",
"type": "string",
"minLength": 1,
},
2014-07-17 21:28:02 +00:00
"console": {
"description": "console TCP port",
"minimum": 1,
"maximum": 65535,
"type": "integer"
},
"ram": {
"description": "Amount of RAM",
"minimum": 0,
"maximum": 65535,
"type": "integer"
},
2014-07-17 21:28:02 +00:00
},
"additionalProperties": False,
"required": ["name", "vm_id", "project_id"]
2014-07-17 21:28:02 +00:00
}