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: RHEL55 - fence agents: Option for setting port for telnet/ssh/ssl used by fence agent
Date: Mon, 31 Aug 2009 16:02:00 -0000	[thread overview]
Message-ID: <20090831160157.B3CF31201D4@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=28f3bf4cff08f5d714e9d7b134ebbce12264746e
Commit:        28f3bf4cff08f5d714e9d7b134ebbce12264746e
Parent:        0b53674b0634755fe041e6e8fbd00780ca5c8791
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Mon Aug 31 17:46:30 2009 +0200
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Mon Aug 31 17:46:30 2009 +0200

fence agents: Option for setting port for telnet/ssh/ssl used by fence agent

On some fencing devices there is possibility to change default port where
ssh/ssl/telnet/... is listening. There is new option 'ipport' (getopt: -u)
which can be used for this purpose. It is probable that it will make option
'udpport' (also -u; currently used in SNMP based agents) obsoleted in one
of the next versions.

Resolves Red Hat Bugzilla #496446
---
 fence/agents/apc/fence_apc.py                 |    2 +-
 fence/agents/bladecenter/fence_bladecenter.py |    2 +-
 fence/agents/drac/fence_drac5.py              |    2 +-
 fence/agents/ilo/fence_ilo.py                 |    9 +++++----
 fence/agents/lib/fencing.py.py                |   23 +++++++++++++++++++----
 fence/agents/lpar/fence_lpar.py               |    6 ++++--
 fence/agents/rsa/fence_rsa.py                 |    2 +-
 fence/agents/virsh/fence_virsh.py             |    8 ++++----
 fence/agents/wti/fence_wti.py                 |    2 +-
 9 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index ac272fa..1c65e91 100755
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -186,7 +186,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"secure", "port", "switch", "test", "separator",
-			"inet4_only", "inet6_only" ]
+			"inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 7f6acd7..6479065 100755
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -92,7 +92,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"cmd_prompt", "secure", "port", "identity_file", "separator",
-			"inet4_only", "inet6_only" ]
+			"inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py
index 0eece4a..bc09805 100755
--- a/fence/agents/drac/fence_drac5.py
+++ b/fence/agents/drac/fence_drac5.py
@@ -84,7 +84,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"cmd_prompt", "secure", "drac_version", "module_name",
-			"separator", "inet4_only", "inet6_only" ]
+			"separator", "inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index 4fd8404..828e95c 100755
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -57,13 +57,14 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"ssl", "ribcl", "inet4_only", "inet6_only" ]
+			"ssl", "ribcl", "inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 
-	options = check_input(device_opt, process_input(device_opt))
-
-	options["-z"] = 1
+	pinput = process_input(device_opt)
+	pinput["-z"] = 1
+	options = check_input(device_opt, pinput)
+	
 	LOGIN_TIMEOUT = 10
 
 	##
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 04527d1..79cf7e9 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -75,6 +75,13 @@ all_opt = {
 		"longopt" : "ip",
 		"help" : "-a, --ip=<ip>                  IP address or hostname of fencing device",
 		"order" : 1 },
+	"ipport" : {
+		"getopt" : "u:",
+		"longopt" : "ipport",
+		"help" : "-u, --ipport=<port>            TCP port to use",
+		"required" : "0",
+		"shortdesc" : "TCP port to use for connection with device",
+		"order" : 1 },		
 	"login" : {
 		"getopt" : "l:",
 		"longopt" : "username",
@@ -462,6 +469,14 @@ def check_input(device_opt, opt):
 	if (["list", "monitor"].count(options["-o"])==0 and (options.has_key("-L") and (not (options.has_key("-n"))))):
 		fail_usage("Failed: You have to enter virtual machine name")
 
+	if options.has_key("-u") == False:
+		if options.has_key("-x"):
+			options["-u"] = 22
+		elif options.has_key("-z"):
+			options["-u"] = 443
+		else:
+			options["-u"] = 23
+
 	return options
 	
 def wait_power_status(tn, options, get_power_fn):
@@ -544,10 +559,10 @@ def fence_login(options):
 		re_pass  = re.compile("password", re.IGNORECASE)
 
 		if options.has_key("-z"):
-			command = '%s %s %s %s' % (SSL_PATH, force_ipvx, options["-a"], "443")
+			command = '%s %s %s %s' % (SSL_PATH, force_ipvx, options["-a"], options["-u"])
 			conn = fspawn(command)
 		elif options.has_key("-x") and 0 == options.has_key("-k"):
-			command = '%s %s %s@%s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"])
+			command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-u"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
 			conn = fspawn(command)
@@ -558,7 +573,7 @@ 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"):
-			command = '%s %s %s@%s -i %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-k"])
+			command = '%s %s %s@%s -i %s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-k"], options["-u"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
 			conn = fspawn(command)
@@ -576,7 +591,7 @@ def fence_login(options):
 		else:
 			conn = fspawn(TELNET_PATH)
 			conn.send("set binary\n")
-			conn.send("open %s\n"%(options["-a"]))
+			conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
 			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/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 9e177fb..b507b46 100755
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -134,11 +134,13 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"secure", "partition", "managed", "hmc_version", "cmd_prompt",
-			"separator", "inet4_only", "inet6_only" ]
+			"separator", "inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 
-	options = check_input(device_opt, process_input(device_opt))
+	pinput = process_input(device_opt)
+	pinput["-x"] = 1
+	options = check_input(device_opt, pinput)
 
 	## 
 	## Fence agent specific defaults
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index 6a01d6c..90cc99c 100755
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -41,7 +41,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"cmd_prompt", "secure" ]
+			"cmd_prompt", "secure", "ipport" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 4097d96..3a102d2 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -64,18 +64,18 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"secure", "identity_file", "test", "port", "separator",
-			"inet4_only", "inet6_only" ]
+			"inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 
-	options = check_input(device_opt, process_input(device_opt))
+	pinput = process_input(device_opt)
+	pinput["-x"] = 1
+	options = check_input(device_opt, pinput)
 
 	## Defaults for fence agent
 	if 0 == options.has_key("-c"):
 		options["-c"] = "\[EXPECT\]#\ "
 
-	options["-x"]=1
-
 	options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\  /bin/bash --noprofile --norc\"'"
 
 	## Operate the fencing device
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 79024ae..cb183dc 100755
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -77,7 +77,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"cmd_prompt", "secure", "port", "no_login", "no_password",
-			"test", "separator", "inet4_only", "inet6_only" ]
+			"test", "separator", "inet4_only", "inet6_only", "ipport" ]
 
 	atexit.register(atexit_handler)
 


                 reply	other threads:[~2009-08-31 16:02 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=20090831160157.B3CF31201D4@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).