From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30706 invoked by alias); 20 Jul 2009 13:51:41 -0000 Received: (qmail 30698 invoked by alias); 20 Jul 2009 13:51:41 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_40,SPF_HELO_PASS X-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_40,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: RHEL4 - 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/RHEL4 X-Git-Reftype: branch X-Git-Oldrev: b992279f3080cde3eb714cd202455fa7c7619f92 X-Git-Newrev: 770a87c873cb64d9e08425f9ffaf9c598effa113 From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090720135120.3D4291201A5@lists.fedorahosted.org> Date: Mon, 20 Jul 2009 13:51: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/msg00056.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=770a87c873cb64d9e08425f9ffaf9c598effa113 Commit: 770a87c873cb64d9e08425f9ffaf9c598effa113 Parent: b992279f3080cde3eb714cd202455fa7c7619f92 Author: Marek 'marx' Grac AuthorDate: Mon Jul 20 15:46:11 2009 +0200 Committer: Marek 'marx' Grac CommitterDate: Mon Jul 20 15:46:11 2009 +0200 fencing: #510335 - Fencing fails if telnet/ssh is not available --- fence/agents/lib/fencing.py.py | 37 +++++++++++++++++++++++++++++++++---- fence/agents/wti/fence_wti.py | 9 ++++++++- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index 55b1b65..0210ec3 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 @@ -377,12 +378,24 @@ def fence_login(options): if options.has_key("-z"): command = '%s %s %s' % (SSL_PATH, options["-a"], "443") - 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' % (SSH_PATH, options["-l"], options["-a"]) 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") @@ -390,7 +403,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' % (SSH_PATH, options["-l"], options["-a"], options["-k"])) + command = '%s %s@%s -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"]) + 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") @@ -402,7 +423,15 @@ def fence_login(options): else: fail_usage("Failed: You have to enter passphrase (-p) for identity file") else: - conn = fspawn('%s %s' % (TELNET_PATH, options["-a"])) + command = '%s %s' % (TELNET_PATH, options["-a"]) + 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) + 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 6335df7..f04f645 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)