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

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