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

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