This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE2 - fence agents: Option for setting port fortelnet/ssh/ssl used by fence agent


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=55d38a4c4cd4b278e76040823e1944573c7d6877
Commit:        55d38a4c4cd4b278e76040823e1944573c7d6877
Parent:        a174a703e7ae078ddae98473c27ee71ebf44a547
Author:        Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate:    Fri Jun 19 14:00:35 2009 +0200
Committer:     Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Fri Jun 19 14:00:35 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: #506928
---
 fence/agents/apc/fence_apc.py                 |    2 +-
 fence/agents/bladecenter/fence_bladecenter.py |    2 +-
 fence/agents/drac/fence_drac5.py              |    3 ++-
 fence/agents/ilo/fence_ilo.py                 |    2 +-
 fence/agents/lib/fencing.py.py                |   24 ++++++++++++++++++++----
 fence/agents/lpar/fence_lpar.py               |    3 ++-
 fence/agents/rsa/fence_rsa.py                 |    2 +-
 fence/agents/virsh/fence_virsh.py             |    2 +-
 fence/agents/wti/fence_wti.py                 |    2 +-
 9 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index eccad66..90aab93 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -170,7 +170,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure", "port", "switch", "test" ]
+			"secure", "port", "switch", "test", "ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 2d9a661..dc5d091 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -63,7 +63,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", "port", "identity_file" ]
+			"cmd_prompt", "secure", "port", "identity_file", "ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py
index a8b1add..85bf3b5 100644
--- a/fence/agents/drac/fence_drac5.py
+++ b/fence/agents/drac/fence_drac5.py
@@ -61,7 +61,8 @@ 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", "drac_version", "module_name" ]
+			"cmd_prompt", "secure", "drac_version", "module_name",
+			"ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index e050ea8..e2343e2 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -56,7 +56,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"ssl", "ribcl" ]
+			"ssl", "ribcl", "ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index b8131a2..e8f89ec 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -63,6 +63,12 @@ all_opt = {
 		"getopt" : "a:",
 		"help" : "-a <ip>        IP address or hostname of fencing device",
 		"order" : 1 },
+	"ipport" : {
+		"getopt" : "u:",
+		"help" : "-u <port>      TCP port to use",
+		"required" : "0",
+		"shortdesc" : "TCP port to use for connection with device",
+		"order" : 1 },
 	"login" : {
 		"getopt" : "l:",
 		"help" : "-l <name>      Login name",
@@ -387,6 +393,14 @@ def check_input(device_opt, opt):
 	if (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):
@@ -441,10 +455,10 @@ def fence_login(options):
 		re_pass  = re.compile("password", re.IGNORECASE)
 
 		if options.has_key("-z"):
-			command = '%s %s %s' % (SSL_PATH, options["-a"], "443")
+			command = '%s %s %s' % (SSL_PATH, options["-a"], options["-u"])
 			conn = fspawn(command)
 		elif options.has_key("-x") and 0 == options.has_key("-k"):
-			command = '%s %s@%s' % (SSH_PATH, options["-l"], options["-a"])
+			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)
@@ -467,7 +481,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 -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"])
+			command = '%s %s@%s -i %s -p %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"], options["-u"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
 			conn = fspawn(command)
@@ -483,7 +497,9 @@ 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"]))
+			conn = fspawn(TELNET_PATH)
+			conn.send("set binary\n")
+			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 bf05f73..c20cde5 100755
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -81,7 +81,8 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure", "partition", "managed", "hmc_version", "cmd_prompt" ]
+			"secure", "partition", "managed", "hmc_version", 
+			"cmd_prompt", "ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index af2a780..1e6314a 100644
--- 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" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 9a10e9d..3012621 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -62,7 +62,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure", "identity_file", "test", "port" ]
+			"secure", "identity_file", "test", "port", "ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 569867f..54c037f 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -68,7 +68,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" ]
+			"test", "ipport" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]