mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Patch hostname in configuration file even if name is unsync
Ref https://github.com/GNS3/gns3-gui/issues/1889
This commit is contained in:
5 files changed
+23
-6
No files matched your search
@@ -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)
|
||||
|
||||
@@ -307,7 +307,7 @@ class IOUVM(BaseNode):
|
||||
|
||||
if self.startup_config_file:
|
||||
content = self.startup_config_content
|
||||
content = content.replace(self._name, new_name)
|
||||
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)
|
||||
|
||||
@@ -171,6 +171,7 @@ class VPCSVM(BaseNode):
|
||||
if self.script_file:
|
||||
content = self.startup_script
|
||||
content = content.replace(self._name, new_name)
|
||||
content = re.sub(r"^set pcname .+$", "set pcname " + new_name, content, flags=re.MULTILINE)
|
||||
self.startup_script = content
|
||||
|
||||
super(VPCSVM, VPCSVM).name.__set__(self, new_name)
|
||||
|
||||
Reference in new issue
Block a user