mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 04:47:54 +00:00
Fix crash when project sets 'auto_open' option and a remote GNS3 VM is used. Fixes https://github.com/GNS3/gns3-gui/issues/3014
This commit is contained in:
parent
1cbed45f16
commit
62130c116a
@ -99,11 +99,13 @@ class Controller:
|
|||||||
await self.add_compute(**c)
|
await self.add_compute(**c)
|
||||||
except (aiohttp.web.HTTPError, KeyError):
|
except (aiohttp.web.HTTPError, KeyError):
|
||||||
pass # Skip not available servers at loading
|
pass # Skip not available servers at loading
|
||||||
await self.load_projects()
|
|
||||||
try:
|
try:
|
||||||
await self.gns3vm.auto_start_vm()
|
await self.gns3vm.auto_start_vm()
|
||||||
except GNS3VMError as e:
|
except GNS3VMError as e:
|
||||||
log.warning(str(e))
|
log.warning(str(e))
|
||||||
|
|
||||||
|
await self.load_projects()
|
||||||
await self._project_auto_open()
|
await self._project_auto_open()
|
||||||
|
|
||||||
def _update_config(self):
|
def _update_config(self):
|
||||||
@ -238,7 +240,7 @@ class Controller:
|
|||||||
if file.endswith(".gns3"):
|
if file.endswith(".gns3"):
|
||||||
try:
|
try:
|
||||||
await self.load_project(os.path.join(project_dir, file), load=False)
|
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
|
pass # Skip not compatible projects
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.error(str(e))
|
log.error(str(e))
|
||||||
|
@ -427,7 +427,7 @@ class Compute:
|
|||||||
ws_url = self._getUrl("/notifications/ws")
|
ws_url = self._getUrl("/notifications/ws")
|
||||||
try:
|
try:
|
||||||
async with self._session().ws_connect(ws_url, auth=self._auth, heartbeat=10) as ws:
|
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:
|
async for response in ws:
|
||||||
if response.type == aiohttp.WSMsgType.TEXT:
|
if response.type == aiohttp.WSMsgType.TEXT:
|
||||||
msg = json.loads(response.data)
|
msg = json.loads(response.data)
|
||||||
@ -445,15 +445,15 @@ class Compute:
|
|||||||
if response.type == aiohttp.WSMsgType.CLOSE:
|
if response.type == aiohttp.WSMsgType.CLOSE:
|
||||||
await ws.close()
|
await ws.close()
|
||||||
elif response.type == aiohttp.WSMsgType.ERROR:
|
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:
|
elif response.type == aiohttp.WSMsgType.CLOSED:
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
except aiohttp.client_exceptions.ClientResponseError as e:
|
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:
|
finally:
|
||||||
self._connected = False
|
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)
|
# 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:
|
if not hasattr(sys, "_called_from_test") or not sys._called_from_test:
|
||||||
|
@ -51,7 +51,6 @@ class RemoteGNS3VM(BaseGNS3VM):
|
|||||||
|
|
||||||
if not self.vmname:
|
if not self.vmname:
|
||||||
return
|
return
|
||||||
vm_compute = None
|
|
||||||
for compute in self._controller.computes.values():
|
for compute in self._controller.computes.values():
|
||||||
if compute.name == self.vmname:
|
if compute.name == self.vmname:
|
||||||
self.running = True
|
self.running = True
|
||||||
|
@ -133,7 +133,7 @@ class CrashReport:
|
|||||||
for key, value in extra_context.items():
|
for key, value in extra_context.items():
|
||||||
scope.set_extra(key, value)
|
scope.set_extra(key, value)
|
||||||
|
|
||||||
def capture_exception(self, request):
|
def capture_exception(self, request=None):
|
||||||
|
|
||||||
if not SENTRY_SDK_AVAILABLE:
|
if not SENTRY_SDK_AVAILABLE:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user