fencing: new option --method
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 fencing: new option --method
Add new option method --method for cycle reboot
--- fence/agents/lib/fencing.py.py | 80 ++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 23 deletions(-)
fence/agents/lib/fencing.py.py +57 -23
@@ -25,7 +25,6 @@ EC_STATUS = 8 EC_STATUS_HMC = 9 EC_PASSWORD_MISSING = 10 EC_INVALID_PRIVILEGES = 11 -EC_TOOL_FAIL = 12 TELNET_PATH = "/usr/bin/telnet" SSH_PATH = "/usr/bin/ssh"
@@ -343,7 +342,16 @@ all_opt = { "help" : "--use-sudo Use sudo (without password) when calling 3rd party software", "required" : "0", "shortdesc" : "Use sudo (without password) when calling 3rd party sotfware.", - "order" : 205} + "order" : 205}, + "method" : { + "getopt" : "m:", + "longopt" : "method", + "help" : "-m, --method=[method] Method to fence (onoff|cycle) (Default: onoff)", + "required" : "0", + "shortdesc" : "Method to fence (onoff|cycle) (Default: onoff)", + "default" : "onoff", + "choices" : [ "onoff", "cycle" ], + "order" : 1} } # options which are added automatically if 'key' is encountered ("default" is always added)
@@ -413,8 +421,7 @@ def fail(error_code): EC_STATUS_HMC : "Failed: Either unable to obtain correct plug status, partition is not available or incorrect HMC version used", EC_PASSWORD_MISSING : "Failed: You have to set login password", - EC_INVALID_PRIVILEGES : "Failed: The user does not have the correct privileges to do the requested action.", - EC_TOOL_FAIL: "Failed: Required tool not found or not accessible." + EC_INVALID_PRIVILEGES : "Failed: The user does not have the correct privileges to do the requested action." }[error_code] + "\n" sys.stderr.write(message) syslog.syslog(syslog.LOG_ERR, message)
@@ -782,6 +789,23 @@ def set_multi_power_fn(tn, options, set_power_fn): else: set_power_fn(tn, options) +def multi_reboot_cycle_fn(tn, options, reboot_cycle_fn): + success = False; + if options.has_key("--plugs"): + for plug in options["--plugs"]: + try: + options["--uuid"] = str(uuid.UUID(plug)) + except ValueError: + pass + except KeyError: + pass + options["--plug"] = plug + plug_status = reboot_cycle_fn(tn, options) + if plug_status: + success = plug_status + else: + success = reboot_cycle_fn(tn, options) + return success def show_docs(options, docs = None): device_opt = options["device_opt"]
@@ -806,7 +830,7 @@ def show_docs(options, docs = None): print __main__.REDHAT_COPYRIGHT sys.exit(0) -def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None): +def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None, reboot_cycle_fn = None): result = 0 try:
@@ -865,28 +889,38 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None else: fail(EC_WAITING_OFF) elif options["--action"] == "reboot": - if status != "off": - options["--action"] = "off" - set_multi_power_fn(tn, options, set_power_fn) - time.sleep(int(options["--power-wait"])) - if wait_power_status(tn, options, get_power_fn) == 0: - fail(EC_WAITING_OFF) - options["--action"] = "on" - power_on = False - try: + if options.has_key("--method") and options["--method"].lower() == "cycle": for _ in range(1, 1 + int(options["--retry-on"])): - set_multi_power_fn(tn, options, set_power_fn) - time.sleep(int(options["--power-wait"])) - if wait_power_status(tn, options, get_power_fn) == 1: + if multi_reboot_cycle_fn(tn, options, reboot_cycle_fn): power_on = True break - except Exception, ex: - # an error occured during power ON phase in reboot - # fence action was completed succesfully even in that case - sys.stderr.write(str(ex)) - syslog.syslog(syslog.LOG_NOTICE, str(ex)) - pass + + if not power_on: + fail(EC_TIMED_OUT) + + else: + if status != "off": + options["--action"] = "off" + set_multi_power_fn(tn, options, set_power_fn) + time.sleep(int(options["--power-wait"])) + if wait_power_status(tn, options, get_power_fn) == 0: + fail(EC_WAITING_OFF) + options["--action"] = "on" + + try: + for _ in range(1, 1 + int(options["--retry-on"])): + set_multi_power_fn(tn, options, set_power_fn) + time.sleep(int(options["--power-wait"])) + if wait_power_status(tn, options, get_power_fn) == 1: + power_on = True + break + except Exception, ex: + # an error occured during power ON phase in reboot + # fence action was completed succesfully even in that case + sys.stderr.write(str(ex)) + syslog.syslog(syslog.LOG_NOTICE, str(ex)) + pass if power_on == False: # this should not fail as node was fenced succesfully
Signature · 1 line
1.8.3.1
PATCH 1/3 fencing: new option --method
Hi Ondrej,
I have several comments:
* please include patches so they depends only on upstream or posted series (2/3 can depend on 1/3)
[ e.g. problem with -EC_TOOL_FAIL ]
Quoted 6 lines · Ondrej Mular
Add new option method --method for cycle reboot
--- fence/agents/lib/fencing.py.py | 80 ++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 23 deletions(-)
...
Quoted 8 lines
fence/agents/lib/fencing.py.py +7
-0+def multi_reboot_cycle_fn(tn, options, reboot_cycle_fn): + success = False; + if options.has_key("--plugs"): + for plug in options["--plugs"]: + try: + options["--uuid"] = str(uuid.UUID(plug)) + except ValueError:
fence/agents/lib/fencing.py.py def set_multi_power_fn(tn, options, set_power_fn): · line 808
Quoted 10 lines
fence/agents/lib/fencing.py.py +10
-0+ pass + except KeyError: + pass + options["--plug"] = plug + plug_status = reboot_cycle_fn(tn, options) + if plug_status: + success = plug_status + else: + success = reboot_cycle_fn(tn, options) + return success
Although we support multiple ports (--plugs) it is possible only when using 'method=offon' because otherwise we will just reboot port #1, reboot port #2, ... so the machine with redundant power supply will not be rebooted. We should end with a failure message when users attempts to do this combination. imho it will be best to include this constrain directly to do it in check_input() in fencing library
m,