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]

The tag: rgmanager_2_0_45 has been created


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c8e1dff26b5fd3d9cb5c72a6787871fc92686a39
Commit:        c8e1dff26b5fd3d9cb5c72a6787871fc92686a39
Parent:        3993b5e73a08031ec88a25c5cfa5146d4ab3787c
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Wed Nov 12 14:57:03 2008 +0100
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Wed Nov 12 15:02:24 2008 +0100

[fence] Extension to fence agent for LPAR/HMC with 'list'/'monitor' operation

---
 fence/agents/lib/fencing.py.py  |    2 +-
 fence/agents/lpar/fence_lpar.py |   29 +++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index f661af8..124f8c2 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -403,7 +403,7 @@ 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 0 == options["device_opt"].count("port")):
+	if (options["-o"] == "list") and (0 == options["device_opt"].count("port")) and (0 == options["device_opt"].count("partition")):
 		print "N/A"
 		return
 	elif (options["-o"] == "list" and get_outlet_list == None):
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index a8a4fe9..56c3153 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -57,6 +57,31 @@ def set_power_status(conn, options):
 	except pexpect.TIMEOUT:
 		fail(EC_TIMED_OUT)
 
+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)
+
+		## 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",
@@ -76,14 +101,14 @@ def main():
 	if 0 == options.has_key("-s"):
 		fail_usage("Failed: You have to enter name of managed system")
 
-        if 0 == options.has_key("-n"):
+        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")
 
 	##
 	## 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, get_lpar_list)
 
 	##
 	## Logout from system


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