From 610dee957d0d25ba972e1ed93aa574ad508fdfaa Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 18 Feb 2015 17:48:02 -0700 Subject: [PATCH 1/2] Use HTTP error 409 instead of 500 for VMError. --- gns3server/modules/dynamips/nodes/router.py | 4 ++-- gns3server/web/route.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index 910430a9..dcfaac80 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -1495,10 +1495,10 @@ class Router(BaseVM): try: reply = yield from self._hypervisor.send("vm extract_config {}".format(self._name)) - reply = reply[0].rsplit(' ', 2)[-2:] - except IOError: + except DynamipsError: #for some reason Dynamips gets frozen when it does not find the magic number in the NVRAM file. return None, None + reply = reply[0].rsplit(' ', 2)[-2:] startup_config = reply[0][1:-1] # get statup-config and remove single quotes private_config = reply[1][1:-1] # get private-config and remove single quotes return startup_config, private_config diff --git a/gns3server/web/route.py b/gns3server/web/route.py index 4bf5679b..1fee37c7 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -115,8 +115,8 @@ class Route(object): except VMError as e: log.error("VM error detected: {type}".format(type=type(e)), exc_info=1) response = Response(route=route) - response.set_status(500) - response.json({"message": str(e), "status": 500}) + response.set_status(409) + response.json({"message": str(e), "status": 409}) except Exception as e: log.error("Uncaught exception detected: {type}".format(type=type(e)), exc_info=1) response = Response(route=route) From 3d1363150ebf5af4e1ce70d02681780aacf9672f Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 18 Feb 2015 18:24:35 -0700 Subject: [PATCH 2/2] Fixes ghost file path. --- gns3server/modules/dynamips/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index c10fce52..03eb326c 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -435,7 +435,7 @@ class Dynamips(BaseManager): except DynamipsError as e: log.warn("Could not create ghost instance: {}".format(e)) - if vm.ghost_file != ghost_file and os.path.isfile(ghost_file): + if vm.ghost_file != ghost_file and os.path.isfile(ghost_file_path): # set the ghost file to the router yield from vm.set_ghost_status(2) yield from vm.set_ghost_file(ghost_file)