From c1d949e3ca56c288967336d3e37bc0096588d533 Mon Sep 17 00:00:00 2001 From: Marek 'marx' Grac <mgrac@redhat.com> Date: Mon, 9 Nov 2009 15:34:09 +0100 Subject: [PATCH] fencing: Fix case sensitives in action parameter Resolves: bz#528938 --- fence/agents/apc_snmp/fence_apc_snmp.py | 2 +- fence/agents/baytech/fence_baytech.pl | 2 +- fence/agents/rsb/fence_rsb.py | 18 ++++++++++-------- fence/agents/xcat/fence_xcat.pl | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py index c391809..d2db854 100755 --- a/fence/agents/apc_snmp/fence_apc_snmp.py +++ b/fence/agents/apc_snmp/fence_apc_snmp.py @@ -225,7 +225,7 @@ def usage(): print " -u <udpport> UDP port to use (default 161)" print " -c <community> SNMP community (default 'private')" print " -n <num> Outlet name/number to act on" - print " -o <string> Action: Reboot (default), On, Off and Status" + print " -o <string> Action: Reboot (default), on, off and status" print " -v <filename> Verbose mode - write to file" print " -V Version" diff --git a/fence/agents/baytech/fence_baytech.pl b/fence/agents/baytech/fence_baytech.pl index aac218a..39d91da 100755 --- a/fence/agents/baytech/fence_baytech.pl +++ b/fence/agents/baytech/fence_baytech.pl @@ -76,7 +76,7 @@ sub usage print " -D debugging output\n"; print " -h usage\n"; print " -l string user name\n"; - print " -o string action: On,Off,Status or Reboot (default)\n"; + print " -o string action: on,off,status or reboot (default)\n"; print " -n string outlet name\n"; print " -p string password\n"; print " -S path script to run to retrieve password\n"; diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py index ecb830d..1f5592e 100755 --- a/fence/agents/rsb/fence_rsb.py +++ b/fence/agents/rsb/fence_rsb.py @@ -42,7 +42,7 @@ def usage(): print " -n [telnet port] telnet port" print " -p [password] password" print " -S [path] script to run to retrieve password" - print " -o [action] Reboot (default), Off, On, or Status" + print " -o [action] reboot (default), off, on, or status" print " -v Verbose Verbose mode" print " -V Print Version, then exit" @@ -118,13 +118,14 @@ def main(): if o == "-S": passwd_script = a if o == "-o": - if a == "Off" or a == "OFF" or a == "off": + a_lower=a.lower() + if a_lower == "off": action = POWER_OFF - elif a == "On" or a == "ON" or a == "on": + elif a_lower == "on": action = POWER_ON - elif a == "Status" or a == "STATUS" or a == "status": + elif a_lower == "status": action = POWER_STATUS - elif a == "Reboot" or a == "REBOOT" or a == "reboot": + elif a_lower == "reboot": action = POWER_REBOOT else: usage() @@ -173,11 +174,12 @@ def main(): try: a = params["option"] - if a == "Off" or a == "OFF" or a == "off": + a_lower = a.lower() + if a_lower == "off": action = POWER_OFF - elif a == "On" or a == "ON" or a == "on": + elif a_lower == "on": action = POWER_ON - elif a == "Reboot" or a == "REBOOT" or a == "reboot": + elif a_lower == "reboot": action = POWER_REBOOT except KeyError, e: action = POWER_REBOOT diff --git a/fence/agents/xcat/fence_xcat.pl b/fence/agents/xcat/fence_xcat.pl index 31168bb..209c680 100755 --- a/fence/agents/xcat/fence_xcat.pl +++ b/fence/agents/xcat/fence_xcat.pl @@ -138,6 +138,7 @@ if (@ARGV > 0) { fail_usage "Unknown parameter." if (@ARGV > 0); fail_usage "No '-n' flag specified." unless defined $opt_n; + $opt_o=lc($opt_o) fail_usage "Unrecognised action '$opt_o' for '-o' flag" unless $opt_o =~ /^(on|off|reset|stat)$/; @@ -145,6 +146,7 @@ if (@ARGV > 0) { get_options_stdin(); fail "failed: no plug number" unless defined $opt_n; + $opt_o=lc($opt_o) fail "failed: unrecognised action: $opt_o" unless $opt_o =~ /^(on|off|reset|stat)$/; } -- 1.6.0.6