public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jan Friesse <honzaf@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: master - fence: Added support for no_password in fence agents library and fence_eps.
Date: Wed, 22 Oct 2008 14:21:00 -0000	[thread overview]
Message-ID: <20081022142043.795891201E4@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d57145f52761f3cbd7574a988906f3315ca53cca
Commit:        d57145f52761f3cbd7574a988906f3315ca53cca
Parent:        82a83ab1e9253d3784333da9279713bec25f0a8b
Author:        Jan Friesse <jfriesse@redhat.com>
AuthorDate:    Wed Oct 22 16:19:52 2008 +0200
Committer:     Jan Friesse <jfriesse@redhat.com>
CommitterDate: Wed Oct 22 16:19:52 2008 +0200

fence: Added support for no_password in fence agents library and fence_eps.

Some fence devices don't need login name and password for fencing (this
is generally bad idea, but ePowerSwitch 8M+ is good example).
---
 fence/agents/eps/fence_eps.py  |   23 ++++++++++-------------
 fence/agents/lib/fencing.py.py |   17 +++++++++++------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index c91d5af..f3b7f15 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -23,8 +23,6 @@ def eps_log(options,str):
 # @param options Device options
 # @param params HTTP GET parameters (without ?)
 def eps_run_command(options, params):
-	# String for Authorization header
-	auth_str = 'Basic ' + string.strip(base64.encodestring(options["-l"]+':'+options["-p"]))
 	try:
 		# New http connection
 		conn = httplib.HTTPConnection(options["-a"])
@@ -37,8 +35,14 @@ def eps_run_command(options, params):
 		eps_log(options,"GET "+request_str+"\n")
 		conn.putrequest('GET', request_str)
 
-		eps_log(options,"Authorization:"+auth_str+"\n")
-		conn.putheader('Authorization',auth_str)
+		if (options.has_key("-l")):
+			if (not options.has_key("-p")):
+				options["-p"]="" # Default is empty password
+				
+			# String for Authorization header
+			auth_str = 'Basic ' + string.strip(base64.encodestring(options["-l"]+':'+options["-p"]))
+			eps_log(options,"Authorization:"+auth_str+"\n")
+			conn.putheader('Authorization',auth_str)
 
 		conn.endheaders()
 
@@ -88,18 +92,11 @@ def eps_define_new_opts():
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"test", "port", "hidden_page", "no_login" ]
+			"test", "port", "hidden_page", "no_login", "no_password" ]
 
 	eps_define_new_opts()
 
-	# Because we DON'T need password, we must do little hack
-	input_opts=process_input(device_opt)
-	if ((not input_opts.has_key("-p")) and (not input_opts.has_key("-S"))):
-		input_opts["-p"]=""
-	if (not input_opts.has_key("-l")):
-		input_opts["-l"]=""
-
-	options = check_input(device_opt,input_opts)
+	options = check_input(device_opt,process_input(device_opt))
 
 	if (not options.has_key("-c")):
 		options["-c"]="hidden.htm"
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 3398aa9..40fe29f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -70,6 +70,10 @@ all_opt = {
 		"getopt" : "",
 		"help" : "",
 		"order" : 1 },
+	"no_password" : {
+		"getopt" : "",
+		"help" : "",
+		"order" : 1 },
 	"passwd" : {
 		"getopt" : "p:",
 		"help" : "-p <password>  Login password or passphrase",
@@ -296,12 +300,13 @@ def check_input(device_opt, opt):
 	if 0 == options.has_key("-a"):
 		fail_usage("Failed: You have to enter fence address")
 
-	if 0 == device_opt.count("identity_file"):
-		if 0 == (options.has_key("-p") or options.has_key("-S")):
-			fail_usage("Failed: You have to enter password or password script")
-	else: 
-		if 0 == (options.has_key("-p") or options.has_key("-S") or options.has_key("-k")):
-			fail_usage("Failed: You have to enter password, password script or identity file")
+	if (device_opt.count("no_password") == 0):
+		if 0 == device_opt.count("identity_file"):
+			if 0 == (options.has_key("-p") or options.has_key("-S")):
+				fail_usage("Failed: You have to enter password or password script")
+			else: 
+				if 0 == (options.has_key("-p") or options.has_key("-S") or options.has_key("-k")):
+					fail_usage("Failed: You have to enter password, password script or identity file")
 
 	if 0 == options.has_key("-x") and 1 == options.has_key("-k"):
 		fail_usage("Failed: You have to use identity file together with ssh connection (-x)")


                 reply	other threads:[~2008-10-22 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=20081022142043.795891201E4@lists.fedorahosted.org \
    --to=honzaf@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).