From 40151cd1fe1011faab69abd4570609046aec3452 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 9 Jun 2018 21:47:36 +0700 Subject: [PATCH] Fix switching console type from telnet to VNC throws error. Fixes #2489. --- gns3server/compute/base_node.py | 2 +- gns3server/controller/node.py | 2 +- gns3server/handlers/api/compute/qemu_handler.py | 3 ++- gns3server/handlers/api/compute/virtualbox_handler.py | 3 +++ gns3server/handlers/api/compute/vmware_handler.py | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gns3server/compute/base_node.py b/gns3server/compute/base_node.py index ff995a4e..e7a95a26 100644 --- a/gns3server/compute/base_node.py +++ b/gns3server/compute/base_node.py @@ -442,7 +442,7 @@ class BaseNode: return if self._console_type == "vnc" and console is not None and console < 5900: - raise NodeError("VNC console require a port superior or equal to 5900 currently it's {}".format(console)) + raise NodeError("VNC console require a port superior or equal to 5900, current port is {}".format(console)) if self._console: self._manager.port_manager.release_tcp_port(self._console, self._project) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index d081f10f..1db2206d 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -387,7 +387,7 @@ class Node: if prop not in self.CONTROLLER_ONLY_PROPERTIES: update_compute = True - # We update properties on the compute and wait for the anwser from the compute node + # We update properties on the compute and wait for the answer from the compute node if prop == "properties": compute_properties = kwargs[prop] else: diff --git a/gns3server/handlers/api/compute/qemu_handler.py b/gns3server/handlers/api/compute/qemu_handler.py index 6e2c1e5c..9d406bf5 100644 --- a/gns3server/handlers/api/compute/qemu_handler.py +++ b/gns3server/handlers/api/compute/qemu_handler.py @@ -120,7 +120,8 @@ class QEMUHandler: qemu_manager = Qemu.instance() vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) - + # update the console first to avoid issue if updating console type + vm.console = request.json.pop("console", vm.console) for name, value in request.json.items(): if hasattr(vm, name) and getattr(vm, name) != value: setattr(vm, name, value) diff --git a/gns3server/handlers/api/compute/virtualbox_handler.py b/gns3server/handlers/api/compute/virtualbox_handler.py index d42a79bd..42a1f127 100644 --- a/gns3server/handlers/api/compute/virtualbox_handler.py +++ b/gns3server/handlers/api/compute/virtualbox_handler.py @@ -138,6 +138,9 @@ class VirtualBoxHandler: if ram != vm.ram: yield from vm.set_ram(ram) + # update the console first to avoid issue if updating console type + vm.console = request.json.pop("console", vm.console) + for name, value in request.json.items(): if hasattr(vm, name) and getattr(vm, name) != value: setattr(vm, name, value) diff --git a/gns3server/handlers/api/compute/vmware_handler.py b/gns3server/handlers/api/compute/vmware_handler.py index daeb7bf6..45475fe5 100644 --- a/gns3server/handlers/api/compute/vmware_handler.py +++ b/gns3server/handlers/api/compute/vmware_handler.py @@ -106,7 +106,8 @@ class VMwareHandler: vmware_manager = VMware.instance() vm = vmware_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) - + # update the console first to avoid issue if updating console type + vm.console = request.json.pop("console", vm.console) for name, value in request.json.items(): if hasattr(vm, name) and getattr(vm, name) != value: setattr(vm, name, value)