From d9f44edcaf48972889491d1483f626bf83170986 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 23 Dec 2014 15:29:27 -0700 Subject: [PATCH] Fixes incompatibility for IOS startup-config and private-config paths created on Windows and loaded from a project on Linux/Mac OS X. --- gns3server/modules/dynamips/backends/vm.py | 31 +++++++++++----------- gns3server/modules/qemu/__init__.py | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gns3server/modules/dynamips/backends/vm.py b/gns3server/modules/dynamips/backends/vm.py index 187e61d1..710c1986 100644 --- a/gns3server/modules/dynamips/backends/vm.py +++ b/gns3server/modules/dynamips/backends/vm.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import os -import base64 import ntpath import time from gns3server.modules import IModule @@ -412,36 +411,38 @@ class VM(object): response = {} try: - startup_config_path = os.path.join(router.hypervisor.working_dir, "configs", "i{}_startup-config.cfg".format(router.id)) - private_config_path = os.path.join(router.hypervisor.working_dir, "configs", "i{}_private-config.cfg".format(router.id)) + default_startup_config_path = os.path.join(router.hypervisor.working_dir, "configs", "i{}_startup-config.cfg".format(router.id)) + default_private_config_path = os.path.join(router.hypervisor.working_dir, "configs", "i{}_private-config.cfg".format(router.id)) # a new startup-config has been pushed if "startup_config_base64" in request: # update the request with the new local startup-config path - request["startup_config"] = self.create_config_from_base64(request["startup_config_base64"], router, startup_config_path) + request["startup_config"] = self.create_config_from_base64(request["startup_config_base64"], router, default_startup_config_path) # a new private-config has been pushed if "private_config_base64" in request: # update the request with the new local private-config path - request["private_config"] = self.create_config_from_base64(request["private_config_base64"], router, private_config_path) + request["private_config"] = self.create_config_from_base64(request["private_config_base64"], router, default_private_config_path) if "startup_config" in request: - if os.path.isfile(request["startup_config"]) and request["startup_config"] != startup_config_path: + startup_config_path = request["startup_config"].replace("\\", '/') + if os.path.isfile(startup_config_path) and startup_config_path != default_startup_config_path: # this is a local file set in the GUI - request["startup_config"] = self.create_config_from_file(request["startup_config"], router, startup_config_path) - router.set_config(request["startup_config"]) + startup_config_path = self.create_config_from_file(startup_config_path, router, default_startup_config_path) + router.set_config(startup_config_path) else: - router.set_config(request["startup_config"]) - response["startup_config"] = request["startup_config"] + router.set_config(startup_config_path) + response["startup_config"] = startup_config_path if "private_config" in request: - if os.path.isfile(request["private_config"]) and request["private_config"] != private_config_path: + private_config_path = request["private_config"].replace("\\", '/') + if os.path.isfile(private_config_path) and private_config_path != default_private_config_path: # this is a local file set in the GUI - request["private_config"] = self.create_config_from_file(request["private_config"], router, private_config_path) - router.set_config(router.startup_config, request["private_config"]) + private_config_path = self.create_config_from_file(private_config_path, router, default_private_config_path) + router.set_config(router.startup_config, private_config_path) else: - router.set_config(router.startup_config, request["private_config"]) - response["private_config"] = request["private_config"] + router.set_config(router.startup_config, private_config_path) + response["private_config"] = private_config_path except DynamipsError as e: self.send_custom_error(str(e)) diff --git a/gns3server/modules/qemu/__init__.py b/gns3server/modules/qemu/__init__.py index 96e43e3f..beaac4ef 100644 --- a/gns3server/modules/qemu/__init__.py +++ b/gns3server/modules/qemu/__init__.py @@ -74,7 +74,7 @@ class Qemu(IModule): self._udp_end_port_range = qemu_config.get("udp_end_port_range", 45500) self._host = qemu_config.get("host", kwargs["host"]) self._console_host = qemu_config.get("console_host", kwargs["console_host"]) - self._monitor_host = qemu_config.get("monitor_host", "0.0.0.0") + self._monitor_host = qemu_config.get("monitor_host", "127.0.0.1") self._projects_dir = kwargs["projects_dir"] self._tempdir = kwargs["temp_dir"] self._working_dir = self._projects_dir