1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Drop console_type serial, and enable_remote_console for Vbox and VMware

Ref #748
This commit is contained in:
Julien Duponchelle 2016-11-03 18:17:50 +01:00
parent 382d8887d5
commit 4e15f89604
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
28 changed files with 163 additions and 110 deletions

View File

@ -23,7 +23,8 @@ A minimal version:
The revision is the version of file format:
* 5: GNS3 2.0
* 6: GNS3 2.0
* 5: GNS3 2.0 < alpha 4
* 4: GNS3 1.5
* 3: GNS3 1.4
* 2: GNS3 1.3

View File

@ -66,7 +66,6 @@ class VirtualBoxVM(BaseNode):
self._ethernet_adapters = {}
self._headless = False
self._acpi_shutdown = False
self._enable_remote_console = False
if not self.linked_clone:
for node in self.manager.nodes:
if node.vmname == vmname:
@ -86,7 +85,6 @@ class VirtualBoxVM(BaseNode):
"vmname": self.vmname,
"headless": self.headless,
"acpi_shutdown": self.acpi_shutdown,
"enable_remote_console": self.enable_remote_console,
"adapters": self._adapters,
"adapter_type": self.adapter_type,
"ram": self.ram,
@ -245,7 +243,7 @@ class VirtualBoxVM(BaseNode):
self._local_udp_tunnels[adapter_number][1],
nio)
if self._enable_remote_console and self._console is not None:
if self._console is not None:
try:
# wait for VirtualBox to create the pipe file.
if sys.platform.startswith("win"):
@ -539,34 +537,6 @@ class VirtualBoxVM(BaseNode):
log.info("VirtualBox VM '{name}' [{id}] has disabled the ACPI shutdown mode".format(name=self.name, id=self.id))
self._acpi_shutdown = acpi_shutdown
@property
def enable_remote_console(self):
"""
Returns either the remote console is enabled or not
:returns: boolean
"""
return self._enable_remote_console
@asyncio.coroutine
def set_enable_remote_console(self, enable_remote_console):
"""
Sets either the console is enabled or not
:param enable_remote_console: boolean
"""
if enable_remote_console:
log.info("VirtualBox VM '{name}' [{id}] has enabled the console".format(name=self.name, id=self.id))
vm_state = yield from self._get_vm_state()
if vm_state == "running":
self._start_remote_console()
else:
log.info("VirtualBox VM '{name}' [{id}] has disabled the console".format(name=self.name, id=self.id))
self._stop_remote_console()
self._enable_remote_console = enable_remote_console
@property
def ram(self):
"""

View File

@ -68,7 +68,6 @@ class VMwareVM(BaseNode):
# VMware VM settings
self._headless = False
self._vmx_path = vmx_path
self._enable_remote_console = False
self._acpi_shutdown = False
self._adapters = 0
self._ethernet_adapters = {}
@ -87,7 +86,6 @@ class VMwareVM(BaseNode):
"vmx_path": self.vmx_path,
"headless": self.headless,
"acpi_shutdown": self.acpi_shutdown,
"enable_remote_console": self.enable_remote_console,
"adapters": self._adapters,
"adapter_type": self.adapter_type,
"use_any_adapter": self.use_any_adapter,
@ -442,7 +440,7 @@ class VMwareVM(BaseNode):
if nio:
yield from self._add_ubridge_connection(nio, adapter_number)
# if self._enable_remote_console and self._console is not None:
# if self._console is not None:
# try:
# if sys.platform.startswith("win"):
# yield from wait_for_named_pipe_creation(self._get_pipe_name())
@ -631,33 +629,6 @@ class VMwareVM(BaseNode):
log.info("VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'".format(name=self.name, id=self.id, vmx=vmx_path))
self._vmx_path = vmx_path
@property
def enable_remote_console(self):
"""
Returns either the remote console is enabled or not
:returns: boolean
"""
return self._enable_remote_console
@enable_remote_console.setter
def enable_remote_console(self, enable_remote_console):
"""
Sets either the console is enabled or not
:param enable_remote_console: boolean
"""
# if enable_remote_console:
# log.info("VMware VM '{name}' [{id}] has enabled the console".format(name=self.name, id=self.id))
# if self._started:
# self._start_remote_console()
# else:
# log.info("VMware VM '{name}' [{id}] has disabled the console".format(name=self.name, id=self.id))
# self._stop_remote_console()
self._enable_remote_console = enable_remote_console
@property
def adapters(self):
"""

