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_lpar: #485065 Add support for HMC v3


Gitweb:        http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commitdiff;h=5afd5af37b31abc7c2198940796fd3bd9b03d621
Commit:        5afd5af37b31abc7c2198940796fd3bd9b03d621
Parent:        4aeae7289e8a27870faed0462ab93e46d05f3e9c
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Mon Feb 16 14:44:54 2009 +0100
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Mon Feb 16 14:44:54 2009 +0100

fence_lpar: #485065 Add support for HMC v3

New options for LPAR agent: (-H; hmc-version) and (-c; command-prompt). HMC version
have to be set because v3 and v4 are not compatibile. It is possible to auto-detect
version (lshmc -V) but this is quite slow to do it in each fencing operation. Default
value is '4' because we don't want to change previous behaviour. It does not mean
that it should not work with HMC v5, v6 - we just need to mark them.

Command prompt option was set to default value but missing in device's options. Older
LPAR has different prompt so it was added to default one. If you wish to add your own
prompt that remember that $ has to be written as '\$'.
---
 fence/agents/lib/fencing.py.py  |    6 +++
 fence/agents/lpar/fence_lpar.py |   77 +++++++++++++++++++++++++--------------
 2 files changed, 56 insertions(+), 27 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 7b7f8d5..9cd6bc8 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -122,6 +122,12 @@ all_opt = {
 		"longopt" : "drac-version",
 		"help" : "-D, --drac-version=<version>   Force DRAC version to use",
 		"order" : 1 },
+	"hmc_version" : {
+		"getopt" : "H:",
+		"longopt" : "hmc-version",
+		"help" : "-H, --hmc-version=<version>   Force HMC version to use: 3, 4 (default)",
+		"default" : 4, 
+		"order" : 1 },
 	"ribcl" : {
 		"getopt" : "r:",
 		"longopt" : "ribcl-version",
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 44b3a71..53f8f60 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -21,19 +21,30 @@ BUILD_DATE=""
 #END_VERSION_GENERATION
 
 def get_power_status(conn, options):
-	try:
-		conn.send("lssyscfg -r lpar -m "+ options["-s"] +" --filter 'lpar_names=" + options["-n"] + "'\n")
-		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
-	except pexpect.EOF:
-		fail(EC_CONNECTION_LOST)
-	except pexpect.TIMEOUT:
-		fail(EC_TIMED_OUT)
+	if options["-H"] == "3":
+		try:
+			conn.send("lssyscfg -r lpar -m " + options["-s"] + " -n " + options["-n"] + " -F name,state\n")
+			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("^" + options["-n"] + ",(.*?),.*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+	elif options["-H"] == "4":
+		try:
+			conn.send("lssyscfg -r lpar -m "+ options["-s"] +" --filter 'lpar_names=" + options["-n"] + "'\n")
+			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(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
+		status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
 
 	##
 	## Transformation to standard ON/OFF status if possible
-	if status in ["Running", "Open Firmware", "Shutting Down"]:
+	if status in ["Running", "Open Firmware", "Shutting Down", "Starting"]:
 		status = "on"
 	else:
 		status = "off"
@@ -41,21 +52,31 @@ def get_power_status(conn, options):
 	return status
 
 def set_power_status(conn, options):
-	try:
-		if options["-o"] == "on":
-			conn.send("chsysstate -o on -r lpar -m " + options["-s"] + 
-				" -n " + options["-n"] + 
-				" -f `lssyscfg -r lpar -F curr_profile " +
-				" -m " + options["-s"] +
-				" --filter \"lpar_names="+ options["-n"] +"\"`\n" )
-		else:
-			conn.send("chsysstate -o shutdown -r lpar --immed" +
-				" -m " + options["-s"] + " -n " + options["-n"] + "\n")		
-		conn.log_expect(options, options["-c"], POWER_TIMEOUT)
-	except pexpect.EOF:
-		fail(EC_CONNECTION_LOST)
-	except pexpect.TIMEOUT:
-		fail(EC_TIMED_OUT)
+	if options["-H"] == "3":
+		try:
+			conn.send("chsysstate -o " + options["-o"] + " -r lpar -m " + options["-s"]
+				+ " -n " + options["-n"] + "\n")
+			conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+		except pexpect.EOF:
+			fail(EC_CONNECTION_LOST)
+		except pexpect.TIMEOUT:
+			fail(EC_TIMED_OUT)		
+	elif options["-H"] == "4":
+		try:
+			if options["-o"] == "on":
+				conn.send("chsysstate -o on -r lpar -m " + options["-s"] + 
+					" -n " + options["-n"] + 
+					" -f `lssyscfg -r lpar -F curr_profile " +
+					" -m " + options["-s"] +
+					" --filter \"lpar_names="+ options["-n"] +"\"`\n" )
+			else:
+				conn.send("chsysstate -o shutdown -r lpar --immed" +
+					" -m " + options["-s"] + " -n " + options["-n"] + "\n")		
+			conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+		except pexpect.EOF:
+			fail(EC_CONNECTION_LOST)
+		except pexpect.TIMEOUT:
+			fail(EC_TIMED_OUT)
 
 def get_lpar_list(conn, options):
 	outlets = { }
@@ -85,7 +106,7 @@ def get_lpar_list(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure", "partition", "managed" ]
+			"secure", "partition", "managed", "hmc_version", "cmd_prompt" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
@@ -93,17 +114,19 @@ def main():
 	## Fence agent specific defaults
 	#####
 	if 0 == options.has_key("-c"):
-		options["-c"] = ":~>"
+		options["-c"] = [ ":~>", "]\$" ]
 
 	if 0 == options.has_key("-x"):
 		fail_usage("Failed: You have to use ssh connection (-x) to fence device")
 
 	if 0 == options.has_key("-s"):
 		fail_usage("Failed: You have to enter name of managed system")
-
         if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")):
                 fail_usage("Failed: You have to enter name of the partition")
 
+	if 1 == options.has_key("-H") and (options["-H"] != "3" and options["-H"] != "4"):
+		fail_usage("Failed: You have to enter valid version number: 3 or 4")
+
 	##
 	## Operate the fencing device
 	####


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