From 8acc1a69d6695bc5d3a86f21f60910186053bac1 Mon Sep 17 00:00:00 2001 From: Marek 'marx' Grac <mgrac@redhat.com> Date: Fri, 6 Nov 2009 12:42:52 +0100 Subject: [PATCH] fencing: New option --retry-on <N> New firmware (v1.70+) for ilo2 is much slower then before. Option --retry-on=X (on stdin retry_on=X) is introduced and it attempts to send power on command to machine and wait for results X times. Default for fence agents is 1 so they won't be affected; fence_ilo default value is 3. Resolves: #bz507514 (timeout options are needed before applying this patch separately) --- fence/agents/ilo/fence_ilo.py | 4 +++- fence/agents/lib/fencing.py.py | 35 ++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py index 0ff40d7..a55c989 100755 --- a/fence/agents/ilo/fence_ilo.py +++ b/fence/agents/ilo/fence_ilo.py @@ -57,11 +57,13 @@ def main(): device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", "action", "ipaddr", "login", "passwd", "passwd_script", "ssl", "ribcl", "inet4_only", "inet6_only", "ipport", - "power_timeout", "shell_timeout", "login_timeout", "power_wait" ] + "power_timeout", "shell_timeout", "login_timeout", "power_wait", + "retry_on" ] atexit.register(atexit_handler) all_opt["login_timeout"]["default"] = "10" + all_opt["retry_on"]["default"] = "3" pinput = process_input(device_opt) pinput["-z"] = 1 diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index 566cebf..26f28f7 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -347,7 +347,13 @@ all_opt = { "getopt" : "M", "longopt" : "missing-as-off", "help" : "--missing-as-off Missing port returns OFF instead of failure", - "order" : 200} + "order" : 200 }, + "retry_on" : { + "getopt" : "r:", + "longopt" : "retry-on", + "help" : "--retry-on <attempts> Count of attempts to retry power on", + "default" : "1", + "order" : 200 } } class fspawn(pexpect.spawn): @@ -715,9 +721,15 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None if status == "on": print "Success: Already ON" else: - set_power_fn(tn, options) - time.sleep(int(options["-G"])) - if wait_power_status(tn, options, get_power_fn): + power_on = False + for i in range(1,int(options["-r"])): + set_power_fn(tn, options) + time.sleep(int(options["-G"])) + if wait_power_status(tn, options, get_power_fn): + power_on = True + break + + if power_on: print "Success: Powered ON" else: fail(EC_WAITING_ON) @@ -739,10 +751,19 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None if wait_power_status(tn, options, get_power_fn) == 0: fail(EC_WAITING_OFF) options["-o"] = "on" - set_power_fn(tn, options) - time.sleep(int(options["-G"])) - if wait_power_status(tn, options, get_power_fn) == 0: + + power_on = False + for i in range(1,int(options["-r"])): + set_power_fn(tn, options) + time.sleep(int(options["-G"])) + if wait_power_status(tn, options, get_power_fn) == 1: + power_on = True + break + + if power_on == False: + # this should not fail as not was fenced succesfully sys.stderr.write('Timed out waiting to power ON\n') + print "Success: Rebooted" elif options["-o"] == "status": print "Status: " + status.upper() -- 1.6.0.6