[Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.02-1-g2dd250b

mgrac at sourceware.org mgrac at sourceware.org
Mon May 19 15:36:58 UTC 2008


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=2dd250b4ffba38c37d4634c02789ff2705327454

The branch, master has been updated
       via  2dd250b4ffba38c37d4634c02789ff2705327454 (commit)
      from  9183f8ecd7ae7f80f62027ee590d8bff8ecb2d1b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2dd250b4ffba38c37d4634c02789ff2705327454
Author: Marek 'marx' Grac <mgrac at redhat.com>
Date:   Mon May 19 17:28:39 2008 +0200

    [FENCE] Fix #248609: SSH support in Bladecenter fencing (ssh)
    
    Complete ssh support for Bladecenter. You can use password or private key
    (identity_file on STDIN; -k in getopt) to login to system. This patch contains
    complete infrastructure (usable also by other agents).

-----------------------------------------------------------------------

Summary of changes:
 fence/agents/bladecenter/fence_bladecenter.py |    2 +-
 fence/agents/lib/fencing.py.py                |   40 ++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index d149ede..2707054 100755
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -64,7 +64,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"cmd_prompt", "secure", "port" ]
+			"cmd_prompt", "secure", "port", "identity_file" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index b0de573..ff98c25 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -72,12 +72,16 @@ all_opt = {
 		"order" : 1 },
 	"passwd" : {
 		"getopt" : "p:",
-		"help" : "-p <password>  Login password",
+		"help" : "-p <password>  Login password or passphrase",
 		"order" : 1 },
 	"passwd_script" : {
 		"getopt" : "S:",
 		"help" : "-S <script>    Script to run to retrieve password",
 		"order" : 1 },
+	"identity_file" : {
+		"getopt" : "k:",
+		"help" : "-k <filename>  Identity file (private key) for ssh ",
+		"order" : 1 },
 	"module_name" : {
 		"getopt" : "m:",
 		"help" : "-m <module>    DRAC/MC module name",
@@ -254,11 +258,19 @@ def check_input(device_opt, opt):
 	if 0 == options.has_key("-a"):
 		fail_usage("Failed: You have to enter fence address")
 
-	if 0 == (options.has_key("-p") or options.has_key("-S")):
-		fail_usage("Failed: You have to enter password or password script")
+	if 0 == device_opt.count("identity_file"):
+		if 0 == (options.has_key("-p") or options.has_key("-S")):
+			fail_usage("Failed: You have to enter password or password script")
+	else: 
+		if 0 == (options.has_key("-p") or options.has_key("-S") or options.has_key("-k")):
+			fail_usage("Failed: You have to enter password, password script or identity file")
+
+	if 0 == options.has_key("-x") and 1 == options.has_key("-k"):
+		fail_usage("Failed: You have to use identity file together with ssh connection (-x)")
 
-	if 1 == (options.has_key("-p") and options.has_key("-S")):
-		fail_usage("Failed: You have to enter password or password script")
+	if 1 == options.has_key("-k"):
+		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")):
 		fail_usage("Failed: You have to enter plug number")
@@ -325,14 +337,26 @@ def fence_login(options):
 		re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
 		re_pass  = re.compile("password", re.IGNORECASE)
 
-		if options.has_key("-x"):
+		if options.has_key("-x") and 0 == options.has_key("-k"):
 			conn = fspawn ('ssh ' + options["-l"] + "@" + options["-a"])
-			result = conn.log_expect(options, [ "ssword: ", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
+			result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
 			if result == 1:
 				conn.sendline("yes")
-				conn.log_expect(options, "ssword: ", SHELL_TIMEOUT)
+				conn.log_expect(options, "ssword:", SHELL_TIMEOUT)
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		elif options.has_key("-x") and 1 == options.has_key("-k"):
+			conn = fspawn ('ssh ' + options["-l"] + "@" + options["-a"] + " -i " + options["-k"])
+			result = conn.log_expect(options, [ options["-c"], "Are you sure you want to continue connecting (yes/no)?", "Enter passphrase for key '"+options["-k"]+"':" ], LOGIN_TIMEOUT)
+			if result == 1:
+				conn.sendline("yes")
+				conn.log_expect(options, [ options["-c"], "Enter passphrase for key '"+options["-k"]+"':"] , SHELL_TIMEOUT)
+			if result != 0:
+				if options.has_key("-p"):
+					conn.sendline(options["-p"])
+					conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+				else:
+					fail_usage("Failed: You have to enter passphrase (-p) for identity file")
 		else:
 			conn = fspawn ('telnet ' + options["-a"])
 			conn.log_expect(options, re_login, LOGIN_TIMEOUT)


hooks/post-receive
--
Cluster Project




More information about the Cluster-devel mailing list