Fixes console and close in VirtualBox VM.

This commit is contained in:
Jeremy 2015-02-05 11:58:10 -07:00
parent ab122d969e
commit f2ff933b20

View File

@ -327,7 +327,7 @@ class VirtualBoxVM(BaseVM):
# VM is already closed # VM is already closed
return return
self.stop() yield from self.stop()
if self._console: if self._console:
self._manager.port_manager.release_console_port(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)) # yield from self._modify_vm('--name "{}"'.format(vmname))
self._vmname = vmname self._vmname = vmname
@asyncio.coroutine
def rename(self):
pass
@asyncio.coroutine @asyncio.coroutine
def set_adapters(self, adapters): def set_adapters(self, adapters):
""" """
@ -494,7 +499,8 @@ class VirtualBoxVM(BaseVM):
""" """
self._adapter_start_index = adapter_start_index 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, log.info("VirtualBox VM '{name}' [{id}]: adapter start index changed to {index}".format(name=self.name,
id=self.id, id=self.id,
index=adapter_start_index)) index=adapter_start_index))
@ -518,7 +524,6 @@ class VirtualBoxVM(BaseVM):
""" """
self._adapter_type = adapter_type self._adapter_type = adapter_type
log.info("VirtualBox VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.name, log.info("VirtualBox VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.name,
id=self.id, id=self.id,
adapter_type=adapter_type)) adapter_type=adapter_type))
@ -723,7 +728,7 @@ class VirtualBoxVM(BaseVM):
self._serial_pipe = open(pipe_name, "a+b") self._serial_pipe = open(pipe_name, "a+b")
except OSError as e: except OSError as e:
raise VirtualBoxError("Could not open the pipe {}: {}".format(pipe_name, 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() self._telnet_server_thread.start()
else: else:
try: try:
@ -731,7 +736,7 @@ class VirtualBoxVM(BaseVM):
self._serial_pipe.connect(pipe_name) self._serial_pipe.connect(pipe_name)
except OSError as e: except OSError as e:
raise VirtualBoxError("Could not connect to the pipe {}: {}".format(pipe_name, 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() self._telnet_server_thread.start()
def _stop_remote_console(self): def _stop_remote_console(self):