From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7905 invoked by alias); 19 Jun 2009 12:05:40 -0000 Received: (qmail 7899 invoked by alias); 19 Jun 2009 12:05:40 -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: STABLE2 - 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/STABLE2 X-Git-Reftype: branch X-Git-Oldrev: a174a703e7ae078ddae98473c27ee71ebf44a547 X-Git-Newrev: 55d38a4c4cd4b278e76040823e1944573c7d6877 From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090619120513.11A5D1201D2@lists.fedorahosted.org> Date: Fri, 19 Jun 2009 12:05: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/msg00565.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=55d38a4c4cd4b278e76040823e1944573c7d6877 Commit: 55d38a4c4cd4b278e76040823e1944573c7d6877 Parent: a174a703e7ae078ddae98473c27ee71ebf44a547 Author: Marek 'marx' Grac AuthorDate: Fri Jun 19 14:00:35 2009 +0200 Committer: Marek 'marx' Grac 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 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", @@ -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))