From 41d7570b24082c145270cfcdda7579c3704edc1e Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 28 Feb 2017 12:08:47 +0100 Subject: [PATCH] Load local server before anything else --- gns3server/controller/__init__.py | 6 ++++-- tests/controller/test_controller.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index e159b1ac..efc62bca 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -53,9 +53,10 @@ class Controller: @asyncio.coroutine def start(self): log.info("Start controller") - yield from self.load() + server_config = Config.instance().get_section_config("Server") host = server_config.get("host", "localhost") + # If console_host is 0.0.0.0 client will use the ip they use # to connect to the controller console_host = host @@ -70,6 +71,7 @@ class Controller: user=server_config.get("user", ""), password=server_config.get("password", ""), force=True) + yield from self._load_controller_settings() yield from self.load_projects() yield from self.gns3vm.auto_start_vm() yield from self._project_auto_open() @@ -116,7 +118,7 @@ class Controller: json.dump(data, f, indent=4) @asyncio.coroutine - def load(self): + def _load_controller_settings(self): """ Reload the controller configuration from disk """ diff --git a/tests/controller/test_controller.py b/tests/controller/test_controller.py index 3227c54f..3ae347a2 100644 --- a/tests/controller/test_controller.py +++ b/tests/controller/test_controller.py @@ -42,7 +42,7 @@ def test_save(controller, controller_config_path): assert data["gns3vm"] == controller.gns3vm.__json__() -def test_load(controller, controller_config_path, async_run): +def test_load_controller_settings(controller, controller_config_path, async_run): controller.save() with open(controller_config_path) as f: data = json.load(f) @@ -60,7 +60,7 @@ def test_load(controller, controller_config_path, async_run): data["gns3vm"] = {"vmname": "Test VM"} with open(controller_config_path, "w+") as f: json.dump(data, f) - async_run(controller.load()) + async_run(controller._load_controller_settings()) assert controller.settings["IOU"] assert controller.computes["test1"].__json__() == { "compute_id": "test1", @@ -104,7 +104,7 @@ def test_import_computes_1_x(controller, controller_config_path, async_run): with open(os.path.join(config_dir, "gns3_gui.conf"), "w+") as f: json.dump(gns3_gui_conf, f) - async_run(controller.load()) + async_run(controller._load_controller_settings()) for compute in controller.computes.values(): if compute.id != "local": assert len(compute.id) == 36 @@ -146,7 +146,7 @@ def test_import_gns3vm_1_x(controller, controller_config_path, async_run): json.dump(gns3_gui_conf, f) controller.gns3vm.settings["engine"] = None - async_run(controller.load()) + async_run(controller._load_controller_settings()) assert controller.gns3vm.settings["engine"] == "vmware" assert controller.gns3vm.settings["enable"] assert controller.gns3vm.settings["headless"] @@ -202,7 +202,7 @@ def test_import_remote_gns3vm_1_x(controller, controller_config_path, async_run) json.dump(gns3_gui_conf, f) with asyncio_patch("gns3server.controller.compute.Compute.connect"): - async_run(controller.load()) + async_run(controller._load_controller_settings()) assert controller.gns3vm.settings["engine"] == "remote" assert controller.gns3vm.settings["vmname"] == "http://127.0.0.1:3081"