mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fixes inconsistencies with startup and private config paths when renaming an IOS router.
This commit is contained in:
1 parent
587ddf7646
commit
49506ada3f
4 files changed
+8
-14
No files matched your search
@@ -387,8 +387,8 @@ class VM(object):
|
||||
|
||||
response = {}
|
||||
try:
|
||||
startup_config_path = os.path.join(router.hypervisor.working_dir, "configs", "{}.cfg".format(router.name))
|
||||
private_config_path = os.path.join(router.hypervisor.working_dir, "configs", "{}-private.cfg".format(router.name))
|
||||
startup_config_path = os.path.join(router.hypervisor.working_dir, "configs", "i{}_startup-config.cfg".format(router.id))
|
||||
private_config_path = os.path.join(router.hypervisor.working_dir, "configs", "i{}_private-config.cfg".format(router.id))
|
||||
|
||||
# a new startup-config has been pushed
|
||||
if "startup_config_base64" in request:
|
||||
|
||||
@@ -227,7 +227,7 @@ class Router(object):
|
||||
|
||||
if self._startup_config:
|
||||
# change the hostname in the startup-config
|
||||
startup_config_path = os.path.join(self.hypervisor.working_dir, "configs", "{}.cfg".format(self.name))
|
||||
startup_config_path = os.path.join(self.hypervisor.working_dir, "configs", "i{}_startup-config.cfg".format(self.id))
|
||||
if os.path.isfile(startup_config_path):
|
||||
try:
|
||||
with open(startup_config_path, "r+", errors="replace") as f:
|
||||
@@ -235,15 +235,12 @@ class Router(object):
|
||||
new_config = old_config.replace(self.name, new_name)
|
||||
f.seek(0)
|
||||
f.write(new_config)
|
||||
new_startup_config_path = os.path.join(os.path.dirname(startup_config_path), "{}.cfg".format(new_name))
|
||||
os.rename(startup_config_path, new_startup_config_path)
|
||||
except OSError as e:
|
||||
raise DynamipsError("Could not amend the configuration {}: {}".format(startup_config_path, e))
|
||||
self.set_config(new_startup_config_path)
|
||||
|
||||
if self._private_config:
|
||||
# change the hostname in the startup-config
|
||||
private_config_path = os.path.join(self.hypervisor.working_dir, "configs", "{}-private.cfg".format(self.name))
|
||||
# change the hostname in the private-config
|
||||
private_config_path = os.path.join(self.hypervisor.working_dir, "configs", "i{}_private-config.cfg".format(self.id))
|
||||
if os.path.isfile(private_config_path):
|
||||
try:
|
||||
with open(private_config_path, "r+", errors="replace") as f:
|
||||
@@ -251,11 +248,8 @@ class Router(object):
|
||||
new_config = old_config.replace(self.name, new_name)
|
||||
f.seek(0)
|
||||
f.write(new_config)
|
||||
new_private_config_path = os.path.join(os.path.dirname(private_config_path), "{}-private.cfg".format(new_name))
|
||||
os.rename(private_config_path, new_private_config_path)
|
||||
except OSError as e:
|
||||
raise DynamipsError("Could not amend the configuration {}: {}".format(private_config_path, e))
|
||||
self.set_config(self.startup_config, new_private_config_path)
|
||||
|
||||
new_name = '"' + new_name + '"' # put the new name into quotes to protect spaces
|
||||
self._hypervisor.send("vm rename {name} {new_name}".format(name=self._name,
|
||||
|
||||
Reference in new issue
Block a user