From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32598 invoked by alias); 16 Feb 2009 14:12:26 -0000 Received: (qmail 32588 invoked by alias); 16 Feb 2009 14:12:25 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_05,J_CHICKENPOX_210,SPF_HELO_PASS X-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_05,J_CHICKENPOX_210,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: RHEL5 - [FENCE] Fixes #485700 - Add support for LPAR/HMC v3 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: 69e844b0921c0b3d0ec0bdf309a4ceb07bbd17b2 X-Git-Newrev: 8722e7de933138606b4e65a325e4884e95ff5ae5 From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090216141204.2E05F12026F@lists.fedorahosted.org> Date: Mon, 16 Feb 2009 14:12: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-q1/txt/msg00459.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=8722e7de933138606b4e65a325e4884e95ff5ae5 Commit: 8722e7de933138606b4e65a325e4884e95ff5ae5 Parent: 69e844b0921c0b3d0ec0bdf309a4ceb07bbd17b2 Author: Marek 'marx' Grac AuthorDate: Mon Feb 16 15:02:54 2009 +0100 Committer: Marek 'marx' Grac CommitterDate: Mon Feb 16 15:10:29 2009 +0100 [FENCE] Fixes #485700 - Add support for LPAR/HMC v3 New options for LPAR agent: (-H; hmc-version) and (-c; command-prompt). HMC version have to be set because v3 and v4 are not compatibile. It is possible to auto-detect version (lshmc -V) but this is quite slow to do it in each fencing operation. Default value is '4' because we don't want to change previous behaviour. It does not mean that it should not work with HMC v5, v6 - we just need to mark them. Command prompt option was set to default value but missing in device's options. Older LPAR has different prompt so it was added to default one. If you wish to add your own prompt that remember that $ has to be written as '\$'. --- fence/agents/lib/fencing.py.py | 6 +++ fence/agents/lpar/fence_lpar.py | 76 +++++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index cb50722..f5f94b1 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -99,6 +99,12 @@ all_opt = { "getopt" : "d:", "help" : "-D Force DRAC version to use", "order" : 1 }, + "hmc_version" : { + "getopt" : "H:", + "longopt" : "hmc-version", + "help" : "-H, --hmc-version= Force HMC version to use: 3, 4 (default)", + "default" : 4, + "order" : 1 }, "ribcl" : { "getopt" : "r:", "help" : "-r Force ribcl version to use", diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py index 33ab92b..c87184c 100755 --- a/fence/agents/lpar/fence_lpar.py +++ b/fence/agents/lpar/fence_lpar.py @@ -22,19 +22,30 @@ BUILD_DATE="" #END_VERSION_GENERATION def get_power_status(conn, options): - try: - conn.send("lssyscfg -r lpar -m "+ options["-s"] +" --filter 'lpar_names=" + options["-n"] + "'\n") - conn.log_expect(options, options["-c"], SHELL_TIMEOUT) - except pexpect.EOF: - fail(EC_CONNECTION_LOST) - except pexpect.TIMEOUT: - fail(EC_TIMED_OUT) + if options["-H"] == "3": + try: + conn.send("lssyscfg -r lpar -m " + options["-s"] + " -n " + options["-n"] + " -F name,state\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + except pexpect.EOF: + fail(EC_CONNECTION_LOST) + except pexpect.TIMEOUT: + fail(EC_TIMED_OUT) + + status = re.compile("^" + options["-n"] + ",(.*?),.*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1) + elif options["-H"] == "4": + try: + conn.send("lssyscfg -r lpar -m "+ options["-s"] +" --filter 'lpar_names=" + options["-n"] + "'\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + except pexpect.EOF: + fail(EC_CONNECTION_LOST) + except pexpect.TIMEOUT: + fail(EC_TIMED_OUT) - status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1) + status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1) ## ## Transformation to standard ON/OFF status if possible - if status in ["Running", "Open Firmware", "Shutting Down"]: + if status in ["Running", "Open Firmware", "Shutting Down", "Starting"]: status = "on" else: status = "off" @@ -42,26 +53,36 @@ def get_power_status(conn, options): return status def set_power_status(conn, options): - try: - if options["-o"] == "on": - conn.send("chsysstate -o on -r lpar -m " + options["-s"] + - " -n " + options["-n"] + - " -f `lssyscfg -r lpar -F curr_profile " + - " -m " + options["-s"] + - " --filter \"lpar_names="+ options["-n"] +"\"`\n" ) - else: - conn.send("chsysstate -o shutdown -r lpar --immed" + - " -m " + options["-s"] + " -n " + options["-n"] + "\n") - conn.log_expect(options, options["-c"], POWER_TIMEOUT) - except pexpect.EOF: - fail(EC_CONNECTION_LOST) - except pexpect.TIMEOUT: - fail(EC_TIMED_OUT) + if options["-H"] == "3": + try: + conn.send("chsysstate -o " + options["-o"] + " -r lpar -m " + options["-s"] + + " -n " + options["-n"] + "\n") + conn.log_expect(options, options["-c"], POWER_TIMEOUT) + except pexpect.EOF: + fail(EC_CONNECTION_LOST) + except pexpect.TIMEOUT: + fail(EC_TIMED_OUT) + elif options["-H"] == "4": + try: + if options["-o"] == "on": + conn.send("chsysstate -o on -r lpar -m " + options["-s"] + + " -n " + options["-n"] + + " -f `lssyscfg -r lpar -F curr_profile " + + " -m " + options["-s"] + + " --filter \"lpar_names="+ options["-n"] +"\"`\n" ) + else: + conn.send("chsysstate -o shutdown -r lpar --immed" + + " -m " + options["-s"] + " -n " + options["-n"] + "\n") + conn.log_expect(options, options["-c"], POWER_TIMEOUT) + except pexpect.EOF: + fail(EC_CONNECTION_LOST) + except pexpect.TIMEOUT: + fail(EC_TIMED_OUT) def main(): device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", "action", "ipaddr", "login", "passwd", "passwd_script", - "secure", "partition", "managed" ] + "secure", "partition", "managed", "hmc_version", "cmd_prompt" ] options = check_input(device_opt, process_input(device_opt)) @@ -69,7 +90,7 @@ def main(): ## Fence agent specific defaults ##### if 0 == options.has_key("-c"): - options["-c"] = ":~>" + options["-c"] = [ ":~>", "]\$" ] if 0 == options.has_key("-x"): fail_usage("Failed: You have to use ssh connection (-x) to fence device") @@ -80,6 +101,9 @@ def main(): if 0 == options.has_key("-n"): fail_usage("Failed: You have to enter name of the partition") + if 1 == options.has_key("-H") and (options["-H"] != "3" and options["-H"] != "4"): + fail_usage("Failed: You have to enter valid version number: 3 or 4") + ## ## Operate the fencing device ####