mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 06:21:15 +02:00
Fixed VPCS base_script_file setting
This commit is contained in:
1 parent
9cc5131024
commit
ec44d70c7b
3 files changed
+25
-42
No files matched your search
@@ -275,6 +275,9 @@ class VPCS(IModule):
|
||||
name = None
|
||||
if "name" in request:
|
||||
name = request["name"]
|
||||
base_script_file = None
|
||||
if "base_script_file" in request:
|
||||
base_script_file = request["base_script_file"]
|
||||
vpcs_path = request["path"]
|
||||
|
||||
try:
|
||||
@@ -285,7 +288,7 @@ class VPCS(IModule):
|
||||
except OSError as e:
|
||||
raise VPCSError("Could not create working directory {}".format(e))
|
||||
|
||||
vpcs_instance = VPCSDevice(vpcs_path, self._working_dir, host=self._host, name=name)
|
||||
vpcs_instance = VPCSDevice(vpcs_path, base_script_file, self._working_dir, host=self._host, name=name)
|
||||
# find a console port
|
||||
if self._current_console_port > self._console_end_port_range:
|
||||
self._current_console_port = self._console_start_port_range
|
||||
@@ -348,7 +351,6 @@ class VPCS(IModule):
|
||||
|
||||
Optional request parameters:
|
||||
- any setting to update
|
||||
- script_file_base64 (script-file base64 encoded)
|
||||
|
||||
Response parameters:
|
||||
- updated settings
|
||||
@@ -366,26 +368,6 @@ class VPCS(IModule):
|
||||
return
|
||||
|
||||
response = {}
|
||||
try:
|
||||
# a new script-file has been pushed
|
||||
if "script_file_base64" in request:
|
||||
config = base64.decodestring(request["script_file_base64"].encode("utf-8")).decode("utf-8")
|
||||
config = "!\n" + config.replace("\r", "")
|
||||
config = config.replace('%h', vpcs_instance.name)
|
||||
config_path = os.path.join(vpcs_instance.working_dir, "script-file")
|
||||
try:
|
||||
with open(config_path, "w") as f:
|
||||
log.info("saving script-file to {}".format(config_path))
|
||||
f.write(config)
|
||||
except OSError as e:
|
||||
raise VPCSError("Could not save the configuration {}: {}".format(config_path, e))
|
||||
# update the request with the new local script-file path
|
||||
request["script_file"] = os.path.basename(config_path)
|
||||
|
||||
except VPCSError as e:
|
||||
self.send_custom_error(str(e))
|
||||
return
|
||||
|
||||
# update the VPCS settings
|
||||
for name, value in request.items():
|
||||
if hasattr(vpcs_instance, name) and getattr(vpcs_instance, name) != value:
|
||||
|
||||
Reference in new issue
Block a user