cluster: RHEL55 - fencing: New option --retry-on <N>

Marek Grác marx at fedoraproject.org
Fri Nov 6 13:45:32 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d51f90a0d58780c18671708c7c18483b1ef25b9c
Commit:        d51f90a0d58780c18671708c7c18483b1ef25b9c
Parent:        670629a1d944a4084258bca807d0152c246d2d4e
Author:        Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate:    Fri Nov 6 14:13:02 2009 +0100
Committer:     Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Fri Nov 6 14:41:49 2009 +0100

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 ae94017..3e45c84 100755
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -58,11 +58,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 cb9bfde..3dd9763 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -346,7 +346,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):
@@ -725,9 +731,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)
@@ -749,10 +761,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()


More information about the cluster-commits mailing list