From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4800 invoked by alias); 20 May 2008 09:23:04 -0000 Received: (qmail 4768 invoked by uid 9650); 20 May 2008 09:23:04 -0000 Date: Tue, 20 May 2008 09:23:00 -0000 Message-ID: <20080520092303.4753.qmail@sourceware.org> From: mgrac@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.02-3-g1e6824a X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: c04bde3821f7cfdf71ac7f376e7a664fc3b11bec X-Git-Newrev: 1e6824a1478c95ae6c3a480e94fea889c1149c9a 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: 2008-q2/txt/msg00362.txt.bz2 This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=1e6824a1478c95ae6c3a480e94fea889c1149c9a The branch, master has been updated via 1e6824a1478c95ae6c3a480e94fea889c1149c9a (commit) from c04bde3821f7cfdf71ac7f376e7a664fc3b11bec (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1e6824a1478c95ae6c3a480e94fea889c1149c9a Author: Marek 'marx' Grac Date: Tue May 20 11:11:23 2008 +0200 [FENCE] Fix #446995: Parse error: Unknown option 'switch=3' Support for APC MasterSwitch was added (it worked in original fencing agent). Option 'switch' on STDIN didn't have a getopt alternative, so '-s ' was added. Plug number notation : works as before. Original behaviour for missing switch number does not change. If there is just one MasterSwitch then we will set it up otherwise error is returned. ----------------------------------------------------------------------- Summary of changes: fence/agents/apc/fence_apc.py | 85 ++++++++++++++++++++++++++++++--------- fence/agents/lib/fencing.py.py | 4 ++ 2 files changed, 69 insertions(+), 20 deletions(-) diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py index cdfd74a..bda9c6d 100755 --- a/fence/agents/apc/fence_apc.py +++ b/fence/agents/apc/fence_apc.py @@ -9,6 +9,7 @@ ## +---------------------------------------------+ ## AP7951 AOS v2.7.0, PDU APP v2.7.3 ## AP7941 AOS v3.5.7, PDU APP v3.5.6 +## AP9606 AOS v2.5.4, PDU APP v2.7.3 ## ## @note: ssh is very slow on AP7951 device ##### @@ -31,6 +32,16 @@ def get_power_status(conn, options): version = 0 admin = 0 + switch = 0; + + if (None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before)): + switch = 1; + if (None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before)): + if (0 == options.has_key("-s")): + fail_usage("Failed: You have to enter physical switch number") + else: + if (0 == options.has_key("-s")): + options["-s"] = 1 if (None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before)): version = 2 @@ -42,16 +53,19 @@ def get_power_status(conn, options): else: admin = 1 - if version == 2: - if admin == 0: - conn.send("2\r\n") + if switch == 0: + if version == 2: + if admin == 0: + conn.send("2\r\n") + else: + conn.send("3\r\n") else: - conn.send("3\r\n") + conn.send("2\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + conn.send("1\r\n") else: - conn.send("2\r\n") - conn.log_expect(options, options["-c"], SHELL_TIMEOUT) - conn.send("1\r\n") - + conn.send(options["-s"]+"\r\n") + while 1 == conn.log_expect(options, [ options["-c"], "Press " ], SHELL_TIMEOUT): result += conn.before conn.send("\r\n") @@ -79,6 +93,22 @@ def set_power_status(conn, options): version = 0 admin = 0 + switch = 0 + + if (None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before)): + switch = 1; + ## MasterSwitch has different schema for on/off actions + action = { + 'on' : "1", + 'off': "3" + }[options["-o"]] + if (None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before)): + if (0 == options.has_key("-s")): + fail_usage("Failed: You have to enter physical switch number") + else: + if (0 == options.has_key("-s")): + options["-s"] = 1 + if (None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before)): version = 2 else: @@ -89,26 +119,35 @@ def set_power_status(conn, options): else: admin = 1 - if version == 2: - if admin == 0: - conn.send("2\r\n") + if switch == 0: + if version == 2: + if admin == 0: + conn.send("2\r\n") + else: + conn.send("3\r\n") else: - conn.send("3\r\n") + conn.send("2\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + conn.send("1\r\n") else: - conn.send("2\r\n") - conn.log_expect(options, options["-c"], SHELL_TIMEOUT) - conn.send("1\r\n") + conn.send(options["-s"] + "\r\n") while 1 == conn.log_expect(options, [ options["-c"], "Press " ], SHELL_TIMEOUT): conn.send("\r\n") conn.send(options["-n"]+"\r\n") conn.log_expect(options, options["-c"], SHELL_TIMEOUT) - if admin == 1: - conn.send("1\r\n") - conn.log_expect(options, options["-c"], SHELL_TIMEOUT) - if version == 3: + + if switch == 0: + if admin == 1: + conn.send("1\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + if version == 3: + conn.send("1\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + else: conn.send("1\r\n") conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + conn.send(action+"\r\n") conn.log_expect(options, "Enter 'YES' to continue or to cancel :", SHELL_TIMEOUT) conn.send("YES\r\n") @@ -126,7 +165,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", "test" ] + "secure", "port", "switch", "test" ] options = check_input(device_opt, process_input(device_opt)) @@ -136,6 +175,12 @@ def main(): if 0 == options.has_key("-c"): options["-c"] = "\n>" + ## Support for -n [switch]:[plug] notation that was used before + if (-1 != options["-n"].find(":")): + (switch, plug) = options["-n"].split(":", 1) + options["-s"] = switch; + options["-n"] = plug; + ## ## Operate the fencing device #### diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index ff98c25..c69e397 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -106,6 +106,10 @@ all_opt = { "getopt" : "n:", "help" : "-n Physical plug number on device", "order" : 1 }, + "switch" : { + "getopt" : "-s:", + "help" : "-s Physical switch number on device", + "order" : 1 }, "test" : { "getopt" : "T", "help" : "", hooks/post-receive -- Cluster Project