From a47fa83cec90014c18b35b30d85947a78147ea9c Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 8 Jan 2020 01:24:47 +0800 Subject: [PATCH] Fix renaming IOL hostname replaces %h only in a single place. Fixes #1707 --- gns3server/compute/dynamips/nodes/router.py | 2 +- gns3server/compute/iou/iou_vm.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gns3server/compute/dynamips/nodes/router.py b/gns3server/compute/dynamips/nodes/router.py index c82bcfd9..e66e0339 100644 --- a/gns3server/compute/dynamips/nodes/router.py +++ b/gns3server/compute/dynamips/nodes/router.py @@ -1532,7 +1532,7 @@ class Router(BaseNode): try: with open(self.startup_config_path, "r+", encoding="utf-8", errors="replace") as f: old_config = f.read() - new_config = re.sub(r"^hostname .+$", "hostname " + new_name, old_config, flags=re.MULTILINE) + new_config = re.sub(r"hostname .+$", "hostname " + new_name, old_config, flags=re.MULTILINE) f.seek(0) f.write(new_config) except OSError as e: diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index 6db57636..9db7c88d 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -325,7 +325,7 @@ class IOUVM(BaseNode): if self.startup_config_file: content = self.startup_config_content - content = re.sub(r"^hostname .+$", "hostname " + new_name, content, flags=re.MULTILINE) + content = re.sub(r"hostname .+$", "hostname " + new_name, content, flags=re.MULTILINE) self.startup_config_content = content super(IOUVM, IOUVM).name.__set__(self, new_name)