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: cluster: RHEL5 - fencing: #510335 - Fencing fails if telnet/ssh is not available
Date: Mon, 20 Jul 2009 14:37:00 -0000	[thread overview]
Message-ID: <20090720143734.6B0EC1201A5@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=405b0dfc7f2c6956560b19e99b6441b24983afbc
Commit:        405b0dfc7f2c6956560b19e99b6441b24983afbc
Parent:        3a7d9047ac8192bd621dfc8ef22918070faafb67
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Mon Jul 20 16:05:51 2009 +0200
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Mon Jul 20 16:05:51 2009 +0200

fencing: #510335 - Fencing fails if telnet/ssh is not available

---
 fence/agents/lib/fencing.py.py |   41 ++++++++++++++++++++++++++++++++++-----
 fence/agents/wti/fence_wti.py  |    9 +++++++-
 2 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index ba8adae..8175048 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -22,6 +22,7 @@ LOGIN_TIMEOUT = 5
 LOG_MODE_VERBOSE = 100
 LOG_MODE_QUIET = 0
 
+EC_GENERIC_ERROR   = 1
 EC_BAD_ARGS        = 2
 EC_LOGIN_DENIED    = 3
 EC_CONNECTION_LOST = 4
@@ -459,12 +460,24 @@ def fence_login(options):
 
 		if options.has_key("-z"):
 			command = '%s %s %s' % (SSL_PATH, options["-a"], options["-u"])
-			conn = fspawn(command)
+			try:
+				conn = fspawn(command)
+			except pexpect.ExceptionPexpect, ex:
+			 	## SSL telnet is part of the fencing package
+			 	sys.stderr.write(str(ex) + "\n")
+			 	sys.exit(EC_GENERIC_ERROR)
 		elif options.has_key("-x") and 0 == options.has_key("-k"):
 			command = '%s %s@%s -p %s' % (SSH_PATH, options["-l"], options["-a"], options["-u"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
-			conn = fspawn(command)
+			try:
+				conn = fspawn(command)
+			except pexpect.ExceptionPexpect, ex:
+				sys.stderr.write(str(ex) + "\n")
+				sys.stderr.write("Due to limitations, binary dependencies on fence agents "
+				"are not in the spec file and must be installed separately." + "\n")
+				sys.exit(EC_GENERIC_ERROR)
+				
 			result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
 			if result == 1:
 				conn.sendline("yes")
@@ -472,7 +485,15 @@ def fence_login(options):
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], LOGIN_TIMEOUT)
 		elif options.has_key("-x") and 1 == options.has_key("-k"):
-			conn = fspawn('%s %s@%s -i %s -p %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"], options["-u"]))
+			command = '%s %s@%s -i %s -p %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"], options["-u"])
+			try:
+				conn = fspawn(command)
+			except pexpect.ExceptionPexpect, ex:
+				sys.stderr.write(str(ex) + "\n")
+				sys.stderr.write("Due to limitations, binary dependencies on fence agents "
+				"are not in the spec file and must be installed separately." + "\n")
+				sys.exit(EC_GENERIC_ERROR)
+
 			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")
@@ -484,9 +505,17 @@ def fence_login(options):
 				else:
 					fail_usage("Failed: You have to enter passphrase (-p) for identity file")
 		else:
-			conn = fspawn(TELNET_PATH)
-			conn.send("set binary\n")
-			conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
+			command = '%s %s' % (TELNET_PATH, options["-a"])
+			try:
+				conn = fspawn(TELNET_PATH)
+				conn.send("set binary\n")
+				conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
+			except pexpect.ExceptionPexpect, ex:
+				sys.stderr.write(str(ex) + "\n")
+				sys.stderr.write("Due to limitations, binary dependencies on fence agents "
+				"are not in the spec file and must be installed separately." + "\n")
+				sys.exit(EC_GENERIC_ERROR)
+
 			conn.log_expect(options, re_login, LOGIN_TIMEOUT)
 			conn.send(options["-l"]+"\r\n")
 			conn.log_expect(options, re_pass, SHELL_TIMEOUT)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 4a5c758..4d9f6b2 100755
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -86,7 +86,14 @@ def main():
 	#####	
 	if 0 == options.has_key("-x"):
 		try:
-			conn = fspawn ('telnet ' + options["-a"])
+			try:
+				conn = fspawn('%s %s' % (TELNET_PATH, options["-a"]))
+			except pexpect.ExceptionPexpect, ex:
+				sys.stderr.write(str(ex) + "\n")
+				sys.stderr.write("Due to limitations, binary dependencies on fence agents "
+				"are not in the spec file and must be installed separately." + "\n")
+				sys.exit(EC_GENERIC_ERROR)
+			
 			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)
 


                 reply	other threads:[~2009-07-20 14:37 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=20090720143734.6B0EC1201A5@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).