|
|
e4ffb1 |
From 3d712dab6d8b1dc7c011a3d9399c3d278329387f Mon Sep 17 00:00:00 2001
|
|
|
e4ffb1 |
From: Marek 'marx' Grac <mgrac@redhat.com>
|
|
|
e4ffb1 |
Date: Wed, 17 Jun 2015 09:30:55 +0200
|
|
|
e4ffb1 |
Subject: [PATCH 2/6] fence_hpblade: Add support for HP Integrity Superdome X
|
|
|
e4ffb1 |
(BL920s)
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
Resolves: rhbz#1216997
|
|
|
e4ffb1 |
---
|
|
|
e4ffb1 |
fence/agents/hpblade/fence_hpblade.py | 85 ++++++++++++++++++++++++++++-------
|
|
|
e4ffb1 |
1 file changed, 68 insertions(+), 17 deletions(-)
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
|
|
|
e4ffb1 |
index e0b8866..832819c 100644
|
|
|
e4ffb1 |
--- a/fence/agents/hpblade/fence_hpblade.py
|
|
|
e4ffb1 |
+++ b/fence/agents/hpblade/fence_hpblade.py
|
|
|
e4ffb1 |
@@ -3,31 +3,62 @@
|
|
|
e4ffb1 |
#####
|
|
|
e4ffb1 |
##
|
|
|
e4ffb1 |
## The Following Agent Has Been Tested On:
|
|
|
e4ffb1 |
-## * BladeSystem c7000 Enclosure
|
|
|
e4ffb1 |
+## * HP BladeSystem c7000 Enclosure
|
|
|
e4ffb1 |
+## * HP Integrity Superdome X (BL920s)
|
|
|
e4ffb1 |
#####
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
import sys, re
|
|
|
e4ffb1 |
+import pexpect, exceptions
|
|
|
e4ffb1 |
import atexit
|
|
|
e4ffb1 |
sys.path.append("@FENCEAGENTSLIBDIR@")
|
|
|
e4ffb1 |
from fencing import *
|
|
|
e4ffb1 |
from fencing import fail, EC_STATUS
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
#BEGIN_VERSION_GENERATION
|
|
|
e4ffb1 |
-RELEASE_VERSION="New Bladecenter Agent - test release on steroids"
|
|
|
e4ffb1 |
-REDHAT_COPYRIGHT=""
|
|
|
e4ffb1 |
-BUILD_DATE="March, 2008"
|
|
|
e4ffb1 |
+RELEASE_VERSION="4.0.11-HP"
|
|
|
e4ffb1 |
+BUILD_DATE="(built Mon Mar 30 08:31:24 EDT 2015)"
|
|
|
e4ffb1 |
+REDHAT_COPYRIGHT="Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved."
|
|
|
e4ffb1 |
#END_VERSION_GENERATION
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
+def get_enclosure_type(conn, options):
|
|
|
e4ffb1 |
+ conn.send_eol("show enclosure info")
|
|
|
e4ffb1 |
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ type_re=re.compile(r"^\s*Enclosure Type: (\w+)(.*?)\s*$")
|
|
|
e4ffb1 |
+ enclosure="unknown"
|
|
|
e4ffb1 |
+ for line in conn.before.splitlines():
|
|
|
e4ffb1 |
+ res = type_re.search(line)
|
|
|
e4ffb1 |
+ if res != None:
|
|
|
e4ffb1 |
+ enclosure=res.group(1)
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ if enclosure == "unknown":
|
|
|
e4ffb1 |
+ fail(EC_GENERIC_ERROR)
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ return enclosure.lower().strip()
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
def get_power_status(conn, options):
|
|
|
e4ffb1 |
- conn.send_eol("show server status " + options["--plug"])
|
|
|
e4ffb1 |
+ if options["enc_type"] == "superdome":
|
|
|
e4ffb1 |
+ cmd_send = "parstatus -M -p " + options["--plug"]
|
|
|
e4ffb1 |
+ powrestr = "^partition:\\d\\s+:\\w+\\s+/(\\w+)\\s.*$"
|
|
|
e4ffb1 |
+ else:
|
|
|
e4ffb1 |
+ cmd_send = "show server status " + options["--plug"]
|
|
|
e4ffb1 |
+ powrestr = "^\\s*Power: (.*?)\\s*$"
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ conn.send_eol(cmd_send)
|
|
|
e4ffb1 |
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
- power_re = re.compile(r"^\s*Power: (.*?)\s*$")
|
|
|
e4ffb1 |
+ power_re = re.compile(powrestr)
|
|
|
e4ffb1 |
status = "unknown"
|
|
|
e4ffb1 |
for line in conn.before.splitlines():
|
|
|
e4ffb1 |
res = power_re.search(line)
|
|
|
e4ffb1 |
if res != None:
|
|
|
e4ffb1 |
- status = res.group(1)
|
|
|
e4ffb1 |
+ if options["enc_type"] == "superdome":
|
|
|
e4ffb1 |
+ if res.group(1) == "DOWN":
|
|
|
e4ffb1 |
+ status = "off"
|
|
|
e4ffb1 |
+ else:
|
|
|
e4ffb1 |
+ status = "on"
|
|
|
e4ffb1 |
+ else:
|
|
|
e4ffb1 |
+ status = res.group(1)
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
if status == "unknown":
|
|
|
e4ffb1 |
if options.has_key("--missing-as-off"):
|
|
|
e4ffb1 |
@@ -38,23 +69,37 @@ def get_power_status(conn, options):
|
|
|
e4ffb1 |
return status.lower().strip()
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
def set_power_status(conn, options):
|
|
|
e4ffb1 |
+ if options["enc_type"] == "superdome":
|
|
|
e4ffb1 |
+ dev="partition "
|
|
|
e4ffb1 |
+ else:
|
|
|
e4ffb1 |
+ dev="server "
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
if options["--action"] == "on":
|
|
|
e4ffb1 |
- conn.send_eol("poweron server " + options["--plug"])
|
|
|
e4ffb1 |
+ conn.send_eol("poweron " + dev + options["--plug"])
|
|
|
e4ffb1 |
elif options["--action"] == "off":
|
|
|
e4ffb1 |
- conn.send_eol("poweroff server " + options["--plug"] + " force")
|
|
|
e4ffb1 |
+ conn.send_eol("poweroff " + dev + options["--plug"] + " force")
|
|
|
e4ffb1 |
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
-def get_blades_list(conn, options):
|
|
|
e4ffb1 |
+def get_instances_list(conn, options):
|
|
|
e4ffb1 |
outlets = {}
|
|
|
e4ffb1 |
-
|
|
|
e4ffb1 |
- conn.send_eol("show server list")
|
|
|
e4ffb1 |
+ if options["enc_type"] == "superdome":
|
|
|
e4ffb1 |
+ cmd_send = "parstatus -P -M"
|
|
|
e4ffb1 |
+ listrestr = "^partition:(\\d+)\\s+:\\w+\\s+/(\\w+)\\s+:OK.*?:(\\w+)\\s*$"
|
|
|
e4ffb1 |
+ else:
|
|
|
e4ffb1 |
+ cmd_send = "show server list"
|
|
|
e4ffb1 |
+ listrestr = "^\\s*(\\d+)\\s+(.*?)\\s+(.*?)\\s+OK\\s+(.*?)\\s+(.*?)\\s*$"
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ conn.send_eol(cmd_send)
|
|
|
e4ffb1 |
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
- list_re = re.compile(r"^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
|
|
|
e4ffb1 |
+ list_re = re.compile(listrestr)
|
|
|
e4ffb1 |
for line in conn.before.splitlines():
|
|
|
e4ffb1 |
res = list_re.search(line)
|
|
|
e4ffb1 |
if res != None:
|
|
|
e4ffb1 |
- outlets[res.group(1)] = (res.group(2), res.group(4).lower())
|
|
|
e4ffb1 |
+ if options["enc_type"] == "superdome":
|
|
|
e4ffb1 |
+ outlets[res.group(1)] = (res.group(3), res.group(2).lower())
|
|
|
e4ffb1 |
+ else:
|
|
|
e4ffb1 |
+ outlets[res.group(1)] = (res.group(2), res.group(4).lower())
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
return outlets
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
@@ -64,14 +109,17 @@ def main():
|
|
|
e4ffb1 |
atexit.register(atexit_handler)
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
all_opt["cmd_prompt"]["default"] = ["c7000oa>"]
|
|
|
e4ffb1 |
+ all_opt["login_timeout"]["default"] = "10"
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
options = check_input(device_opt, process_input(device_opt))
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
docs = {}
|
|
|
e4ffb1 |
docs["shortdesc"] = "Fence agent for HP BladeSystem"
|
|
|
e4ffb1 |
docs["longdesc"] = "fence_hpblade is an I/O Fencing agent \
|
|
|
e4ffb1 |
-which can be used with HP BladeSystem. It logs into an enclosure via telnet or ssh \
|
|
|
e4ffb1 |
-and uses the command line interface to power on and off blades."
|
|
|
e4ffb1 |
+which can be used with HP BladeSystem and HP Integrity Superdome X. \
|
|
|
e4ffb1 |
+It logs into the onboard administrator of an enclosure via telnet or \
|
|
|
e4ffb1 |
+ssh and uses the command line interface to power blades or partitions \
|
|
|
e4ffb1 |
+on or off."
|
|
|
e4ffb1 |
docs["vendorurl"] = "http://www.hp.com"
|
|
|
e4ffb1 |
show_docs(options, docs)
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
@@ -80,7 +128,10 @@ and uses the command line interface to power on and off blades."
|
|
|
e4ffb1 |
######
|
|
|
e4ffb1 |
options["eol"] = "\n"
|
|
|
e4ffb1 |
conn = fence_login(options)
|
|
|
e4ffb1 |
- result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ options["enc_type"] = get_enclosure_type(conn, options)
|
|
|
e4ffb1 |
+
|
|
|
e4ffb1 |
+ result = fence_action(conn, options, set_power_status, get_power_status, get_instances_list)
|
|
|
e4ffb1 |
fence_logout(conn, "exit")
|
|
|
e4ffb1 |
sys.exit(result)
|
|
|
e4ffb1 |
|
|
|
e4ffb1 |
--
|
|
|
e4ffb1 |
1.9.3
|
|
|
e4ffb1 |
|