From 879ed9e4e6be0272f04619e5fa6ffcd80634b8e5 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 25 Mar 2015 14:58:04 -0600 Subject: [PATCH] Fixes issue when exporting IOS router configs. --- gns3server/handlers/api/dynamips_vm_handler.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gns3server/handlers/api/dynamips_vm_handler.py b/gns3server/handlers/api/dynamips_vm_handler.py index 412fbcac..84d14553 100644 --- a/gns3server/handlers/api/dynamips_vm_handler.py +++ b/gns3server/handlers/api/dynamips_vm_handler.py @@ -357,12 +357,16 @@ class DynamipsVMHandler: project_id=request.match_info["project_id"]) startup_config, private_config = yield from vm.extract_config() - startup_config_content = base64.decodebytes(startup_config.encode("utf-8")).decode("utf-8") - private_config_content = base64.decodebytes(private_config.encode("utf-8")).decode("utf-8") + result = {} + if startup_config: + startup_config_content = base64.decodebytes(startup_config.encode("utf-8")).decode("utf-8") + result["startup_config_content"] = startup_config_content + if private_config: + private_config_content = base64.decodebytes(private_config.encode("utf-8")).decode("utf-8") + result["private_config_content"] = private_config_content response.set_status(200) - response.json({"startup_config_content": startup_config_content, - "private_config_content": private_config_content}) + response.json(result) @Route.post( r"/projects/{project_id}/dynamips/vms/{vm_id}/configs/save",