fence_mpath: fix fail_usage() issue and a couple of other minor issues w/the newly added plug/port parameter

(cherry picked from commit 8907dd3770cf624751f850d0ef860f161bc7bb1e)
This commit is contained in:
zhanghan 2023-08-23 16:24:09 +08:00 committed by openeuler-sync-bot
parent 47d9ae887a
commit 53c9d79b69
2 changed files with 83 additions and 1 deletions

View File

@ -6,12 +6,14 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.5.0
Release: 1
Release: 2
License: GPLv2+ and LGPLv2+
Group: System Environment/Base
URL: https://github.com/ClusterLabs/fence-agents
Source0: https://github.com/ClusterLabs/fence-agents/archive/v4.5.0.tar.gz
Patch0: fix-fail_usage-issue-and-a-couple-of-other-minor-iss.patch
%global allfenceagents %(cat <<EOF
fence-agents-alom \\
fence-agents-amt \\
@ -88,6 +90,7 @@ BuildRequires: python3-google-api-client
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
# prevent compilation of something that won't get used anyway
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
@ -881,6 +884,9 @@ Fence agent for IBM z/VM over IP.
%{_mandir}/man8/fence_zvmip.8*
%changelog
* Wed Aug 23 2023 zhanghan <zhanghan@kylinos.cn> - 4.5.0-2
- fix fail_usage() issue and a couple of other minor issues w/the newly added plug/port parameter
* Wed Jun 28 2023 zhaochaoxiang <zhaochaoxiang@kylinos.cn> - 4.5.0-1
- Update package to version 4.5.0

View File

@ -0,0 +1,76 @@
From 44b72f9ee7008e1b37c6be2288106dcd09676938 Mon Sep 17 00:00:00 2001
From: zhanghan <zhanghan@kylinos.cn>
Date: Wed, 23 Aug 2023 16:14:15 +0800
Subject: [PATCH] fix fail_usage() issue and a couple of other minor issues
w/the newly added plug/port parameter
---
agents/mpath/fence_mpath.py | 12 +++++++-----
tests/data/metadata/fence_mpath.xml | 10 +++++-----
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/agents/mpath/fence_mpath.py b/agents/mpath/fence_mpath.py
index 25aeb05..aa56242 100644
--- a/agents/mpath/fence_mpath.py
+++ b/agents/mpath/fence_mpath.py
@@ -213,7 +213,7 @@ Each device must support SCSI-3 persistent reservations.",
"longopt" : "key",
"help" : "-k, --key=[key] Replaced by -n, --plug",
"required" : "0",
- "shortdesc" : "Replaced by -n, --plug",
+ "shortdesc" : "Replaced by port/-n/--plug",
"order": 1
}
all_opt["mpathpersist_path"] = {
@@ -244,7 +244,8 @@ def main():
define_new_opts()
- all_opt["port"]["help"] = "Key to use for the current operation"
+ all_opt["port"]["required"] = "0"
+ all_opt["port"]["help"] = "-n, --plug=[key] Key to use for the current operation"
all_opt["port"]["shortdesc"] = "Key to use for the current operation. \
This key should be unique to a node and have to be written in \
/etc/multipath.conf. For the \"on\" action, the key specifies the key use to \
@@ -266,9 +267,10 @@ be removed from the device(s)."
if "--key" in options:
options["--plug"] = options["--key"]
del options["--key"]
- elif options["--action"] in ["off", "on", "reboot", "status"] \
- and "--plug" not in options:
- fail_usage("Failed: You have to enter plug number or machine identification", stop)
+ elif "--help" not in options and options["--action"] in ["off", "on", \
+ "reboot", "status", "validate-all"] and "--plug" not in options:
+ stop_after_error = False if options["--action"] == "validate-all" else True
+ fail_usage("Failed: You have to enter plug number or machine identification", stop_after_error)
docs = {}
docs["shortdesc"] = "Fence agent for multipath persistent reservation"
diff --git a/tests/data/metadata/fence_mpath.xml b/tests/data/metadata/fence_mpath.xml
index fe9378d..f5e6082 100644
--- a/tests/data/metadata/fence_mpath.xml
+++ b/tests/data/metadata/fence_mpath.xml
@@ -17,15 +17,15 @@ The fence_mpath agent works by having a unique key for each node that has to be
<parameter name="key" unique="0" required="0">
<getopt mixed="-k, --key=[key]" />
<content type="string" />
- <shortdesc lang="en">Replaced by -n, --plug</shortdesc>
+ <shortdesc lang="en">Replaced by port/-n/--plug</shortdesc>
</parameter>
- <parameter name="plug" unique="0" required="1" obsoletes="port">
- <getopt mixed="Key to use for the current operation" />
+ <parameter name="plug" unique="0" required="0" obsoletes="port">
+ <getopt mixed="-n, --plug=[key]" />
<content type="string" />
<shortdesc lang="en">Key to use for the current operation. This key should be unique to a node and have to be written in /etc/multipath.conf. For the "on" action, the key specifies the key use to register the local node. For the "off" action, this key specifies the key to be removed from the device(s).</shortdesc>
</parameter>
- <parameter name="port" unique="0" required="1" deprecated="1">
- <getopt mixed="Key to use for the current operation" />
+ <parameter name="port" unique="0" required="0" deprecated="1">
+ <getopt mixed="-n, --plug=[key]" />
<content type="string" />
<shortdesc lang="en">Key to use for the current operation. This key should be unique to a node and have to be written in /etc/multipath.conf. For the "on" action, the key specifies the key use to register the local node. For the "off" action, this key specifies the key to be removed from the device(s).</shortdesc>
</parameter>
--
2.33.0