summaryrefslogtreecommitdiffstats
path: root/agents/bladecenter
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 06:50:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 06:50:17 +0000
commit86ed03f8adee56c050c73018537371c230a664a6 (patch)
treeeae3d04cdf1c49848e5a671327ab38297f4acb0d /agents/bladecenter
parentInitial commit. (diff)
downloadfence-agents-86ed03f8adee56c050c73018537371c230a664a6.tar.xz
fence-agents-86ed03f8adee56c050c73018537371c230a664a6.zip
Adding upstream version 4.12.1.upstream/4.12.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'agents/bladecenter')
-rw-r--r--agents/bladecenter/fence_bladecenter.py105
1 files changed, 105 insertions, 0 deletions
diff --git a/agents/bladecenter/fence_bladecenter.py b/agents/bladecenter/fence_bladecenter.py
new file mode 100644
index 0000000..d670367
--- /dev/null
+++ b/agents/bladecenter/fence_bladecenter.py
@@ -0,0 +1,105 @@
+#!@PYTHON@ -tt
+
+#####
+##
+## 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
+import atexit
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+from fencing import fail, EC_STATUS, EC_GENERIC_ERROR
+
+def get_power_status(conn, options):
+ node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
+
+ conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
+ i = conn.log_expect([node_cmd, "system>"], int(options["--shell-timeout"]))
+ if i == 1:
+ ## Given blade number does not exist
+ if "--missing-as-off" in options:
+ return "off"
+ else:
+ fail(EC_STATUS)
+ conn.send_eol("power -state")
+ conn.log_expect(node_cmd, int(options["--shell-timeout"]))
+ status = conn.before.splitlines()[-1]
+ conn.send_eol("env -T system")
+ conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
+
+ return status.lower().strip()
+
+def set_power_status(conn, options):
+ node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
+
+ conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
+ i = conn.log_expect([node_cmd, "system>"], int(options["--shell-timeout"]))
+ if i == 1:
+ ## Given blade number does not exist
+ if "--missing-as-off" in options:
+ return
+ else:
+ fail(EC_GENERIC_ERROR)
+
+ conn.send_eol("power -"+options["--action"])
+ conn.log_expect(node_cmd, int(options["--shell-timeout"]))
+ conn.send_eol("env -T system")
+ conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
+
+def get_blades_list(conn, options):
+ outlets = {}
+
+ node_cmd = "system>"
+
+ conn.send_eol("env -T system")
+ conn.log_expect(node_cmd, int(options["--shell-timeout"]))
+ conn.send_eol("list -l 2")
+ conn.log_expect(node_cmd, int(options["--shell-timeout"]))
+
+ lines = conn.before.split("\r\n")
+ filter_re = re.compile(r"^\s*blade\[(\d+)\]\s+(.*?)\s*$")
+ for blade_line in lines:
+ res = filter_re.search(blade_line)
+ if res != None:
+ outlets[res.group(1)] = (res.group(2), "")
+
+ return outlets
+
+def main():
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", \
+ "port", "missing_as_off", "telnet"]
+
+ atexit.register(atexit_handler)
+
+ all_opt["power_wait"]["default"] = "10"
+ all_opt["cmd_prompt"]["default"] = ["system>"]
+
+ options = check_input(device_opt, process_input(device_opt))
+
+ docs = {}
+ docs["shortdesc"] = "Fence agent for IBM BladeCenter"
+ docs["longdesc"] = "fence_bladecenter is an I/O Fencing agent \
+which can be used with IBM Bladecenters with recent enough firmware that \
+includes telnet support. It logs into a Brocade chasis via telnet or ssh \
+and uses the command line interface to power on and off blades."
+ docs["vendorurl"] = "http://www.ibm.com"
+ show_docs(options, docs)
+
+ ##
+ ## Operate the fencing device
+ ######
+ conn = fence_login(options, "(username\s*:\s*)")
+ result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
+ fence_logout(conn, "exit")
+ sys.exit(result)
+
+if __name__ == "__main__":
+ main()