From aeab9780d8e841be1683493097bee1eaaf262933 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 15 Apr 2015 19:49:40 -0600 Subject: [PATCH] Fixes initial-configs that were not restored when opening a project containing IOU VMs. --- gns3server/handlers/api/iou_handler.py | 4 ---- gns3server/modules/iou/iou_vm.py | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gns3server/handlers/api/iou_handler.py b/gns3server/handlers/api/iou_handler.py index 98bd4cf7..acf3b5b1 100644 --- a/gns3server/handlers/api/iou_handler.py +++ b/gns3server/handlers/api/iou_handler.py @@ -59,8 +59,6 @@ class IOUHandler: for name, value in request.json.items(): if hasattr(vm, name) and getattr(vm, name) != value: setattr(vm, name, value) - if "initial_config_content" in request.json: - vm.initial_config = request.json.get("initial_config_content") response.set_status(201) response.json(vm) @@ -108,8 +106,6 @@ class IOUHandler: for name, value in request.json.items(): if hasattr(vm, name) and getattr(vm, name) != value: setattr(vm, name, value) - if "initial_config_content" in request.json: - vm.initial_config = request.json.get("initial_config_content") response.json(vm) @classmethod diff --git a/gns3server/modules/iou/iou_vm.py b/gns3server/modules/iou/iou_vm.py index 305250e0..5edf33a9 100644 --- a/gns3server/modules/iou/iou_vm.py +++ b/gns3server/modules/iou/iou_vm.py @@ -317,9 +317,9 @@ class IOUVM(BaseVM): """ if self.initial_config_file: - content = self.initial_config + content = self.initial_config_content content = content.replace(self._name, new_name) - self.initial_config = content + self.initial_config_content = content super(IOUVM, IOUVM).name.__set__(self, new_name) @@ -939,7 +939,7 @@ class IOUVM(BaseVM): log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e)) @property - def initial_config(self): + def initial_config_content(self): """ Returns the content of the current initial-config file. """ @@ -952,10 +952,10 @@ class IOUVM(BaseVM): with open(config_file) as f: return f.read() except OSError as e: - raise IOUError("Can't read configuration file '{}'".format(config_file)) + raise IOUError("Can't read configuration file '{}': {}".format(config_file, e)) - @initial_config.setter - def initial_config(self, initial_config): + @initial_config_content.setter + def initial_config_content(self, initial_config): """ Update the initial config