mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Extract private-config only when necessary (content is different than the default). Fixes #520.
This commit is contained in:
parent
cb6df28f59
commit
1ae17b74df
@ -1521,7 +1521,6 @@ class Router(BaseVM):
|
||||
if startup_config_base64:
|
||||
if not self.startup_config:
|
||||
self._startup_config = os.path.join("configs", "i{}_startup-config.cfg".format(self._dynamips_id))
|
||||
|
||||
try:
|
||||
config = base64.b64decode(startup_config_base64).decode("utf-8", errors="replace")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
@ -1532,13 +1531,11 @@ class Router(BaseVM):
|
||||
except (binascii.Error, OSError) as e:
|
||||
raise DynamipsError("Could not save the startup configuration {}: {}".format(config_path, e))
|
||||
|
||||
if private_config_base64:
|
||||
if private_config_base64 and base64.b64decode(private_config_base64) != b'\nkerberos password \nend\n':
|
||||
if not self.private_config:
|
||||
self._private_config = os.path.join("configs", "i{}_private-config.cfg".format(self._dynamips_id))
|
||||
|
||||
try:
|
||||
config = base64.b64decode(private_config_base64).decode("utf-8", errors="replace")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
config_path = os.path.join(module_workdir, self.private_config)
|
||||
with open(config_path, "wb") as f:
|
||||
log.info("saving private-config to {}".format(self.private_config))
|
||||
|
@ -108,7 +108,6 @@ class IOUVM(BaseVM):
|
||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||
|
||||
yield from self.stop()
|
||||
self.save_configs()
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
@ -681,6 +680,7 @@ class IOUVM(BaseVM):
|
||||
self._iouyap_process = None
|
||||
|
||||
self._started = False
|
||||
self.save_configs()
|
||||
|
||||
def _terminate_process_iouyap(self):
|
||||
"""
|
||||
@ -1097,7 +1097,7 @@ class IOUVM(BaseVM):
|
||||
if private_config is None:
|
||||
private_config = ''
|
||||
|
||||
# We disallow erasing the startup config file
|
||||
# We disallow erasing the private config file
|
||||
if len(private_config) == 0 and os.path.exists(private_config_path):
|
||||
return
|
||||
|
||||
@ -1204,18 +1204,16 @@ class IOUVM(BaseVM):
|
||||
config_path = os.path.join(self.working_dir, "startup-config.cfg")
|
||||
try:
|
||||
config = startup_config_content.decode("utf-8", errors="replace")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
with open(config_path, "wb") as f:
|
||||
log.info("saving startup-config to {}".format(config_path))
|
||||
f.write(config.encode("utf-8"))
|
||||
except (binascii.Error, OSError) as e:
|
||||
raise IOUError("Could not save the startup configuration {}: {}".format(config_path, e))
|
||||
|
||||
if private_config_content:
|
||||
if private_config_content and private_config_content != b'\nend\n':
|
||||
config_path = os.path.join(self.working_dir, "private-config.cfg")
|
||||
try:
|
||||
config = private_config_content.decode("utf-8", errors="replace")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
with open(config_path, "wb") as f:
|
||||
log.info("saving private-config to {}".format(config_path))
|
||||
f.write(config.encode("utf-8"))
|
||||
|
Loading…
Reference in New Issue
Block a user