mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-05 14:51:13 +02:00
Drop console_type serial, and enable_remote_console for Vbox and VMware
Ref #748
This commit is contained in:
28 files changed
+163
-110
No files matched your search
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user