mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Prevent error when quick close of gns3 server after docker usage
Fix #382
This commit is contained in:
parent
8cf55166cb
commit
061b459abe
@ -44,6 +44,9 @@ class Docker(BaseManager):
|
|||||||
# Allow locking during ubridge operations
|
# Allow locking during ubridge operations
|
||||||
self.ubridge_lock = asyncio.Lock()
|
self.ubridge_lock = asyncio.Lock()
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self._connector.close()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def query(self, method, path, data={}, params={}):
|
def query(self, method, path, data={}, params={}):
|
||||||
"""
|
"""
|
||||||
|
@ -248,6 +248,7 @@ class DockerVM(BaseVM):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
"""Stops this Docker container."""
|
"""Stops this Docker container."""
|
||||||
|
|
||||||
|
try:
|
||||||
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
||||||
yield from self._ubridge_hypervisor.stop()
|
yield from self._ubridge_hypervisor.stop()
|
||||||
|
|
||||||
@ -262,6 +263,10 @@ class DockerVM(BaseVM):
|
|||||||
yield from self.manager.query("POST", "containers/{}/stop".format(self._cid), params={"t": 5})
|
yield from self.manager.query("POST", "containers/{}/stop".format(self._cid), params={"t": 5})
|
||||||
log.info("Docker container '{name}' [{image}] stopped".format(
|
log.info("Docker container '{name}' [{image}] stopped".format(
|
||||||
name=self._name, image=self._image))
|
name=self._name, image=self._image))
|
||||||
|
# Ignore runtime error because when closing the server
|
||||||
|
except RuntimeError as e:
|
||||||
|
log.debug("Docker runtime error when closing: {}".format(str(e)))
|
||||||
|
return
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def pause(self):
|
def pause(self):
|
||||||
@ -282,6 +287,8 @@ class DockerVM(BaseVM):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def remove(self):
|
def remove(self):
|
||||||
"""Removes this Docker container."""
|
"""Removes this Docker container."""
|
||||||
|
|
||||||
|
try:
|
||||||
state = yield from self._get_container_state()
|
state = yield from self._get_container_state()
|
||||||
if state == "paused":
|
if state == "paused":
|
||||||
yield from self.unpause()
|
yield from self.unpause()
|
||||||
@ -300,6 +307,10 @@ class DockerVM(BaseVM):
|
|||||||
for nio in adapter.ports.values():
|
for nio in adapter.ports.values():
|
||||||
if nio and isinstance(nio, NIOUDP):
|
if nio and isinstance(nio, NIOUDP):
|
||||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||||
|
# Ignore runtime error because when closing the server
|
||||||
|
except RuntimeError as e:
|
||||||
|
log.debug("Docker runtime error when closing: {}".format(str(e)))
|
||||||
|
return
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def close(self):
|
def close(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user