mirror of
https://github.com/GNS3/gns3-server
synced 2025-01-11 08:30:57 +00:00
Ensure in all cases the docker console is closed before restart
Fix https://github.com/GNS3/gns3-gui/issues/1226
This commit is contained in:
parent
c7d58eb3b3
commit
28f7c2a1cd
@ -326,6 +326,8 @@ class DockerVM(BaseVM):
|
||||
if state == "paused":
|
||||
yield from self.unpause()
|
||||
else:
|
||||
yield from self._clean_servers()
|
||||
|
||||
result = yield from self.manager.query("POST", "containers/{}/start".format(self._cid))
|
||||
|
||||
namespace = yield from self._get_namespace()
|
||||
@ -473,16 +475,23 @@ class DockerVM(BaseVM):
|
||||
log.info("Docker container '{name}' [{image}] restarted".format(
|
||||
name=self._name, image=self._image))
|
||||
|
||||
@asyncio.coroutine
|
||||
def _clean_servers(self):
|
||||
"""
|
||||
Clean the list of running console servers
|
||||
"""
|
||||
if len(self._telnet_servers) > 0:
|
||||
for telnet_server in self._telnet_servers:
|
||||
telnet_server.close()
|
||||
yield from telnet_server.wait_closed()
|
||||
self._telnet_servers = []
|
||||
|
||||
@asyncio.coroutine
|
||||
def stop(self):
|
||||
"""Stops this Docker container."""
|
||||
|
||||
try:
|
||||
if len(self._telnet_servers) > 0:
|
||||
for telnet_server in self._telnet_servers:
|
||||
telnet_server.close()
|
||||
yield from telnet_server.wait_closed()
|
||||
self._telnet_servers = []
|
||||
yield from self._clean_servers()
|
||||
|
||||
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
||||
yield from self._ubridge_hypervisor.stop()
|
||||
|
Loading…
Reference in New Issue
Block a user