From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3300 invoked by alias); 20 Jul 2009 14:37:58 -0000 Received: (qmail 3294 invoked by alias); 20 Jul 2009 14:37:57 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: RHEL5 - fencing: #510335 - Fencing fails if telnet/ssh is not available To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: 3a7d9047ac8192bd621dfc8ef22918070faafb67 X-Git-Newrev: 405b0dfc7f2c6956560b19e99b6441b24983afbc From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090720143734.6B0EC1201A5@lists.fedorahosted.org> Date: Mon, 20 Jul 2009 14:37:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00057.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=405b0dfc7f2c6956560b19e99b6441b24983afbc Commit: 405b0dfc7f2c6956560b19e99b6441b24983afbc Parent: 3a7d9047ac8192bd621dfc8ef22918070faafb67 Author: Marek 'marx' Grac AuthorDate: Mon Jul 20 16:05:51 2009 +0200 Committer: Marek 'marx' Grac 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)