summaryrefslogtreecommitdiff
path: root/src/helpers/vyos-merge-config.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@sentrium.io>2019-06-12 12:45:00 -0500
committerJohn Estabrook <jestabro@sentrium.io>2019-06-12 12:45:00 -0500
commitbd6f3f6534a93f8a8c64e06967c24d4c3827c517 (patch)
tree1aca0140ab16542b86dd3f26de5152cba750a8fb /src/helpers/vyos-merge-config.py
parent441f95d499f42f57b3a15d78aec826f794fab59f (diff)
downloadvyos-1x-bd6f3f6534a93f8a8c64e06967c24d4c3827c517.tar.gz
vyos-1x-bd6f3f6534a93f8a8c64e06967c24d4c3827c517.zip
T1397: check for path argument in both effective and merge config
The merge config script restores the ability to restrict changes to a specified path. In the initial implementation, the path was checked for validity only with respect to the effective config; fix to allow valid paths from merge config as well.
Diffstat (limited to 'src/helpers/vyos-merge-config.py')
-rwxr-xr-xsrc/helpers/vyos-merge-config.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/helpers/vyos-merge-config.py b/src/helpers/vyos-merge-config.py
index e97a1c08d..e9a14ae98 100755
--- a/src/helpers/vyos-merge-config.py
+++ b/src/helpers/vyos-merge-config.py
@@ -57,10 +57,6 @@ else:
print(err)
sys.exit(1)
-path = None
-if (len(sys.argv) > 2):
- path = " ".join(sys.argv[2:])
-
with tempfile.NamedTemporaryFile() as file_to_migrate:
with open(file_to_migrate.name, 'w') as fd:
fd.write(config_file)
@@ -91,12 +87,19 @@ merge_cmd_list = merge_cmds.splitlines()
effective_cmd_set = set(effective_cmd_list)
add_cmds = [ cmd for cmd in merge_cmd_list if cmd not in effective_cmd_set ]
-if path:
- if not effective_config.exists(path):
- print("path {} does not exist in running config; will use "
- "root.".format(path))
+path = None
+if (len(sys.argv) > 2):
+ path = sys.argv[2:]
+ if (not effective_config_tree.exists(path) and not
+ merge_config_tree.exists(path)):
+ print("path {} does not exist in either effective or merge"
+ " config; will use root.".format(path))
+ path = None
else:
- add_cmds = [ cmd for cmd in add_cmds if path in cmd ]
+ path = " ".join(path)
+
+if path:
+ add_cmds = [ cmd for cmd in add_cmds if path in cmd ]
for cmd in add_cmds:
cmd = "/opt/vyatta/sbin/my_" + cmd