This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - [fence] Operation 'list' and 'monitor' for iLO, DRAC5 and APC


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=0e29686d2deae8f403a2b1d87af76bb668db22e1
Commit:        0e29686d2deae8f403a2b1d87af76bb668db22e1
Parent:        bc3c001c78019d0f2f1a6c20d1caf61e9048f6c7
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Thu Oct 23 15:27:16 2008 +0200
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Thu Oct 23 15:41:05 2008 +0200

[fence]	Operation 'list' and 'monitor' for iLO, DRAC5 and APC

Operation for listing available outlets works also for single-unit
fencing devices and returns N/A (can be changed to anything else). Option
'monitor' can be used for monitoring health of the fencing device. It
does not output anything and will perform operation 'list' (on multi-port devices; ef. APC) or operation 'status' (on single-port devices; eg. iLO).
---
 fence/agents/apc/fence_apc.py    |    4 ++--
 fence/agents/drac/fence_drac5.py |    2 +-
 fence/agents/ilo/fence_ilo.py    |    2 +-
 fence/agents/lib/fencing.py.py   |   18 +++++++++++++-----
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 7630af5..653d214 100755
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -85,7 +85,7 @@ def get_power_status(conn, options):
 	except pexpect.TIMEOUT:
 		fail(EC_TIMED_OUT)
 
-	if options["-o"] == "list":
+	if ["list", "monitor"].count(options["-o"]) == 1:
 		return outlets
 	else:
 		status = re.compile("\s*"+options["-n"]+"-.*(ON|OFF)", re.IGNORECASE).search(result).group(1)
@@ -188,7 +188,7 @@ def main():
 		options["-c"] = "\n>"
 
 	## Support for -n [switch]:[plug] notation that was used before
-	if (-1 != options["-n"].find(":")):
+	if (options.has_key("-n") == 1) and (-1 != options["-n"].find(":")):
 		(switch, plug) = options["-n"].split(":", 1)
 		options["-s"] = switch;
 		options["-n"] = plug;
diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py
old mode 100644
new mode 100755
index 6a70b68..41bd1d0
--- a/fence/agents/drac/fence_drac5.py
+++ b/fence/agents/drac/fence_drac5.py
@@ -66,7 +66,7 @@ def main():
 	## Operate the fencing device
 	######
 	conn = fence_login(options)
-	fence_action(conn, options, set_power_status, get_power_status)
+	fence_action(conn, options, set_power_status, get_power_status, None)
 
 	##
 	## Logout from system
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
old mode 100644
new mode 100755
index e050ea8..0cf416e
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -95,7 +95,7 @@ def main():
 	##
 	## Fence operations
 	####
-	fence_action(conn, options, set_power_status, get_power_status)
+	fence_action(conn, options, set_power_status, get_power_status, None)
 
 if __name__ == "__main__":
 	main()
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 7927acd..cf7d9be 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -273,6 +273,7 @@ def process_input(avail_opt):
 ######
 def check_input(device_opt, opt):
 	options = dict(opt)
+	options["device_opt"] = device_opt
 
 	if options.has_key("-h"): 
 		usage(device_opt)
@@ -294,7 +295,7 @@ def check_input(device_opt, opt):
 	# Convert action to lowercase
 	options["-o"]=options["-o"].lower()
 
-	if 0 == ["on", "off", "reboot", "status", "list"].count(options["-o"].lower()):
+	if 0 == ["on", "off", "reboot", "status", "list", "monitor"].count(options["-o"].lower()):
 		fail_usage("Failed: Unrecognised action '" + options["-o"] + "'")
 
 	if (0 == options.has_key("-l")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
@@ -318,7 +319,7 @@ def check_input(device_opt, opt):
 		if 0 == os.path.isfile(options["-k"]):
 			fail_usage("Failed: Identity file " + options["-k"] + " does not exist")
 
-	if (0 == options.has_key("-n")) and (device_opt.count("port")):
+	if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")) and (device_opt.count("port")):
 		fail_usage("Failed: You have to enter plug number")
 
 	if options.has_key("-S"):
@@ -361,18 +362,23 @@ def wait_power_status(tn, options, get_power_fn):
 	return 0
 
 def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None):
-	if (options["-o"] == "list" and get_outlet_list == None):		
+	if (options["-o"] == "list" and 0 == options["device_opt"].count("port")):
+		print "N/A"
+		return
+	elif (options["-o"] == "list" and get_outlet_list == None):
 		## @todo: exception?
 		## This is just temporal solution, we will remove default value
 		## None as soon as all existing agent will support this operation 
 		print "NOTICE: List option is not working on this device yet"
 		return
-	elif (options["-o"] == "list"):
+	elif (options["-o"] == "list") or ((options["-o"] == "monitor") and 1 == options["device_opt"].count("port")):
 		outlets = get_outlet_list(tn, options)
 		## keys can be numbers (port numbers) or strings (names of VM)
 		for o in outlets.keys():
 			(alias, status) = outlets[o]
-			print o + options["-C"] + alias	
+			if options["-o"] != "monitor":
+				print o + options["-C"] + alias	
+		return
 
 	status = get_power_fn(tn, options)
 
@@ -407,6 +413,8 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 		print "Success: Rebooted"
 	elif options["-o"] == "status":
 		print "Status: " + status.upper()
+	elif options["-o"] == "monitor":
+		1
 
 def fence_login(options):
 	try:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]