Patch hostname in configuration file even if name is unsync

Ref https://github.com/GNS3/gns3-gui/issues/1889
This commit is contained in:
Julien Duponchelle
2017-02-27 12:48:05 +01:00
parent 8fd59c7967
commit 70e2b87ff0
5 changed files with 23 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import asyncio
import time
import sys
import os
import re
import glob
import shlex
import base64
@ -1493,7 +1494,7 @@ class Router(BaseNode):
try:
with open(startup_config_path, "r+", encoding="utf-8", errors="replace") as f:
old_config = f.read()
new_config = old_config.replace(self.name, new_name)
new_config = re.sub(r"^hostname .+$", "hostname " + new_name, old_config, flags=re.MULTILINE)
f.seek(0)
self._startup_config_content = new_config
f.write(new_config)