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_wti: #481664 - fence_wti is unable toconnect to (password-less) fencing device


Gitweb:        http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commitdiff;h=0c86ec57d983df1cbeaba12e48730b54f4cbff8a
Commit:        0c86ec57d983df1cbeaba12e48730b54f4cbff8a
Parent:        ba86139894ba411fe9b359d3449e99344fa09862
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Wed Feb 11 15:16:09 2009 +0100
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Wed Feb 11 15:16:09 2009 +0100

fence_wti: #481664 -  fence_wti is unable to connect to (password-less) fencing device

Login mechanism was completely rewritten so now we support no-loginname, no-password and
possibly any other configuration.
---
 fence/agents/wti/fence_wti.py |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 29aace7..9f5ec8f 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -75,7 +75,8 @@ 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", "no_login", "test" ]
+			"cmd_prompt", "secure", "port", "no_login", "no_password",
+			"test" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
@@ -88,15 +89,22 @@ def main():
 	##
 	## Operate the fencing device
 	##
-	## @note: if there is not a login name then we assume that it is WTI-IPS
-	##        where no login name is used
+	## @note: if it possible that this device does not need either login, password or both of them
 	#####	
-	if (0 == options.has_key("-l")):
+	if 0 == options.has_key("-x"):
 		try:
 			conn = fspawn ('telnet ' + options["-a"])
-			conn.log_expect(options, "Password: ", SHELL_TIMEOUT)
-			conn.send(options["-p"]+"\r\n")
-			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+			re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
+			re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["-c"])), re.IGNORECASE)
+
+			result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], SHELL_TIMEOUT)
+			if result == 0:
+				conn.send(options["-l"]+"\r\n")
+				result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], SHELL_TIMEOUT)
+		
+			if result == 1:
+				conn.send(options["-p"]+"\r\n")
+				conn.log_expect(options, options["-c"], SHELL_TIMEOUT)	
 		except pexpect.EOF:
 			fail(EC_LOGIN_DENIED) 
 		except pexpect.TIMEOUT:


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