From 62130c116a9a11107da1b1ebd16fee697611b6d2 Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 9 Jul 2020 20:13:21 +0930 Subject: [PATCH] Fix crash when project sets 'auto_open' option and a remote GNS3 VM is used. Fixes https://github.com/GNS3/gns3-gui/issues/3014 --- gns3server/controller/__init__.py | 6 ++++-- gns3server/controller/compute.py | 8 ++++---- gns3server/controller/gns3vm/remote_gns3_vm.py | 1 - gns3server/crash_report.py | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 36f6422b..82910589 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -99,11 +99,13 @@ class Controller: await self.add_compute(**c) except (aiohttp.web.HTTPError, KeyError): pass # Skip not available servers at loading - await self.load_projects() + try: await self.gns3vm.auto_start_vm() except GNS3VMError as e: log.warning(str(e)) + + await self.load_projects() await self._project_auto_open() def _update_config(self): @@ -238,7 +240,7 @@ class Controller: if file.endswith(".gns3"): try: await self.load_project(os.path.join(project_dir, file), load=False) - except (aiohttp.web.HTTPConflict, NotImplementedError): + except (aiohttp.web.HTTPConflict, aiohttp.web.HTTPNotFound, NotImplementedError): pass # Skip not compatible projects except OSError as e: log.error(str(e)) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 38d158d0..39eb961b 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -427,7 +427,7 @@ class Compute: ws_url = self._getUrl("/notifications/ws") try: async with self._session().ws_connect(ws_url, auth=self._auth, heartbeat=10) as ws: - log.info("Connected to compute WebSocket '{}'".format(ws_url)) + log.info("Connected to compute '{}' WebSocket '{}'".format(self._id, ws_url)) async for response in ws: if response.type == aiohttp.WSMsgType.TEXT: msg = json.loads(response.data) @@ -445,15 +445,15 @@ class Compute: if response.type == aiohttp.WSMsgType.CLOSE: await ws.close() elif response.type == aiohttp.WSMsgType.ERROR: - log.error("Error received on compute WebSocket '{}': {}".format(ws_url, ws.exception())) + log.error("Error received on compute '{}' WebSocket '{}': {}".format(self._id, ws_url, ws.exception())) elif response.type == aiohttp.WSMsgType.CLOSED: pass break except aiohttp.client_exceptions.ClientResponseError as e: - log.error("Client response error received on compute WebSocket '{}': {}".format(ws_url,e)) + log.error("Client response error received on compute '{}' WebSocket '{}': {}".format(self._id, ws_url,e)) finally: self._connected = False - log.info("Connection closed to compute WebSocket '{}'".format(ws_url)) + log.info("Connection closed to compute '{}' WebSocket '{}'".format(self._id, ws_url)) # Try to reconnect after 1 second if server unavailable only if not during tests (otherwise we create a ressources usage bomb) if not hasattr(sys, "_called_from_test") or not sys._called_from_test: diff --git a/gns3server/controller/gns3vm/remote_gns3_vm.py b/gns3server/controller/gns3vm/remote_gns3_vm.py index 8ef533e4..48a89d53 100644 --- a/gns3server/controller/gns3vm/remote_gns3_vm.py +++ b/gns3server/controller/gns3vm/remote_gns3_vm.py @@ -51,7 +51,6 @@ class RemoteGNS3VM(BaseGNS3VM): if not self.vmname: return - vm_compute = None for compute in self._controller.computes.values(): if compute.name == self.vmname: self.running = True diff --git a/gns3server/crash_report.py b/gns3server/crash_report.py index c0fbd0bc..3034d703 100644 --- a/gns3server/crash_report.py +++ b/gns3server/crash_report.py @@ -133,7 +133,7 @@ class CrashReport: for key, value in extra_context.items(): scope.set_extra(key, value) - def capture_exception(self, request): + def capture_exception(self, request=None): if not SENTRY_SDK_AVAILABLE: return