Blame SOURCES/bz1753228-fence_mpath-2-fix-plug-parameter-issues.patch

66332a
From 868c494d17952eecc6736683c6df04aa9d3a3199 Mon Sep 17 00:00:00 2001
66332a
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
66332a
Date: Fri, 20 Sep 2019 12:06:55 +0200
66332a
Subject: [PATCH] fence_mpath: fix fail_usage() issue and a couple of other
66332a
 minor issues w/the newly added plug/port parameter
66332a
66332a
---
66332a
 agents/mpath/fence_mpath.py         | 12 +++++++-----
66332a
 tests/data/metadata/fence_mpath.xml | 10 +++++-----
66332a
 2 files changed, 12 insertions(+), 10 deletions(-)
66332a
66332a
diff --git a/agents/mpath/fence_mpath.py b/agents/mpath/fence_mpath.py
66332a
index 25aeb052..73517851 100644
66332a
--- a/agents/mpath/fence_mpath.py
66332a
+++ b/agents/mpath/fence_mpath.py
66332a
@@ -213,7 +213,7 @@ def define_new_opts():
66332a
 		"longopt" : "key",
66332a
 		"help" : "-k, --key=[key]                Replaced by -n, --plug",
66332a
 		"required" : "0",
66332a
-		"shortdesc" : "Replaced by -n, --plug",
66332a
+		"shortdesc" : "Replaced by port/-n/--plug",
66332a
 		"order": 1
66332a
 	}
66332a
 	all_opt["mpathpersist_path"] = {
66332a
@@ -244,7 +244,8 @@ def main():
66332a
 
66332a
 	define_new_opts()
66332a
 
66332a
-	all_opt["port"]["help"] = "Key to use for the current operation"
66332a
+	all_opt["port"]["required"] = "0"
66332a
+	all_opt["port"]["help"] = "-n, --plug=[key]               Key to use for the current operation"
66332a
 	all_opt["port"]["shortdesc"] = "Key to use for the current operation. \
66332a
 This key should be unique to a node and have to be written in \
66332a
 /etc/multipath.conf. For the \"on\" action, the key specifies the key use to \
66332a
@@ -266,9 +267,10 @@ def main():
66332a
 	if "--key" in options:
66332a
 		options["--plug"] = options["--key"]
66332a
 		del options["--key"]
66332a
-	elif options["--action"] in ["off", "on", "reboot", "status"] \
66332a
-	     and "--plug" not in options:
66332a
-		fail_usage("Failed: You have to enter plug number or machine identification", stop)
66332a
+	elif "--help" not in options and options["--action"] in ["off", "on", \
66332a
+	     "reboot", "status", "validate-all"] and "--plug" not in options:
66332a
+		stop_after_error = False if options["--action"] == "validate-all" else True
66332a
+		fail_usage("Failed: You have to enter plug number or machine identification", stop_after_error)
66332a
 
66332a
 	docs = {}
66332a
 	docs["shortdesc"] = "Fence agent for multipath persistent reservation"
66332a
diff --git a/tests/data/metadata/fence_mpath.xml b/tests/data/metadata/fence_mpath.xml
66332a
index fe9378df..f5e60823 100644
66332a
--- a/tests/data/metadata/fence_mpath.xml
66332a
+++ b/tests/data/metadata/fence_mpath.xml
66332a
@@ -17,15 +17,15 @@ The fence_mpath agent works by having a unique key for each node that has to be
66332a
 	<parameter name="key" unique="0" required="0">
66332a
 		<getopt mixed="-k, --key=[key]" />
66332a
 		<content type="string"  />
66332a
-		<shortdesc lang="en">Replaced by -n, --plug</shortdesc>
66332a
+		<shortdesc lang="en">Replaced by port/-n/--plug</shortdesc>
66332a
 	</parameter>
66332a
-	<parameter name="plug" unique="0" required="1" obsoletes="port">
66332a
-		<getopt mixed="Key to use for the current operation" />
66332a
+	<parameter name="plug" unique="0" required="0" obsoletes="port">
66332a
+		<getopt mixed="-n, --plug=[key]" />
66332a
 		<content type="string"  />
66332a
 		<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>
66332a
 	</parameter>
66332a
-	<parameter name="port" unique="0" required="1" deprecated="1">
66332a
-		<getopt mixed="Key to use for the current operation" />
66332a
+	<parameter name="port" unique="0" required="0" deprecated="1">
66332a
+		<getopt mixed="-n, --plug=[key]" />
66332a
 		<content type="string"  />
66332a
 		<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>
66332a
 	</parameter>