public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: "Marek Grác" <marx@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: fence-agents: master - fence_wti: #481664 - fence_wti is unable to connect to (password-less) fencing device
Date: Wed, 11 Feb 2009 14:21:00 -0000	[thread overview]
Message-ID: <20090211142123.015FA120346@lists.fedorahosted.org> (raw)

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:


                 reply	other threads:[~2009-02-11 14:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090211142123.015FA120346@lists.fedorahosted.org \
    --to=marx@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).