public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* fence-agents: master - fence_lpar: Fix 'list' operation for HMC v3
@ 2009-02-16 14:28 Marek Grác
  0 siblings, 0 replies; only message in thread
From: Marek Grác @ 2009-02-16 14:28 UTC (permalink / raw)
  To: cluster-cvs-relay

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

fence_lpar: Fix 'list' operation for HMC v3

---
 fence/agents/lpar/fence_lpar.py |   57 ++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 53f8f60..a5a769a 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -80,33 +80,54 @@ def set_power_status(conn, options):
 
 def get_lpar_list(conn, options):
 	outlets = { }
-	try:
-		conn.send("lssyscfg -r lpar -m " + options["-s"] + 
-			" -F name:state\n")
-		conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+	if options["-H"] == "3":
+		try:
+			conn.send("query_partition_names -m " + options["-s"] + "\n")
+			conn.log_expect(options, options["-c"], POWER_TIMEOUT)
 
-		## We have to remove first line (command) and last line (part of new prompt)
-		####
-		res = re.search("^.+?\n(.*)\n.*$", conn.before, re.S)
+			## We have to remove first 3 lines (command + header) and last line (part of new prompt)
+			####
+			res = re.search("^.+?\n(.+?\n){2}(.*)\n.*$", conn.before, re.S)
 
-		if res == None:
-			fail_usage("Unable to parse output of list command")
+			if res == None:
+				fail_usage("Unable to parse output of list command")
 		
-		lines = res.group(1).split("\n")
-		for x in lines:
-			s = x.split(":")
-			outlets[s[0]] = ("", s[1])
-	except pexpect.EOF:
-		fail(EC_CONNECTION_LOST)
-	except pexpect.TIMEOUT:
-		fail(EC_TIMED_OUT)
+			lines = res.group(2).split("\n")
+			for x in lines:
+				outlets[x.rstrip()] = ("", "")
+		except pexpect.EOF:
+			fail(EC_CONNECTION_LOST)
+		except pexpect.TIMEOUT:
+			fail(EC_TIMED_OUT)		
+	elif options["-H"] == "4":
+		try:
+			conn.send("lssyscfg -r lpar -m " + options["-s"] + 
+				" -F name:state\n")
+			conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+
+			## We have to remove first line (command) and last line (part of new prompt)
+			####
+			res = re.search("^.+?\n(.*)\n.*$", conn.before, re.S)
+
+			if res == None:
+				fail_usage("Unable to parse output of list command")
+		
+			lines = res.group(1).split("\n")
+			for x in lines:
+				s = x.split(":")
+				outlets[s[0]] = ("", s[1])
+		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",
-			"secure", "partition", "managed", "hmc_version", "cmd_prompt" ]
+			"secure", "partition", "managed", "hmc_version", "cmd_prompt",
+			"separator" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-16 14:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-16 14:28 fence-agents: master - fence_lpar: Fix 'list' operation for HMC v3 Marek Grác

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).