Merge branch 'master' into unstable

This commit is contained in:
Julien Duponchelle
2015-05-14 19:29:30 +02:00
8 changed files with 90 additions and 27 deletions

View File

@ -368,15 +368,16 @@ class DynamipsVMHandler:
else:
# nvram doesn't contain anything if the router has not been started at least once
# in this case just use the startup-config file
startup_config_path = os.path.join(module_workdir, vm.startup_config)
if os.path.exists(startup_config_path):
try:
with open(startup_config_path, "rb") as f:
content = f.read().decode("utf-8", errors='replace')
if content:
result["startup_config_content"] = content
except OSError as e:
raise DynamipsError("Could not read the startup-config {}: {}".format(startup_config_path, e))
if vm.startup_config:
startup_config_path = os.path.join(module_workdir, vm.startup_config)
if os.path.isfile(startup_config_path):
try:
with open(startup_config_path, "rb") as f:
content = f.read().decode("utf-8", errors='replace')
if content:
result["startup_config_content"] = content
except OSError as e:
raise DynamipsError("Could not read the startup-config {}: {}".format(startup_config_path, e))
if private_config_base64:
private_config_content = base64.b64decode(private_config_base64).decode("utf-8", errors='replace')
@ -384,15 +385,16 @@ class DynamipsVMHandler:
else:
# nvram doesn't contain anything if the router has not been started at least once
# in this case just use the private-config file
private_config_path = os.path.join(module_workdir, vm.private_config)
if os.path.exists(private_config_path):
try:
with open(private_config_path, "rb") as f:
content = f.read().decode("utf-8", errors='replace')
if content:
result["private_config_content"] = content
except OSError as e:
raise DynamipsError("Could not read the private-config {}: {}".format(private_config_path, e))
if vm.private_config:
private_config_path = os.path.join(module_workdir, vm.private_config)
if os.path.isfile(private_config_path):
try:
with open(private_config_path, "rb") as f:
content = f.read().decode("utf-8", errors='replace')
if content:
result["private_config_content"] = content
except OSError as e:
raise DynamipsError("Could not read the private-config {}: {}".format(private_config_path, e))
response.set_status(200)
response.json(result)