Report GNS3 VM errors to the GUI server summary. Ref #1359.

This commit is contained in:
grossmj 2018-08-28 15:42:06 +07:00
parent 8d4e73d23c
commit 00cf66fb0f
3 changed files with 25 additions and 8 deletions

View File

@ -138,6 +138,14 @@ class Compute:
self._password = None self._password = None
self._auth = aiohttp.BasicAuth(self._user, "") self._auth = aiohttp.BasicAuth(self._user, "")
def set_last_error(self, msg):
"""
Set the last error message for this compute.
:param msg: message
"""
self._last_error = msg
@asyncio.coroutine @asyncio.coroutine
def interfaces(self): def interfaces(self):
""" """

View File

@ -246,13 +246,15 @@ class GNS3VM:
except GNS3VMError as e: except GNS3VMError as e:
# User will receive the error later when they will try to use the node # User will receive the error later when they will try to use the node
try: try:
yield from self._controller.add_compute(compute_id="vm", compute = yield from self._controller.add_compute(compute_id="vm",
name="GNS3 VM ({})".format(self.current_engine().vmname), name="GNS3 VM ({})".format(self.current_engine().vmname),
host=None, host=None,
force=True) force=True)
compute.set_last_error(str(e))
except aiohttp.web.HTTPConflict: except aiohttp.web.HTTPConflict:
pass pass
log.error("Can't start the GNS3 VM: %s", str(e)) log.error("Cannot start the GNS3 VM: {}".format(e))
@asyncio.coroutine @asyncio.coroutine
def exit_vm(self): def exit_vm(self):
@ -290,8 +292,9 @@ class GNS3VM:
yield from engine.start() yield from engine.start()
except Exception as e: except Exception as e:
yield from self._controller.delete_compute("vm") yield from self._controller.delete_compute("vm")
log.error("Can't start the GNS3 VM: {}".format(str(e))) log.error("Cannot start the GNS3 VM: {}".format(str(e)))
yield from compute.update(name="GNS3 VM ({})".format(engine.vmname)) yield from compute.update(name="GNS3 VM ({})".format(engine.vmname))
compute.set_last_error(str(e))
raise e raise e
yield from compute.connect() # we can connect now that the VM has started yield from compute.connect() # we can connect now that the VM has started
yield from compute.update(name="GNS3 VM ({})".format(engine.vmname), yield from compute.update(name="GNS3 VM ({})".format(engine.vmname),

View File

@ -137,7 +137,10 @@ class WebServer:
def signal_handler(signame, *args): def signal_handler(signame, *args):
log.warning("Server has got signal {}, exiting...".format(signame)) log.warning("Server has got signal {}, exiting...".format(signame))
asyncio_ensure_future(self.shutdown_server()) try:
asyncio_ensure_future(self.shutdown_server())
except asyncio.CancelledError:
pass
signals = ["SIGTERM", "SIGINT"] signals = ["SIGTERM", "SIGINT"]
if sys.platform.startswith("win"): if sys.platform.startswith("win"):
@ -295,4 +298,7 @@ class WebServer:
log.warning("TypeError exception in the loop {}".format(e)) log.warning("TypeError exception in the loop {}".format(e))
finally: finally:
if self._loop.is_running(): if self._loop.is_running():
self._loop.run_until_complete(self.shutdown_server()) try:
self._loop.run_until_complete(self.shutdown_server())
except asyncio.CancelledError:
pass