mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Automatically extract IOS configs when a project is closed.
This commit is contained in:
1 parent
f44fbd1f16
commit
f6561bf684
3 files changed
+41
-26
No files matched your search
@@ -608,31 +608,7 @@ class VM(object):
|
||||
return
|
||||
|
||||
try:
|
||||
if router.startup_config or router.private_config:
|
||||
|
||||
startup_config_base64, private_config_base64 = router.extract_config()
|
||||
if startup_config_base64:
|
||||
try:
|
||||
config = base64.decodestring(startup_config_base64.encode("utf-8")).decode("utf-8")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
config_path = os.path.join(router.hypervisor.working_dir, router.startup_config)
|
||||
with open(config_path, "w") as f:
|
||||
log.info("saving startup-config to {}".format(router.startup_config))
|
||||
f.write(config)
|
||||
except OSError as e:
|
||||
raise DynamipsError("Could not save the startup configuration {}: {}".format(config_path, e))
|
||||
|
||||
if private_config_base64:
|
||||
try:
|
||||
config = base64.decodestring(private_config_base64.encode("utf-8")).decode("utf-8")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
config_path = os.path.join(router.hypervisor.working_dir, router.private_config)
|
||||
with open(config_path, "w") as f:
|
||||
log.info("saving private-config to {}".format(router.private_config))
|
||||
f.write(config)
|
||||
except OSError as e:
|
||||
raise DynamipsError("Could not save the private configuration {}: {}".format(config_path, e))
|
||||
|
||||
router.save_configs()
|
||||
except DynamipsError as e:
|
||||
log.warn("could not save config to {}: {}".format(router.startup_config, e))
|
||||
|
||||
|
||||
Reference in new issue
Block a user