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