1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Fixes inconsistencies with startup and private config paths when renaming an IOS router.

This commit is contained in:
grossmj 2014-06-18 07:22:57 -06:00
parent 587ddf7646
commit 49506ada3f
4 changed files with 8 additions and 14 deletions

View File

@ -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:

View File

@ -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,

View File

@ -373,7 +373,7 @@ class IOU(IModule):
if not iou_instance:
return
config_path = os.path.join(iou_instance.working_dir, "initial-config")
config_path = os.path.join(iou_instance.working_dir, "initial-config.cfg")
try:
if "initial_config_base64" in request:
# a new initial-config has been pushed

View File

@ -208,9 +208,9 @@ class IOUDevice(object):
new_working_dir,
e))
if self._intial_config:
if self._initial_config:
# update the initial-config
config_path = os.path.join(self._working_dir, "initial-config")
config_path = os.path.join(self._working_dir, "initial-config.cfg")
if os.path.isfile(config_path):
try:
with open(config_path, "r+", errors="replace") as f: