From 4a2dfb0037b2b7b2af87125b08657f582f2ce206 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 6 Sep 2017 18:12:22 +0700 Subject: [PATCH] Do not prevent a project to be deleted. Fixes #2237. --- gns3server/controller/project.py | 7 ++++++- gns3server/web/route.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index f486d348..5845321e 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -680,8 +680,13 @@ class Project: @asyncio.coroutine def delete(self): + if self._status != "opened": - yield from self.open() + try: + yield from self.open() + except aiohttp.web.HTTPConflict as e: + # ignore missing images or other conflicts when deleting a project + log.warning("Conflict while deleting project: {}".format(e.text)) yield from self.delete_on_computes() yield from self.close() try: diff --git a/gns3server/web/route.py b/gns3server/web/route.py index ebf67e34..97adbf4a 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -211,12 +211,12 @@ class Route(object): response = Response(request=request, route=route) response.set_status(409) response.json({"message": str(e), "status": 409, "exception": e.__class__.__name__}) - except (ImageMissingError) as e: + except ImageMissingError as e: log.error("Image missing error detected: {}".format(e.image)) response = Response(request=request, route=route) response.set_status(409) response.json({"message": str(e), "status": 409, "image": e.image, "exception": e.__class__.__name__}) - except asyncio.futures.CancelledError as e: + except asyncio.futures.CancelledError: response = Response(request=request, route=route) response.set_status(408) response.json({"message": "Request canceled", "status": 408})