public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* fence-agents: master - fence_wti: #481664 - fence_wti is unable to connect to (password-less) fencing device
@ 2009-02-11 14:21 Marek Grác
  0 siblings, 0 replies; only message in thread
From: Marek Grác @ 2009-02-11 14:21 UTC (permalink / raw)
  To: cluster-cvs-relay

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:


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 14:21 fence-agents: master - fence_wti: #481664 - fence_wti is unable to connect to (password-less) fencing device 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).