View File

@ -35,7 +35,7 @@ import logging
log = logging.getLogger(__name__)
GNS3_FILE_FORMAT_REVISION = 5
GNS3_FILE_FORMAT_REVISION = 6
def _check_topology_schema(topo):
@ -113,7 +113,7 @@ def load_topology(path):
topo = json.load(f)
except (OSError, UnicodeDecodeError, json.JSONDecodeError) as e:
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
if "revision" not in topo or topo["revision"] < GNS3_FILE_FORMAT_REVISION:
if "revision" not in topo or topo["revision"] < 5:
# If it's an old GNS3 file we need to convert it
# first we backup the file
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
@ -121,12 +121,40 @@ def load_topology(path):
_check_topology_schema(topo)
with open(path, "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4, sort_keys=True)
elif topo["revision"] > GNS3_FILE_FORMAT_REVISION:
# Version before GNS3 2.0 alpha 4
if topo["revision"] < 6:
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
topo = _convert_2_0_0_alpha(topo, path)
_check_topology_schema(topo)
with open(path, "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4, sort_keys=True)
if topo["revision"] > GNS3_FILE_FORMAT_REVISION:
raise aiohttp.web.HTTPConflict(text="This project is designed for a more recent version of GNS3 please update GNS3 to version {} or later".format(topo["version"]))
_check_topology_schema(topo)
return topo
def _convert_2_0_0_alpha(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 alpha to 2.0.0 final.
Changes:
* No more serial console
* No more option for VMware / VirtualBox remote console (always use telnet)
"""
topo["revision"] = 6
for node in topo.get("topology", {}).get("nodes", []):
if node.get("console_type") == "serial":
node["console_type"] = "telnet"
if node["node_type"] in ("vmware", "virtualbox"):
prop = node.get("properties")
if "enable_remote_console" in prop:
del prop["enable_remote_console"]
return topo
def _convert_1_3_later(topo, topo_path):
"""
Convert topologies from 1_3 to the new file format
@ -139,7 +167,7 @@ def _convert_1_3_later(topo, topo_path):
new_topo = {
"type": "topology",
"revision": GNS3_FILE_FORMAT_REVISION,
"revision": 5,
"version": __version__,
"auto_start": topo.get("auto_start", False),
"name": topo["name"],

View File

@ -60,9 +60,6 @@ class VirtualBoxHandler:
console=request.json.get("console", None),
adapters=request.json.get("adapters", 0))
if "enable_remote_console" in request.json:
yield from vm.set_enable_remote_console(request.json.pop("enable_remote_console"))
if "ram" in request.json:
ram = request.json.pop("ram")
if ram != vm.ram:
@ -120,9 +117,6 @@ class VirtualBoxHandler:
if vmname != vm.vmname:
yield from vm.set_vmname(vmname)
if "enable_remote_console" in request.json:
yield from vm.set_enable_remote_console(request.json.pop("enable_remote_console"))
if "adapters" in request.json:
adapters = int(request.json.pop("adapters"))
if adapters != vm.adapters:

View File

@ -143,7 +143,7 @@ NODE_OBJECT_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["serial", "vnc", "telnet", "http", None]
"enum": ["vnc", "telnet", "http", None]
},
"properties": {
"description": "Properties specific to an emulator",

View File

@ -66,10 +66,6 @@ VBOX_CREATE_SCHEMA = {
"maximum": 65535,
"type": "integer"
},
"enable_remote_console": {
"description": "Enable the remote console",
"type": "boolean"
},
"ram": {
"description": "Amount of RAM",
"minimum": 0,
@ -127,10 +123,6 @@ VBOX_OBJECT_SCHEMA = {
"decription": "Path to the VM working directory",
"type": ["string", "null"]
},
"enable_remote_console": {
"description": "Enable the remote console",
"type": "boolean"
},
"headless": {
"description": "Headless mode",
"type": "boolean"

View File

@ -48,10 +48,6 @@ VMWARE_CREATE_SCHEMA = {
"maximum": 65535,
"type": "integer"
},
"enable_remote_console": {
"description": "Enable the remote console",
"type": "boolean"
},
"headless": {
"description": "Headless mode",
"type": "boolean"
@ -118,10 +114,6 @@ VMWARE_OBJECT_SCHEMA = {
"type": "string",
"minLength": 1,
},
"enable_remote_console": {
"description": "Enable the remote console",
"type": "boolean"
},
"headless": {
"description": "Headless mode",
"type": "boolean"

View File

@ -39,7 +39,7 @@ def test_project_to_topology_empty(tmpdir):
"auto_open": False,
"scene_width": 2000,
"scene_height": 1000,
"revision": 5,
"revision": GNS3_FILE_FORMAT_REVISION,
"topology": {
"nodes": [],
"links": [],
@ -79,7 +79,7 @@ def test_load_topology(tmpdir):
data = {
"project_id": "69f26504-7aa3-48aa-9f29-798d44841211",
"name": "Test",
"revision": 5,
"revision": GNS3_FILE_FORMAT_REVISION,
"topology": {
"nodes": [],
"links": [],

View File

@ -15,7 +15,7 @@
}
]
},
"revision" : 5,
"revision": 6,
"project_id" : "ANYUUID",
"type" : "topology",
"auto_start" : false

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_3_dynamips",
"project_id": "ba5790e1-2f51-443e-a3cc-1a2eee132888",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{

View File

@ -1,5 +1,5 @@
{
"revision": 5,
"revision": 6,
"auto_start": false,
"topology": {
"drawings": [],

View File

@ -1,7 +1,7 @@
{
"name": "builtins",
"project_id": "644e3892-4a50-4457-9601-2234d4842169",
"revision": 5,
"revision": 6,
"auto_start": false,
"topology": {
"computes": [

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_cloud",
"project_id": "467ce18d-4848-494a-88d2-4f53ddaca111",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{

View File

@ -1,7 +1,7 @@
{
"name": "1_5_docker_remote",
"project_id": "8182b710-c6bf-4e51-8e2e-213cce952797",
"revision": 5,
"revision": 6,
"auto_start": false,
"topology": {
"computes": [

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_drawing",
"project_id": "ANYUUID",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
],

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_dynamips",
"project_id": "62f389c0-f26d-43b7-ab29-e4d306b29c07",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_host",
"project_id": "ce17e635-bc1b-44df-946c-149e938dedc4",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_image",
"project_id": "ANYUUID",
"revision": 5,
"revision": 6,
"topology": {
"computes": [],
"drawings": [

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_internet",
"project_id": "a64f6cf9-ea6e-42e6-9e4e-a2a292e2b827",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{"name": "GNS3 VM", "protocol": "http", "port": 3080, "host": "172.16.16.150", "compute_id": "vm"}

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_iou",
"project_id": "8a077150-3e3e-4fed-944e-b8cd882e24db",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{

View File

@ -1,7 +1,7 @@
{
"name": "testqemu",
"project_id": "a3ca8a82-6b11-4c8e-b20d-c9e94286054c",
"revision": 5,
"revision": 6,
"auto_start": false,
"topology": {
"computes": [

View File

@ -41,7 +41,7 @@
}
]
},
"revision" : 5,
"revision": 6,
"name" : "1_5_snapshot",
"project_id" : "17912669-dd40-4843-b348-689b8f34f09d",
"auto_start" : false

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_virtualbox",
"project_id": "bf00c459-05a5-45c0-950c-3f6150a20703",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{
@ -37,7 +37,6 @@
"acpi_shutdown": false,
"adapter_type": "Intel PRO/1000 MT Desktop (82540EM)",
"adapters": 1,
"enable_remote_console": false,
"headless": false,
"ram": 512,
"use_any_adapter": false,

View File

@ -1,7 +1,7 @@
{
"name": "1_5_vmware",
"project_id": "4be1f3e5-76e5-4223-93b7-f37f4091549e",
"revision": 5,
"revision": 6,
"auto_start": false,
"topology": {
"computes": [
@ -37,7 +37,6 @@
"acpi_shutdown": false,
"adapter_type": "e1000",
"adapters": 1,
"enable_remote_console": false,
"headless": false,
"use_any_adapter": false,
"vmx_path": "/Users/bob/Documents/Virtual Machines.localized/GNS3 VM.vmwarevm/GNS3 VM.vmx"

View File

@ -2,7 +2,7 @@
"auto_start": false,
"name": "1_5_vpcs",
"project_id": "62fc7a04-ae65-4003-a9e6-a046b1996f0e",
"revision": 5,
"revision": 6,
"topology": {
"computes": [
{

View File

@ -0,0 +1,53 @@
{
"name": "1_5_vmware",
"project_id": "4be1f3e5-76e5-4223-93b7-f37f4091549e",
"revision": 6,
"auto_start": false,
"topology": {
"computes": [
{
"compute_id": "local",
"host": "127.0.0.1",
"name": "Local",
"port": 3080,
"protocol": "http"
}
],
"drawings": [],
"links": [],
"nodes": [
{
"compute_id": "local",
"console": 2000,
"console_type": "telnet",
"label": {
"rotation": 0,
"style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;",
"text": "GNS3 VM",
"x": 5,
"y": -25
},
"name": "GNS3 VM",
"node_id": "9e06d0ce-e8df-4f38-bdfa-7c83e19a91c1",
"node_type": "vmware",
"port_name_format": "Ethernet{0}",
"port_segment_size": 0,
"first_port_name": null,
"properties": {
"acpi_shutdown": false,
"adapter_type": "e1000",
"adapters": 1,
"headless": false,
"use_any_adapter": false,
"vmx_path": "/Users/bob/Documents/Virtual Machines.localized/GNS3 VM.vmwarevm/GNS3 VM.vmx"
},
"symbol": ":/symbols/vmware_guest.svg",
"x": 7,
"y": 8,
"z": 1
}
]
},
"type": "topology",
"version": "ANYSTR"
}

View File

@ -0,0 +1,54 @@
{
"name": "1_5_vmware",
"project_id": "4be1f3e5-76e5-4223-93b7-f37f4091549e",
"revision": 5,
"auto_start": false,
"topology": {
"computes": [
{
"compute_id": "local",
"host": "127.0.0.1",
"name": "Local",
"port": 3080,
"protocol": "http"
}
],
"drawings": [],
"links": [],
"nodes": [
{
"compute_id": "local",
"console": 2000,
"console_type": "serial",
"label": {
"rotation": 0,
"style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;",
"text": "GNS3 VM",
"x": 5,
"y": -25
},
"name": "GNS3 VM",
"node_id": "9e06d0ce-e8df-4f38-bdfa-7c83e19a91c1",
"node_type": "vmware",
"port_name_format": "Ethernet{0}",
"port_segment_size": 0,
"first_port_name": null,
"properties": {
"acpi_shutdown": false,
"adapter_type": "e1000",
"adapters": 1,
"headless": false,
"use_any_adapter": false,
"enable_remote_console": false,
"vmx_path": "/Users/bob/Documents/Virtual Machines.localized/GNS3 VM.vmwarevm/GNS3 VM.vmx"
},
"symbol": ":/symbols/vmware_guest.svg",
"x": 7,
"y": 8,
"z": 1
}
]
},
"type": "topology",
"version": "ANYSTR"
}