From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4196 invoked by alias); 28 Mar 2008 15:18:55 -0000 Received: (qmail 4151 invoked by uid 9650); 28 Mar 2008 15:18:53 -0000 Date: Fri, 28 Mar 2008 15:18:00 -0000 Message-ID: <20080328151852.4133.qmail@sourceware.org> From: mgrac@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. gfs-kernel_0_1_22-103-g2c60edd X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4a5cd1e6a072618e0700bb0aabc73813fd49bbae X-Git-Newrev: 2c60eddf3d7bedfd452c9583a7e957103e1eaa16 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-q1/txt/msg00395.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=2c60eddf3d7bedfd452c9583a7e957103e1eaa16 The branch, master has been updated via 2c60eddf3d7bedfd452c9583a7e957103e1eaa16 (commit) from 4a5cd1e6a072618e0700bb0aabc73813fd49bbae (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 2c60eddf3d7bedfd452c9583a7e957103e1eaa16 Author: Marek 'marx' Grac Date: Fri Mar 28 16:11:31 2008 +0100 fence/agents: New fencings agents There are new fencing agents based on a new library. They need a 'pexpect' package. If it is possible there is support for both telnet and ssh. In this patch there are agents for: APC, BladeCenter, Drac 5, ILo and WTI. It is possible that backward compatibility is broken (to be fixed). ----------------------------------------------------------------------- Summary of changes: fence/agents/apc/apc.py | 94 ++++++++++ fence/agents/bladecenter/bladecenter.py | 84 +++++++++ fence/agents/drac/drac5.py | 72 ++++++++ fence/agents/ilo/ilo.py | 71 +++++++ fence/agents/lib/fencing.py | 303 +++++++++++++++++++++++++++++++ fence/agents/wti/wti-ips.py | 100 ++++++++++ fence/agents/wti/wti-rsm.py | 87 +++++++++ 7 files changed, 811 insertions(+), 0 deletions(-) create mode 100755 fence/agents/apc/apc.py create mode 100755 fence/agents/bladecenter/bladecenter.py create mode 100755 fence/agents/drac/drac5.py create mode 100755 fence/agents/ilo/ilo.py create mode 100644 fence/agents/lib/fencing.py create mode 100755 fence/agents/wti/wti-ips.py create mode 100755 fence/agents/wti/wti-rsm.py diff --git a/fence/agents/apc/apc.py b/fence/agents/apc/apc.py new file mode 100755 index 0000000..d502d5a --- /dev/null +++ b/fence/agents/apc/apc.py @@ -0,0 +1,94 @@ +#!/usr/bin/python + +## +## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. +## +## The Following Agent Has Been Tested On: +## +## Model Firmware +## +---------------------------------------------+ +## AP7951 AOS v2.7.0, PDU APP v2.7.3 +## +## @note: ssh is very slow on AP7951 device +##### + +import sys, re, pexpect +sys.path.append("../lib/") +from fencing import * + +def get_power_status(conn, options): + result = "" + try: + conn.send("1\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + conn.send("2\r\n") + while 1 == conn.log_expect(options, [ options["-c"], "Press " ], SHELL_TIMEOUT): + result += conn.before + conn.send("\r\n") + result += conn.before + conn.send(chr(03)) + conn.log_expect(options, "- Logout", SHELL_TIMEOUT) + 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("\s*"+options["-n"]+"-.*(ON|OFF)", re.IGNORECASE).search(result).group(1) + return status.lower().strip() + +def set_power_status(conn, options): + action = { + 'on' : "1", + 'off': "2" + }[options["-o"]] + + try: + conn.send("1\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + conn.send("2\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) + conn.send(action+"\r\n") + conn.log_expect(options, "Enter 'YES' to continue or to cancel :", SHELL_TIMEOUT) + conn.send("YES\r\n") + conn.log_expect(options, "Press to continue...", SHELL_TIMEOUT) + conn.send("\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + conn.send(chr(03)) + conn.log_expect(options, "- Logout", SHELL_TIMEOUT) + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + except pexcept.EOF: + fail(EC_CONNECTION_LOST) + except pexcept.TIMEOUT: + fail(EC_TIMED_OUT) + +def main(): + device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", + "action", "ipaddr", "login", "passwd", "passwd_script", + "secure", "port" ] + + options = check_input(device_opt, process_input(device_opt)) + + ## + ## Fence agent specific defaults + ##### + if 0 == options.has_key("-c"): + options["-c"] = "\n>" + + ## + ## Operate the fencing device + #### + conn = fence_login(options) + fence_action(conn, options, set_power_status, get_power_status) + + ## + ## Logout from system + ###### + conn.sendline("4") + conn.close() + +if __name__ == "__main__": + main() diff --git a/fence/agents/bladecenter/bladecenter.py b/fence/agents/bladecenter/bladecenter.py new file mode 100755 index 0000000..17b1a8e --- /dev/null +++ b/fence/agents/bladecenter/bladecenter.py @@ -0,0 +1,84 @@ +#!/usr/bin/python + +## +## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. +## +## The Following Agent Has Been Tested On: +## +## Model Firmware +## +--------------------+---------------------------+ +## (1) Main application BRET85K, rev 16 +## Boot ROM BRBR67D, rev 16 +## Remote Control BRRG67D, rev 16 +## +##### + +import sys, re, pexpect +sys.path.append("../lib/") +from fencing import * + +def get_power_status(conn, options): + try: + node_cmd = "system:blade\[" + options["-n"] + "\]>" + + conn.send("env -T system:blade[" + options["-n"] + "]\r\n") + conn.log_expect(options, node_cmd, SHELL_TIMEOUT) + conn.send("power -state\r\n") + conn.log_expect(options, node_cmd, SHELL_TIMEOUT) + status = conn.before.splitlines()[-1] + conn.send("env -T system\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + except pexpect.EOF: + fail(EC_CONNECTION_LOST) + except pexpect.TIMEOUT: + fail(EC_TIMED_OUT) + + return status.lower().strip() + +def set_power_status(conn, options): + action = { + 'on' : "powerup", + 'off': "powerdown" + }[options["-o"]] + + try: + node_cmd = "system:blade\[" + options["-n"] + "\]>" + + conn.send("env -T system:blade[" + options["-n"] + "]\r\n") + conn.log_expect(options, node_cmd, SHELL_TIMEOUT) + conn.send("power -"+options["-o"]+"\r\n") + conn.log_expect(options, node_cmd, SHELL_TIMEOUT) + conn.send("env -T system\r\n") + conn.log_expect(options, options["-c"], SHELL_TIMEOUT) + except pexcept.EOF: + fail(EC_CONNECTION_LOST) + except pexcept.TIMEOUT: + fail(EC_TIMED_OUT) + +def main(): + device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", + "action", "ipaddr", "login", "passwd", "passwd_script", + "cmd_prompt", "secure", "plug_no" ] + + options = check_input(device_opt, process_input(device_opt)) + + ## + ## Fence agent specific defaults + ##### + if 0 == options.has_key("-c"): + options["-c"] = "system>" + + ## + ## Operate the fencing device + ###### + conn = fence_login(options) + fence_action(conn, options, set_power_status, get_power_status) + + ## + ## Logout from system + ###### + conn.send("exit\r\n") + conn.close() + +if __name__ == "__main__": + main() diff --git a/fence/agents/drac/drac5.py b/fence/agents/drac/drac5.py new file mode 100755 index 0000000..d967b64 --- /dev/null +++ b/fence/agents/drac/drac5.py @@ -0,0 +1,72 @@ +#!/usr/bin/python + +## +## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. +## +## The Following Agent Has Been Tested On: +## +## DRAC Version Firmware +## +-----------------+---------------------------+ +## DRAC 5 1.0 (Build 06.05.12) +## DRAC 5 1.21 (Build 07.05.04) +## +## @note: drac_version, modulename were removed +##### + +import sys, re, pexpect +sys.path.append("../lib/") +from fencing import * + +def get_power_status(conn, options): + try: + conn.sendline("racadm serveraction powerstatus") + 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("Server power status: (.*)", re.IGNORECASE).search(conn.before).group(1) + return status.lower().strip() + +def set_power_status(conn, options): + action = { + 'on' : "powerup", + 'off': "powerdown" + }[options["-o"]] + + try: + conn.sendline("racadm serveraction " + action) + conn.log_expect(options, options["-c"], POWER_TIMEOUT) + except pexcept.EOF: + fail(EC_CONNECTION_LOST) + except pexcept.TIMEOUT: + fail(EC_TIMED_OUT) + +def main(): + device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", + "action", "ipaddr", "login", "passwd", "passwd_script", + "cmd_prompt", "secure" ] + + options = check_input(device_opt, process_input(device_opt)) + + ## + ## Fence agent specific defaults + ##### + if 0 == options.has_key("-c"): + options["-c"] = "\$" + + ## + ## Operate the fencing device + ###### + conn = fence_login(options) + fence_action(conn, options, set_power_status, get_power_status) + + ## + ## Logout from system + ###### + conn.sendline("exit") + conn.close() + +if __name__ == "__main__": + main() diff --git a/fence/agents/ilo/ilo.py b/fence/agents/ilo/ilo.py new file mode 100755 index 0000000..761501e --- /dev/null +++ b/fence/agents/ilo/ilo.py @@ -0,0 +1,71 @@ +#!/usr/bin/python + +## +## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. +## +## The Following Agent Has Been Tested On: +## +## iLO Version +## +---------------------------------------------+ +## iLO Advanced 1.91 +## +## @note: We can't use conn.sendline because we need to send CR/LF +##### + +import sys, re, pexpect +sys.path.append("../lib/") +from fencing import * + +def get_power_status(conn, options): + try: + conn.send("POWER\r\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("server power is currently: (.*)", re.IGNORECASE).search(conn.before).group(1) + return status.lower().strip() + +def set_power_status(conn, options): + action = { + 'on' : "powerup", + 'off': "powerdown" + }[options["-o"]] + + try: + conn.send("power " + options["-o"] + "\r\n") + conn.log_expect(options, options["-c"], POWER_TIMEOUT) + except pexcept.EOF: + fail(EC_CONNECTION_LOST) + except pexcept.TIMEOUT: + fail(EC_TIMED_OUT) + +def main(): + device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug", + "action", "ipaddr", "login", "passwd", "passwd_script", + "secure" ] + + options = check_input(device_opt, process_input(device_opt)) + + ## + ## Fence agent specific defaults + ##### + if 0 == options.has_key("-c"): + options["-c"] = "hpiLO->" + + ## + ## Operate the fencing device + #### + conn = fence_login(options) + fence_action(conn, options, set_power_status, get_power_status) + + ## + ## Logout from system + ###### + conn.send("quit\r\n") + conn.close() + +if __name__ == "__main__": + main() diff --git a/fence/agents/lib/fencing.py b/fence/agents/lib/fencing.py new file mode 100644 index 0000000..56c89a7 --- /dev/null +++ b/fence/agents/lib/fencing.py @@ -0,0 +1,303 @@ +#!/usr/bin/python + +## +## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. +## +##### +import sys, getopt, time, os +import pexpect, re +import telnetlib + +POWER_TIMEOUT = 20 +SHELL_TIMEOUT = 3 +LOGIN_TIMEOUT = 5 + +LOG_MODE_VERBOSE = 100 +LOG_MODE_QUIET = 0 + +EC_BAD_ARGS = 2 +EC_LOGIN_DENIED = 3 +EC_CONNECTION_LOST = 4 +EC_TIMED_OUT = 5 +EC_WAITING_ON = 6 +EC_WAITING_OFF = 7 + +all_opt = { + "help" : { + "getopt" : "h", + "help" : "-h Display this help and exit", + "order" : 54 }, + "version" : { + "getopt" : "V", + "help" : "-V Output version information and exit", + "order" : 53 }, + "quiet" : { + "getopt" : "q", + "help" : "-q Quiet mode", + "order" : 50 }, + "verbose" : { + "getopt" : "v", + "help" : "-v Verbose mode", + "order" : 51 }, + "debug" : { + "getopt" : "D:", + "help" : "-D Debugging to output file", + "order" : 52 }, + "agent" : { + "getopt" : "", + "help" : "", + "order" : 1 }, + "action" : { + "getopt" : "o:", + "help" : "-o Action: reboot (default), off or on", + "order" : 1 }, + "ipaddr" : { + "getopt" : "a:", + "help" : "-a IP address or hostname of fencing device", + "order" : 1 }, + "login" : { + "getopt" : "l:", + "help" : "-l Login name", + "order" : 1 }, + "passwd" : { + "getopt" : "p:", + "help" : "-p Login password", + "order" : 1 }, + "passwd_script" : { + "getopt" : "S:", + "help" : "-S