diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-08-12 15:57:00 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-08-12 15:57:00 +0200 |
commit | d822de344c8425b793e0595ba1d0a70c033d2cc3 (patch) | |
tree | 14ac0fb67ccaba7babd4f53e80fc2474aa3fe363 | |
parent | f1720d121911ab14f4925dd9c1075e9d05c8bf79 (diff) | |
download | vyos-1x-d822de344c8425b793e0595ba1d0a70c033d2cc3.tar.gz vyos-1x-d822de344c8425b793e0595ba1d0a70c033d2cc3.zip |
T772: fixup for keepalived not understanding escaped quotes.
Since it does not understand escaped quotes inside notify_* options,
until we fix that, we have to put the script and its arguments
in positional arguments and join inside the transition script runner.
-rwxr-xr-x | src/conf_mode/vrrp.py | 6 | ||||
-rwxr-xr-x | src/system/vrrp-script-wrapper.py | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py index 0f6e531e8..d21e3ef40 100755 --- a/src/conf_mode/vrrp.py +++ b/src/conf_mode/vrrp.py @@ -100,15 +100,15 @@ vrrp_instance {{ group.name }} { {% endif -%} {% if group.master_script -%} - notify_master "/usr/libexec/vyos/system/vrrp-script-wrapper.py --script {{ group.master_script }} --state master --group {{ group.name }} --interface {{ group.interface }}" + notify_master "/usr/libexec/vyos/system/vrrp-script-wrapper.py --state master --group {{ group.name }} --interface {{ group.interface }} {{ group.master_script }}" {% endif -%} {% if group.backup_script -%} - notify_backup "/usr/libexec/vyos/system/vrrp-script-wrapper.py --script {{ group.backup_script }} --state backup --group {{ group.name }} --interface {{ group.interface }}" + notify_backup "/usr/libexec/vyos/system/vrrp-script-wrapper.py --state backup --group {{ group.name }} --interface {{ group.interface }} {{ group.backup_script }}" {% endif -%} {% if group.fault_script -%} - notify_fault "/usr/libexec/vyos/system/vrrp-script-wrapper.py --script {{ group.fault_script }} --state fault --group {{ group.name }} --interface {{ group.interface }}" + notify_fault "/usr/libexec/vyos/system/vrrp-script-wrapper.py --state fault --group {{ group.name }} --interface {{ group.interface }} {{ group.fault_script }}" {% endif -%} } diff --git a/src/system/vrrp-script-wrapper.py b/src/system/vrrp-script-wrapper.py index ce9142b7d..ccd640128 100755 --- a/src/system/vrrp-script-wrapper.py +++ b/src/system/vrrp-script-wrapper.py @@ -27,10 +27,10 @@ import vyos.keepalived parser = argparse.ArgumentParser() -parser.add_argument("-s", "--script", type=str, help="Script to run") parser.add_argument("-t", "--state", type=str, help="VRRP state") parser.add_argument("-g", "--group", type=str, help="VRRP group") parser.add_argument("-i", "--interface", type=str, help="Network interface") +parser.add_argument("script", nargs='+') syslog.openlog('vyos-vrrp-wrapper') @@ -40,6 +40,10 @@ if not args.script or not args.state or not args.group \ parser.print_usage() sys.exit(1) +# Fixup: the reason we take multiple "script" arguments is that people may want +# to pass arguments to the script +args.script = " ".join(args.script) + # Get the old state if it exists and compare it to the current state received # in command line options to avoid executing scripts if no real transition occured. # This is necessary because keepalived does not keep persistent state data even between |