cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Marek 'marx' Grac <mgrac@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] fencing: Missing password is not reported properly
Date: Mon, 30 Jan 2012 15:58:21 +0100	[thread overview]
Message-ID: <1327935501-21099-1-git-send-email-mgrac@redhat.com> (raw)

When username is entered and password is missing then it is possible
that fence code will end with exception.

Resolves: rhbz#785091
---
 fence/agents/lib/fencing.py.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 8be0a61..e93f59a 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -25,6 +25,7 @@ EC_WAITING_ON      = 6
 EC_WAITING_OFF     = 7
 EC_STATUS          = 8
 EC_STATUS_HMC      = 9
+EC_PASSWORD_MISSING = 10
 
 TELNET_PATH = "/usr/bin/telnet"
 SSH_PATH    = "/usr/bin/ssh"
@@ -439,7 +440,8 @@ def fail(error_code):
 		EC_WAITING_ON : "Failed: Timed out waiting to power ON",
 		EC_WAITING_OFF : "Failed: Timed out waiting to power OFF",
 		EC_STATUS : "Failed: Unable to obtain correct plug status or plug is not available",
-		EC_STATUS_HMC : "Failed: Either unable to obtaion correct plug status, partition is not available or incorrect HMC version used"
+		EC_STATUS_HMC : "Failed: Either unable to obtaion correct plug status, partition is not available or incorrect HMC version used",
+		EC_PASSWORD_MISSING : "Failed: You have to set login password"
 	}[error_code] + "\n"
 	sys.stderr.write(message)
 	sys.exit(EC_GENERIC_ERROR)
@@ -946,8 +948,11 @@ def fence_login(options):
 			conn.log_expect(options, re_login, int(options["-y"]))
 			conn.send(options["-l"] + login_eol)
 			conn.log_expect(options, re_pass, int(options["-Y"]))
-			conn.send(options["-p"] + login_eol)
-			conn.log_expect(options, options["-c"], int(options["-Y"]))
+			try:
+				conn.send(options["-p"] + login_eol)
+				conn.log_expect(options, options["-c"], int(options["-Y"]))
+			except KeyError:
+				fail(EC_PASSWORD_MISSING)
 	except pexpect.EOF:
 		fail(EC_LOGIN_DENIED) 
 	except pexpect.TIMEOUT:
-- 
1.7.4.4



             reply	other threads:[~2012-01-30 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 14:58 Marek 'marx' Grac [this message]
2012-01-30 15:08 ` [Cluster-devel] [PATCH] fencing: Missing password is not reported properly Fabio M. Di Nitto

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=1327935501-21099-1-git-send-email-mgrac@redhat.com \
    --to=mgrac@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 NNTP newsgroup(s).