cluster: RHEL55 - fencing: Fence agent for iLO 2 MP
Marek Grác
marx at fedoraproject.org
Wed Nov 11 14:57:55 UTC 2009
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=66bd2e24769c1cb2e3077a2b54f5f9a502ceb1ab
Commit: 66bd2e24769c1cb2e3077a2b54f5f9a502ceb1ab
Parent: c569e17fbdcc9812f4944171487dc220a0388fd6
Author: Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate: Wed Nov 11 15:53:27 2009 +0100
Committer: Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Wed Nov 11 15:53:27 2009 +0100
fencing: Fence agent for iLO 2 MP
Also works with ilo2 with firmware v1.70+. Main difference is that ilo mp uses
ssh instead of ssl.
Resolves: bz#508722
---
fence/agents/Makefile | 3 +
fence/agents/ilo_mp/Makefile | 38 +++++++++++++++++
fence/agents/ilo_mp/fence_ilo_mp.py | 78 +++++++++++++++++++++++++++++++++++
3 files changed, 119 insertions(+), 0 deletions(-)
diff --git a/fence/agents/Makefile b/fence/agents/Makefile
index c8ef06a..4a043ae 100644
--- a/fence/agents/Makefile
+++ b/fence/agents/Makefile
@@ -27,6 +27,7 @@ all:
${MAKE} -C egenera all
# ${MAKE} -C ibmblade all
${MAKE} -C ilo all
+ ${MAKE} -C ilo_mp all
${MAKE} -C ipmilan all
${MAKE} -C lpar all
${MAKE} -C manual all
@@ -58,6 +59,7 @@ install: all
${MAKE} -C egenera install
# ${MAKE} -C ibmblade install
${MAKE} -C ilo install
+ ${MAKE} -C ilo_mp install
${MAKE} -C ipmilan install
${MAKE} -C lpar install
${MAKE} -C manual install
@@ -89,6 +91,7 @@ clean:
${MAKE} -C egenera clean
# ${MAKE} -C ibmblade clean
${MAKE} -C ilo clean
+ ${MAKE} -C ilo_mp clean
${MAKE} -C ipmilan clean
${MAKE} -C lpar clean
${MAKE} -C manual clean
diff --git a/fence/agents/ilo_mp/Makefile b/fence/agents/ilo_mp/Makefile
new file mode 100644
index 0000000..f6e1ddf
--- /dev/null
+++ b/fence/agents/ilo_mp/Makefile
@@ -0,0 +1,38 @@
+###############################################################################
+###############################################################################
+##
+## Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
+## Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+##
+## This copyrighted material is made available to anyone wishing to use,
+## modify, copy, or redistribute it subject to the terms and conditions
+## of the GNU General Public License v.2.
+##
+###############################################################################
+###############################################################################
+
+SOURCE= fence_ilo_mp.py
+TARGET= fence_ilo_mp
+
+top_srcdir=../..
+include ${top_srcdir}/make/defines.mk
+
+all: $(TARGET)
+
+fence_ilo_mp: $(SOURCE)
+ : > $(TARGET)
+ awk "{print}(\$$1 ~ /#BEGIN_VERSION_GENERATION/){exit 0}" $(SOURCE) >> $(TARGET)
+ echo "FENCE_RELEASE_NAME=\"${RELEASE}\";" >> $(TARGET)
+ ${top_srcdir}/scripts/define2var ${top_srcdir}/config/copyright.cf sh REDHAT_COPYRIGHT >> $(TARGET)
+ echo "BUILD_DATE=\"(built `date`)\";" >> $(TARGET)
+ awk -v p=0 "(\$$1 ~ /#END_VERSION_GENERATION/){p = 1} {if(p==1)print}" $(SOURCE) >> $(TARGET)
+ chmod +x $(TARGET)
+
+install: all
+ if [ ! -d ${sbindir} ]; then \
+ install -d ${sbindir}; \
+ fi
+ install -m755 ${TARGET} ${sbindir}
+
+clean:
+ rm -f $(TARGET)
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
new file mode 100644
index 0000000..98d7d69
--- /dev/null
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+
+import sys, re, pexpect, socket
+sys.path.append("/usr/lib/fence")
+from fencing import *
+
+#BEGIN_VERSION_GENERATION
+FENCE_RELEASE_NAME=""
+REDHAT_COPYRIGHT=""
+BUILD_DATE=""
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+ try:
+ conn.send("show /system1\r\n")
+
+ re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
+ conn.log_expect(options, re_state, int(options["-Y"]))
+
+ status = conn.match.group(1).lower()
+
+ if status.startswith("enabled"):
+ return "on"
+ else:
+ return "off"
+ except pexpect.EOF:
+ fail(EC_CONNECTION_LOST)
+ except pexpect.TIMEOUT:
+ fail(EC_TIMED_OUT)
+
+def set_power_status(conn, options):
+ try:
+ if options["-o"] == "on":
+ conn.send("start /system1\r\n")
+ else:
+ conn.send("stop -f /system1\r\n")
+
+ conn.log_expect(options, options["-c"], int(options["-g"]))
+
+ return
+ 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", "cmd_prompt", "ipport", "login_eol_lf",
+ "separator", "inet4_only", "inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
+
+ atexit.register(atexit_handler)
+
+ all_opt["cmd_prompt"]["default"] = [ "MP>", "hpiLO->" ]
+ all_opt["power_wait"]["default"] = 5
+
+ options = check_input(device_opt, process_input(device_opt))
+
+ show_docs(options)
+
+ conn = fence_login(options)
+ conn.send("SMCLP\r\n")
+
+ ##
+ ## Fence operations
+ ####
+ fence_action(conn, options, set_power_status, get_power_status)
+
+ try:
+ conn.send("exit\r\n")
+ except exceptions.OSError:
+ pass
+ except pexpect.ExceptionPexpect:
+ pass
+
+if __name__ == "__main__":
+ main()
More information about the cluster-commits
mailing list