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]

fence-agents: master - fence_drac5: #462390 - Support Dell M600 BladeChassis


Gitweb:        http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commitdiff;h=a5c483c32321f9f09c540c754052f9e50b9c740c
Commit:        a5c483c32321f9f09c540c754052f9e50b9c740c
Parent:        6a175ac6ee758d9f548ce56d88e5f042f569370c
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Fri Apr 24 14:23:57 2009 +0200
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Fri Apr 24 14:23:57 2009 +0200

fence_drac5: #462390 - Support Dell M600 Blade Chassis

Agent for drac5 was extended to support M600. Detection of model is done automatically.
---
 fence/agents/drac/fence_drac5.py |   60 ++++++++++++++++++++++++++++++++-----
 1 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py
index 568b6ae..bffd4f2 100755
--- a/fence/agents/drac/fence_drac5.py
+++ b/fence/agents/drac/fence_drac5.py
@@ -9,7 +9,7 @@
 ##  DRAC 5             1.0  (Build 06.05.12)
 ##  DRAC 5             1.21 (Build 07.05.04)
 ##
-## @note: drac_version, modulename were removed
+## @note: drac_version was removed
 #####
 
 import sys, re, pexpect
@@ -24,15 +24,22 @@ BUILD_DATE="March, 2008"
 
 def get_power_status(conn, options):
 	try:
-		conn.sendline("racadm serveraction powerstatus")
+		if options["model"] == "DRAC CMC":
+			conn.sendline("racadm serveraction powerstatus -m " + options["-m"])
+		elif options["model"] == "DRAC 5":
+			conn.sendline("racadm serveraction powerstatus")
+		
 		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
 	except pexpect.TIMEOUT:
 		fail(EC_TIMED_OUT)
 				
-	status = re.compile("Server power status: (.*)", re.IGNORECASE).search(conn.before).group(1)
-	return status.lower().strip()
+	status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
+	if status.lower().strip() in ["on", "powering on", "powering off"]:
+		return "on"
+	else:
+		return "off"
 
 def set_power_status(conn, options):
 	action = {
@@ -41,18 +48,43 @@ def set_power_status(conn, options):
 	}[options["-o"]]
 
 	try:
-		conn.sendline("racadm serveraction " + action)
+		if options["model"] == "DRAC CMC":
+			conn.sendline("racadm serveraction " + action + " -m " + options["-m"])
+		elif options["model"] == "DRAC 5":
+			conn.sendline("racadm serveraction " + action)
 		conn.log_expect(options, options["-c"], POWER_TIMEOUT)
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
 	except pexpect.TIMEOUT:
 		fail(EC_TIMED_OUT)
 
+def get_list_devices(conn, options):
+	outlets = { }
+
+	try:
+		if options["model"] == "DRAC CMC":
+			conn.sendline("getmodinfo")
+
+			list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
+			for line in conn.before.splitlines():
+				if (list_re.search(line)):
+					outlets[list_re.search(line).group(1)] = ("", list_re.search(line).group(2))
+			conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+		elif options["model"] == "DRAC 5":
+			## DRAC 5 can be used only for one computer
+			pass
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+	return outlets
+	
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"cmd_prompt", "secure",
-			"drac_version", "module_name", "inet4_only", "inet6_only" ]
+			"cmd_prompt", "secure", "drac_version", "module_name",
+			"separator", "inet4_only", "inet6_only" ]
 
 	atexit.register(atexit_handler)
 
@@ -68,7 +100,19 @@ def main():
 	## Operate the fencing device
 	######
 	conn = fence_login(options)
-	fence_action(conn, options, set_power_status, get_power_status, None)
+
+	if conn.before.find("CMC") >= 0:
+		if 0 == options.has_key("-m") and 0 == ["monitor", "list"].count(option["-o"].lower()):
+			fail_usage("Failed: You have to enter module name (-m)")
+			
+		options["model"]="DRAC CMC"		
+	elif conn.before.find("DRAC 5") >= 0:
+		options["model"]="DRAC 5"
+	else:
+		## Assume this is DRAC 5 by default as we don't want to break anything
+		options["model"]="DRAC 5"
+
+	fence_action(conn, options, set_power_status, get_power_status, get_list_devices)
 
 	##
 	## Logout from system


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