8 Star 0 Fork 8

src-anolis-os / fence-agents

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bz2065114-fence_lpar-refactor.patch 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
Zhao Hang 提交于 2023-06-20 15:19 . update to fence-agents-4.10.0-43.el9
From e3dff8570b70f0c19eca84cf02f0aadd68e16599 Mon Sep 17 00:00:00 2001
From: Thomas Renninger <trenn@suse.com>
Date: Fri, 25 Feb 2022 14:05:42 +0100
Subject: [PATCH] fence_lpar: fix missing import logging, use fail_usage
and slightly re-factor code to avoid duplicate code lines.
Should be cleanup only, no functional change.
---
agents/lpar/fence_lpar.py | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/agents/lpar/fence_lpar.py b/agents/lpar/fence_lpar.py
index ad18c6191..2046b0e4e 100644
--- a/agents/lpar/fence_lpar.py
+++ b/agents/lpar/fence_lpar.py
@@ -28,31 +28,28 @@ def _normalize_status(status):
def get_power_status(conn, options):
if options["--hmc-version"] == "3":
- conn.send("lssyscfg -r lpar -m " + options["--managed"] + " -n " + options["--plug"] + " -F name,state\n")
-
- # First line (command) may cause parsing issues if long
- conn.readline()
- conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
-
- try:
- status = re.compile("^" + options["--plug"] + ",(.*?),.*$",
- re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
- except AttributeError as e:
- logging.error("Failed: {}".format(str(e)))
- fail(EC_STATUS_HMC)
+ command = "lssyscfg -r lpar -m " + options["--managed"] + " -n " + options["--plug"] + " -F name,state\n"
elif options["--hmc-version"] in ["4", "IVM"]:
- conn.send("lssyscfg -r lpar -m "+ options["--managed"] +
- " --filter 'lpar_names=" + options["--plug"] + "'\n")
+ command = "lssyscfg -r lpar -m "+ options["--managed"] + \
+ " --filter 'lpar_names=" + options["--plug"] + "'\n"
+ else:
+ # Bad HMC Version cannot be reached
+ fail(EC_STATUS_HMC)
- # First line (command) may cause parsing issues if long
- conn.readline()
- conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
+ conn.send(command)
+ # First line (command) may cause parsing issues if long
+ conn.readline()
+ conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
- try:
+ try:
+ if options["--hmc-version"] == "3":
+ status = re.compile("^" + options["--plug"] + ",(.*?),.*$",
+ re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+ elif options["--hmc-version"] in ["4", "IVM"]:
status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
- except AttributeError as e:
- logging.error("Failed: {}".format(str(e)))
- fail(EC_STATUS_HMC)
+ except AttributeError as e:
+ fail_usage("Command on HMC failed: {}\n{}".format(command, str(e)), False)
+ fail(EC_STATUS_HMC)
return _normalize_status(status)
1
https://gitee.com/src-anolis-os/fence-agents.git
git@gitee.com:src-anolis-os/fence-agents.git
src-anolis-os
fence-agents
fence-agents
a8

搜索帮助

53164aa7 5694891 3bd8fe86 5694891