fence-agents: master - fence_ilo_moonshot: New fence agent for HP Moonshot iLO

Marek GrĂ¡c marx at fedoraproject.org
Wed Aug 27 11:12:12 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=4fb2dd8eb8649942dd7fe180508a31f2f46beae3
Commit:        4fb2dd8eb8649942dd7fe180508a31f2f46beae3
Parent:        55ccdd79f530092af06eea5b4ce6a24bd82c0875
Author:        Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate:    Wed Aug 27 13:05:29 2014 +0200
Committer:     Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Wed Aug 27 13:05:29 2014 +0200

fence_ilo_moonshot: New fence agent for HP Moonshot iLO

Resolves: rhbz#1099551
---
 configure.ac                                    |    1 +
 fence/agents/ilo_moonshot/Makefile.am           |   20 +++++++
 fence/agents/ilo_moonshot/fence_ilo_moonshot.py |   69 +++++++++++++++++++++++
 3 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3589bfa..0569dfe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,6 +276,7 @@ AC_CONFIG_FILES([Makefile
 		 fence/agents/ipdu/Makefile
 		 fence/agents/ifmib/Makefile
 		 fence/agents/ilo/Makefile
+		 fence/agents/ilo_moonshot/Makefile
 		 fence/agents/ilo_mp/Makefile
 		 fence/agents/intelmodular/Makefile
 		 fence/agents/ipmilan/Makefile
diff --git a/fence/agents/ilo_moonshot/Makefile.am b/fence/agents/ilo_moonshot/Makefile.am
new file mode 100644
index 0000000..fe8c5da
--- /dev/null
+++ b/fence/agents/ilo_moonshot/Makefile.am
@@ -0,0 +1,20 @@
+MAINTAINERCLEANFILES	= Makefile.in
+
+TARGET			= fence_ilo_moonshot
+
+SRC			= $(TARGET).py
+
+EXTRA_DIST		= $(SRC)
+
+sbin_SCRIPTS		= $(TARGET)
+
+man_MANS		= $(TARGET).8
+
+FENCE_TEST_ARGS         = -l test -p test -a test
+
+include $(top_srcdir)/make/fencebuild.mk
+include $(top_srcdir)/make/fenceman.mk
+include $(top_srcdir)/make/agentpycheck.mk
+
+clean-local: clean-man
+	rm -f $(TARGET)
diff --git a/fence/agents/ilo_moonshot/fence_ilo_moonshot.py b/fence/agents/ilo_moonshot/fence_ilo_moonshot.py
new file mode 100644
index 0000000..b9b4559
--- /dev/null
+++ b/fence/agents/ilo_moonshot/fence_ilo_moonshot.py
@@ -0,0 +1,69 @@
+#!/usr/bin/python -tt
+
+import sys
+import atexit
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+from fencing import fail, EC_STATUS
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION=""
+REDHAT_COPYRIGHT=""
+BUILD_DATE=""
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+	conn.send_eol("show node list")
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
+
+	nodes = {}
+	for line in conn.before.splitlines():
+		if len(line.split()) == 10:
+			nodes[line.split()[1]] = ("", line.split()[8].lower().strip())
+
+	if ["list", "monitor"].count(options["--action"]) == 1:
+		return nodes
+	else:
+		try:
+			(_, status) = nodes[options["--plug"]]
+			return status.lower()
+		except KeyError:
+			fail(EC_STATUS)
+
+def set_power_status(conn, options):
+	if options["--action"] == "on":
+		conn.send_eol("set node power on %s" % (options["--plug"]))
+	else:
+		conn.send_eol("set node power off force %s" % (options["--plug"]))
+
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
+
+	return
+
+def main():
+	device_opt = ["ipaddr", "login", "passwd", "secure", "cmd_prompt", "port"]
+
+	atexit.register(atexit_handler)
+
+	all_opt["secure"]["default"] = "1"
+	all_opt["cmd_prompt"]["default"] = ["MP>", "hpiLO->"]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	docs = {}
+	docs["shortdesc"] = "Fence agent for HP Moonshot iLO"
+	docs["longdesc"] = ""
+	docs["vendorurl"] = "http://www.hp.com"
+	show_docs(options, docs)
+
+	conn = fence_login(options)
+
+	##
+	## Fence operations
+	####
+	result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
+	fence_logout(conn, "exit")
+	sys.exit(result)
+
+if __name__ == "__main__":
+	main()


More information about the cluster-commits mailing list