commit 2a56e0b3fd7ce168afb33b57685a6b1a59a0efe6
Author: Marek 'marx' Grac <mgrac@redhat.com>
Date: Mon Sep 19 10:21:41 2016 +0200
fence_lpar: Add support for IVM
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 31b0521..de8ce0d 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -32,7 +32,7 @@ def get_power_status(conn, options):
re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
except AttributeError:
fail(EC_STATUS_HMC)
- elif options["--hmc-version"] == "4":
+ elif options["--hmc-version"] in ["4", "IVM"]:
conn.send("lssyscfg -r lpar -m "+ options["--managed"] +
" --filter 'lpar_names=" + options["--plug"] + "'\n")
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
@@ -56,7 +56,7 @@ def set_power_status(conn, options):
conn.send("chsysstate -o " + options["--action"] + " -r lpar -m " + options["--managed"]
+ " -n " + options["--plug"] + "\n")
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
- elif options["--hmc-version"] == "4":
+ elif options["--hmc-version"] in ["4", "IVM"]:
if options["--action"] == "on":
conn.send("chsysstate -o on -r lpar -m " + options["--managed"] +
" -n " + options["--plug"] +
@@ -98,7 +98,29 @@ def get_lpar_list(conn, options):
lines = res.group(1).split("\n")
for outlet_line in lines:
- (port, status) = outlet_line.split(":")
+ try:
+ (port, status) = outlet_line.split(":")
+ except ValueError:
+ fail_usage('Output does not match expected HMC version, try different one');
+ outlets[port] = ("", status)
+ elif options["--hmc-version"] == "IVM":
+ conn.send("lssyscfg -r lpar -m " + options["--managed"] +
+ " -F name,state\n")
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
+
+ ## We have to remove first line (command) and last line (part of new prompt)
+ ####
+ res = re.search("^.+?\n(.*)\n.*$", conn.before, re.S)
+
+ if res == None:
+ fail_usage("Unable to parse output of list command")
+
+ lines = res.group(1).split("\n")
+ for outlet_line in lines:
+ try:
+ (port, status) = outlet_line.split(",")
+ except ValueError:
+ fail_usage('Output does not match expected HMC version, try different one');
outlets[port] = ("", status)
return outlets
@@ -114,11 +136,11 @@ def define_new_opts():
all_opt["hmc_version"] = {
"getopt" : "H:",
"longopt" : "hmc-version",
- "help" : "-H, --hmc-version=[version] Force HMC version to use: 3, 4 (default)",
+ "help" : "-H, --hmc-version=[version] Force HMC version to use: 3, 4 (default), ivm",
"required" : "0",
- "shortdesc" : "Force HMC version to use (3 or 4)",
+ "shortdesc" : "Force HMC version to use (3, 4 or IVM)",
"default" : "4",
- "choices" : ["3", "4"],
+ "choices" : ["3", "4", "ivm"],
"order" : 1}
def main():
diff --git a/tests/data/metadata/fence_lpar.xml b/tests/data/metadata/fence_lpar.xml
index 8c82925..199ca4e 100644
--- a/tests/data/metadata/fence_lpar.xml
+++ b/tests/data/metadata/fence_lpar.xml
@@ -48,8 +48,9 @@
<content type="select" default="4" >
<option value="3" />
<option value="4" />
+ <option value="ivm" />
</content>
- <shortdesc lang="en">Force HMC version to use (3 or 4)</shortdesc>
+ <shortdesc lang="en">Force HMC version to use (3, 4 or IVM)</shortdesc>
</parameter>
<parameter name="inet4_only" unique="0" required="0">
<getopt mixed="-4, --inet4-only" />