From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5841 invoked by alias); 19 Jun 2009 11:33:38 -0000 Received: (qmail 5835 invoked by alias); 19 Jun 2009 11:33:38 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,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: RHEL5 - fence agents: Option for setting port for telnet/ssh/ssl used by fence agent To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: 36ac90224ae2668723df9679d1faecfebd3975c6 X-Git-Newrev: e3835309fe31d96795f47513aecb6629cb46faa0 From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090619113240.A316D1201D2@lists.fedorahosted.org> Date: Fri, 19 Jun 2009 11:33: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-q2/txt/msg00564.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=e3835309fe31d96795f47513aecb6629cb46faa0 Commit: e3835309fe31d96795f47513aecb6629cb46faa0 Parent: 36ac90224ae2668723df9679d1faecfebd3975c6 Author: Marek 'marx' Grac AuthorDate: Fri Jun 19 13:27:35 2009 +0200 Committer: Marek 'marx' Grac CommitterDate: Fri Jun 19 13:27: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 | 22 ++++++++++++++++++---- 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, 28 insertions(+), 12 deletions(-) diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py index dfe9913..c2e5c08 100755 --- a/fence/agents/apc/fence_apc.py +++ b/fence/agents/apc/fence_apc.py @@ -175,7 +175,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 3e7204a..5272df3 100755 --- a/fence/agents/bladecenter/fence_bladecenter.py +++ b/fence/agents/bladecenter/fence_bladecenter.py @@ -67,7 +67,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 556ccb3..3b951c0 100755 --- 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 6513e2a..68748ea 100755 --- a/fence/agents/ilo/fence_ilo.py +++ b/fence/agents/ilo/fence_ilo.py @@ -57,7 +57,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 59133a6..7aed327 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -68,6 +68,12 @@ all_opt = { "getopt" : "a:", "help" : "-a IP address or hostname of fencing device", "order" : 1 }, + "ipport" : { + "getopt" : "u:", + "help" : "-u TCP port to use", + "required" : "0", + "shortdesc" : "TCP port to use for connection with device", + "order" : 1 }, "login" : { "getopt" : "l:", "help" : "-l Login name", @@ -390,6 +396,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): @@ -444,10 +458,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) @@ -458,7 +472,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"): - conn = fspawn('%s %s@%s -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"])) + conn = fspawn('%s %s@%s -i %s -p %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"], options["-u"])) 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") @@ -472,7 +486,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 6e0d848..436d153 100755 --- a/fence/agents/lpar/fence_lpar.py +++ b/fence/agents/lpar/fence_lpar.py @@ -88,7 +88,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 e7f131c..dd2f579 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 15885c6..ae8cd23 100644 --- a/fence/agents/virsh/fence_virsh.py +++ b/fence/agents/virsh/fence_virsh.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", - "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 5740cd4..c536ecc 100755 --- a/fence/agents/wti/fence_wti.py +++ b/fence/agents/wti/fence_wti.py @@ -69,7 +69,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))