From e962717448c2086abc21d9733930baea8048d8fc Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 14 Apr 2019 17:42:20 +0700 Subject: [PATCH] Fix bug when GNS3 VM were not saved. Fix tests. --- gns3server/controller/compute.py | 6 +++++- gns3server/handlers/api/controller/gns3_vm_handler.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index f739553f..419d3e07 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -74,6 +74,7 @@ class Compute: self._user = None self._password = None self._connected = False + self._notifications = None self._closed = False # Close mean we are destroying the compute node self._controller = controller self._set_auth(user, password) @@ -155,7 +156,8 @@ class Compute: if self._http_session and not self._http_session.closed: await self._http_session.close() try: - await self._notifications + if self._notifications: + await self._notifications except asyncio.CancelledError: pass self._closed = True @@ -448,6 +450,8 @@ class Compute: pass self._connected = False break + except aiohttp.client_exceptions.ClientResponseError as e: + log.error("Client response error received on compute WebSocket '{}': {}".format(ws_url,e)) finally: log.info("Connection closed to compute WebSocket '{}'".format(ws_url)) diff --git a/gns3server/handlers/api/controller/gns3_vm_handler.py b/gns3server/handlers/api/controller/gns3_vm_handler.py index d1c56b6a..5506260d 100644 --- a/gns3server/handlers/api/controller/gns3_vm_handler.py +++ b/gns3server/handlers/api/controller/gns3_vm_handler.py @@ -72,7 +72,9 @@ class GNS3VMHandler: }) async def update(request, response): - gns3_vm = Controller().instance().gns3vm + controller = Controller().instance() + gns3_vm = controller.gns3vm await gns3_vm.update_settings(request.json) + controller.save() response.json(gns3_vm) response.set_status(201)