From f2ff933b203b27f988a613dcb6aae8e3836cb1d6 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 5 Feb 2015 11:58:10 -0700 Subject: [PATCH] Fixes console and close in VirtualBox VM. --- gns3server/modules/virtualbox/virtualbox_vm.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gns3server/modules/virtualbox/virtualbox_vm.py b/gns3server/modules/virtualbox/virtualbox_vm.py index bc59ab6d..924dbfb2 100644 --- a/gns3server/modules/virtualbox/virtualbox_vm.py +++ b/gns3server/modules/virtualbox/virtualbox_vm.py @@ -327,7 +327,7 @@ class VirtualBoxVM(BaseVM): # VM is already closed return - self.stop() + yield from self.stop() if self._console: self._manager.port_manager.release_console_port(self._console) @@ -450,6 +450,11 @@ class VirtualBoxVM(BaseVM): # yield from self._modify_vm('--name "{}"'.format(vmname)) self._vmname = vmname + @asyncio.coroutine + def rename(self): + + pass + @asyncio.coroutine def set_adapters(self, adapters): """ @@ -494,7 +499,8 @@ class VirtualBoxVM(BaseVM): """ self._adapter_start_index = adapter_start_index - self.adapters = self.adapters # this forces to recreate the adapter list with the correct index + # TODO: get rid of adapter start index + #self.adapters = self.adapters # this forces to recreate the adapter list with the correct index log.info("VirtualBox VM '{name}' [{id}]: adapter start index changed to {index}".format(name=self.name, id=self.id, index=adapter_start_index)) @@ -518,7 +524,6 @@ class VirtualBoxVM(BaseVM): """ self._adapter_type = adapter_type - log.info("VirtualBox VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.name, id=self.id, adapter_type=adapter_type)) @@ -723,7 +728,7 @@ class VirtualBoxVM(BaseVM): self._serial_pipe = open(pipe_name, "a+b") except OSError as e: raise VirtualBoxError("Could not open the pipe {}: {}".format(pipe_name, e)) - self._telnet_server_thread = TelnetServer(self._vmname, msvcrt.get_osfhandle(self._serial_pipe.fileno()), self._console_host, self._console) + self._telnet_server_thread = TelnetServer(self._vmname, msvcrt.get_osfhandle(self._serial_pipe.fileno()), self._manager.port_manager.console_host, self._console) self._telnet_server_thread.start() else: try: @@ -731,7 +736,7 @@ class VirtualBoxVM(BaseVM): self._serial_pipe.connect(pipe_name) except OSError as e: raise VirtualBoxError("Could not connect to the pipe {}: {}".format(pipe_name, e)) - self._telnet_server_thread = TelnetServer(self._vmname, self._serial_pipe, self._console_host, self._console) + self._telnet_server_thread = TelnetServer(self._vmname, self._serial_pipe, self._manager.port_manager.console_host, self._console) self._telnet_server_thread.start() def _stop_remote_console(self):