|
|
729278 |
From 6d0b2cb598135b697ee583e3514aa427fc0e4cf8 Mon Sep 17 00:00:00 2001
|
|
|
729278 |
From: Reid Wahl <nrwahl@protonmail.com>
|
|
|
729278 |
Date: Wed, 29 Jul 2020 18:33:17 -0700
|
|
|
729278 |
Subject: [PATCH 1/2] fence_lpar: Fix list-status action
|
|
|
729278 |
|
|
|
729278 |
The `list-status` action prints "UNKNOWN" status for all LPARs when
|
|
|
729278 |
`--hmc-version` is `"4"` or `"IVM"`.
|
|
|
729278 |
|
|
|
729278 |
This commit fixes that by mapping the statuses returned by the HMC
|
|
|
729278 |
(e.g., "Running") to the statuses that the fencing library expects
|
|
|
729278 |
(e.g., "on").
|
|
|
729278 |
|
|
|
729278 |
Resolves: RHBZ#1861926
|
|
|
729278 |
|
|
|
729278 |
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
|
|
|
729278 |
---
|
|
|
729278 |
agents/lpar/fence_lpar.py | 27 +++++++++++++++------------
|
|
|
729278 |
1 file changed, 15 insertions(+), 12 deletions(-)
|
|
|
729278 |
|
|
|
729278 |
diff --git a/agents/lpar/fence_lpar.py b/agents/lpar/fence_lpar.py
|
|
|
729278 |
index 9dfabc43..03068466 100644
|
|
|
729278 |
--- a/agents/lpar/fence_lpar.py
|
|
|
729278 |
+++ b/agents/lpar/fence_lpar.py
|
|
|
729278 |
@@ -16,6 +16,16 @@
|
|
|
729278 |
from fencing import *
|
|
|
729278 |
from fencing import fail, fail_usage, EC_STATUS_HMC
|
|
|
729278 |
|
|
|
729278 |
+##
|
|
|
729278 |
+## Transformation to standard ON/OFF status if possible
|
|
|
729278 |
+def _normalize_status(status):
|
|
|
729278 |
+ if status in ["Running", "Open Firmware", "Shutting Down", "Starting"]:
|
|
|
729278 |
+ status = "on"
|
|
|
729278 |
+ else:
|
|
|
729278 |
+ status = "off"
|
|
|
729278 |
+
|
|
|
729278 |
+ return status
|
|
|
729278 |
+
|
|
|
729278 |
def get_power_status(conn, options):
|
|
|
729278 |
if options["--hmc-version"] == "3":
|
|
|
729278 |
conn.send("lssyscfg -r lpar -m " + options["--managed"] + " -n " + options["--plug"] + " -F name,state\n")
|
|
|
729278 |
@@ -42,14 +52,7 @@ def get_power_status(conn, options):
|
|
|
729278 |
except AttributeError:
|
|
|
729278 |
fail(EC_STATUS_HMC)
|
|
|
729278 |
|
|
|
729278 |
- ##
|
|
|
729278 |
- ## Transformation to standard ON/OFF status if possible
|
|
|
729278 |
- if status in ["Running", "Open Firmware", "Shutting Down", "Starting"]:
|
|
|
729278 |
- status = "on"
|
|
|
729278 |
- else:
|
|
|
729278 |
- status = "off"
|
|
|
729278 |
-
|
|
|
729278 |
- return status
|
|
|
729278 |
+ return _normalize_status(status)
|
|
|
729278 |
|
|
|
729278 |
def set_power_status(conn, options):
|
|
|
729278 |
if options["--hmc-version"] == "3":
|
|
|
729278 |
@@ -111,10 +114,10 @@ def get_lpar_list(conn, options):
|
|
|
729278 |
lines = res.group(1).split("\n")
|
|
|
729278 |
for outlet_line in lines:
|
|
|
729278 |
try:
|
|
|
729278 |
- (port, status) = outlet_line.split(":")
|
|
|
729278 |
+ (port, status) = outlet_line.rstrip().split(":")
|
|
|
729278 |
except ValueError:
|
|
|
729278 |
fail_usage('Output does not match expected HMC version, try different one');
|
|
|
729278 |
- outlets[port] = ("", status)
|
|
|
729278 |
+ outlets[port] = ("", _normalize_status(status))
|
|
|
729278 |
elif options["--hmc-version"] == "IVM":
|
|
|
729278 |
conn.send("lssyscfg -r lpar -m " + options["--managed"] +
|
|
|
729278 |
" -F name,state\n")
|
|
|
729278 |
@@ -133,10 +136,10 @@ def get_lpar_list(conn, options):
|
|
|
729278 |
lines = res.group(1).split("\n")
|
|
|
729278 |
for outlet_line in lines:
|
|
|
729278 |
try:
|
|
|
729278 |
- (port, status) = outlet_line.split(",")
|
|
|
729278 |
+ (port, status) = outlet_line.rstrip().split(",")
|
|
|
729278 |
except ValueError:
|
|
|
729278 |
fail_usage('Output does not match expected HMC version, try different one');
|
|
|
729278 |
- outlets[port] = ("", status)
|
|
|
729278 |
+ outlets[port] = ("", _normalize_status(status))
|
|
|
729278 |
|
|
|
729278 |
return outlets
|
|
|
729278 |
|
|
|
729278 |
|
|
|
729278 |
From 4f7b40c0cde896f2f5b09e796ba34450e90aee6c Mon Sep 17 00:00:00 2001
|
|
|
729278 |
From: Reid Wahl <nrwahl@protonmail.com>
|
|
|
729278 |
Date: Wed, 29 Jul 2020 18:43:47 -0700
|
|
|
729278 |
Subject: [PATCH 2/2] fence_lpar: Reduce code duplication in get_lpar_list
|
|
|
729278 |
|
|
|
729278 |
The logic for HMC version 4 and HMC version IVM are the same except for
|
|
|
729278 |
the use of a different separator character. This commit condenses them
|
|
|
729278 |
into one block.
|
|
|
729278 |
|
|
|
729278 |
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
|
|
|
729278 |
---
|
|
|
729278 |
agents/lpar/fence_lpar.py | 28 ++++------------------------
|
|
|
729278 |
1 file changed, 4 insertions(+), 24 deletions(-)
|
|
|
729278 |
|
|
|
729278 |
diff --git a/agents/lpar/fence_lpar.py b/agents/lpar/fence_lpar.py
|
|
|
729278 |
index 03068466..7560a82c 100644
|
|
|
729278 |
--- a/agents/lpar/fence_lpar.py
|
|
|
729278 |
+++ b/agents/lpar/fence_lpar.py
|
|
|
729278 |
@@ -96,31 +96,11 @@ def get_lpar_list(conn, options):
|
|
|
729278 |
lines = res.group(2).split("\n")
|
|
|
729278 |
for outlet_line in lines:
|
|
|
729278 |
outlets[outlet_line.rstrip()] = ("", "")
|
|
|
729278 |
- elif options["--hmc-version"] == "4":
|
|
|
729278 |
- conn.send("lssyscfg -r lpar -m " + options["--managed"] +
|
|
|
729278 |
- " -F name:state\n")
|
|
|
729278 |
-
|
|
|
729278 |
- ## We have to remove first line (command)
|
|
|
729278 |
- conn.readline()
|
|
|
729278 |
- conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
|
|
|
729278 |
-
|
|
|
729278 |
- ## We have to remove last line (part of new prompt)
|
|
|
729278 |
- ####
|
|
|
729278 |
- res = re.search("^(.*)\n.*$", conn.before, re.S)
|
|
|
729278 |
-
|
|
|
729278 |
- if res == None:
|
|
|
729278 |
- fail_usage("Unable to parse output of list command")
|
|
|
729278 |
+ elif options["--hmc-version"] in ["4", "IVM"]:
|
|
|
729278 |
+ sep = ":" if options["--hmc-version"] == "4" else ","
|
|
|
729278 |
|
|
|
729278 |
- lines = res.group(1).split("\n")
|
|
|
729278 |
- for outlet_line in lines:
|
|
|
729278 |
- try:
|
|
|
729278 |
- (port, status) = outlet_line.rstrip().split(":")
|
|
|
729278 |
- except ValueError:
|
|
|
729278 |
- fail_usage('Output does not match expected HMC version, try different one');
|
|
|
729278 |
- outlets[port] = ("", _normalize_status(status))
|
|
|
729278 |
- elif options["--hmc-version"] == "IVM":
|
|
|
729278 |
conn.send("lssyscfg -r lpar -m " + options["--managed"] +
|
|
|
729278 |
- " -F name,state\n")
|
|
|
729278 |
+ " -F name" + sep + "state\n")
|
|
|
729278 |
|
|
|
729278 |
## We have to remove first line (command)
|
|
|
729278 |
conn.readline()
|
|
|
729278 |
@@ -136,7 +116,7 @@ def get_lpar_list(conn, options):
|
|
|
729278 |
lines = res.group(1).split("\n")
|
|
|
729278 |
for outlet_line in lines:
|
|
|
729278 |
try:
|
|
|
729278 |
- (port, status) = outlet_line.rstrip().split(",")
|
|
|
729278 |
+ (port, status) = outlet_line.rstrip().split(sep)
|
|
|
729278 |
except ValueError:
|
|
|
729278 |
fail_usage('Output does not match expected HMC version, try different one');
|
|
|
729278 |
outlets[port] = ("", _normalize_status(status))
|