Blob Blame History Raw
From 4b06b842e57f80bda87ec57b9e0e047fe89ad25f Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Wed, 26 Aug 2015 12:54:47 +0200
Subject: [PATCH 2/3] fence_ipmilan: Re-introduce -t / timeout option

In the new fence agent this option was replaced by --*-timeout but old
option should work as before. It sets all *-timeout to a value 'timeout'

Resolves: rhbz#1257137
---
 fence/agents/ipmilan/fence_ipmilan.py | 16 +++++++++++++++-
 tests/data/metadata/fence_idrac.xml   | 23 ++++++++++++++---------
 tests/data/metadata/fence_ilo3.xml    | 23 ++++++++++++++---------
 tests/data/metadata/fence_ilo4.xml    | 23 ++++++++++++++---------
 tests/data/metadata/fence_imm.xml     | 23 ++++++++++++++---------
 tests/data/metadata/fence_ipmilan.xml | 23 ++++++++++++++---------
 6 files changed, 85 insertions(+), 46 deletions(-)

diff --git a/fence/agents/ipmilan/fence_ipmilan.py b/fence/agents/ipmilan/fence_ipmilan.py
index 8224b83..fd04110 100644
--- a/fence/agents/ipmilan/fence_ipmilan.py
+++ b/fence/agents/ipmilan/fence_ipmilan.py
@@ -125,12 +125,21 @@ def define_new_opts():
 		"help" : "",
 		"order" : 1
 	}
+	all_opt["timeout"] = {
+		"getopt" : "t:",
+		"longopt" : "timeout",
+		"help" : "-t [seconds]                   Timeout (sec) for IPMI operation",
+		"required" : "0",
+		"shortdesc" : "Timeout (sec) for IPMI operation",
+		"order" : 1
+	}
 
 def main():
 	atexit.register(atexit_handler)
 
 	device_opt = ["ipaddr", "ipport", "login", "no_login", "no_password", "passwd",
-		"lanplus", "auth", "cipher", "privlvl", "sudo", "ipmitool_path", "method", "obsolete_ip"]
+		"lanplus", "auth", "cipher", "privlvl", "sudo", "ipmitool_path", "method",
+		"obsolete_ip", "timeout"]
 	define_new_opts()
 
 	if os.path.basename(sys.argv[0]) == "fence_ilo3":
@@ -148,6 +157,11 @@ def main():
 		pi["--ip"] = pi["--obsolete-ip"]
 	options = check_input(device_opt, pi)
 
+	if "--timeout" in options:
+		options["--shell-timeout"] = options["--timeout"]
+		options["--power-timeout"] = options["--timeout"]
+		options["--login-timeout"] = options["--timeout"]
+
 	docs = {}
 	docs["shortdesc"] = "Fence agent for IPMI"
 	docs["longdesc"] = "fence_ipmilan is an I/O Fencing agent\
diff --git a/tests/data/metadata/fence_idrac.xml b/tests/data/metadata/fence_idrac.xml
index 0aced2a..6e0b834 100644
--- a/tests/data/metadata/fence_idrac.xml
+++ b/tests/data/metadata/fence_idrac.xml
@@ -64,6 +64,11 @@
 		</content>
 		<shortdesc lang="en">IPMI Lan Auth type.</shortdesc>
 	</parameter>
+	<parameter name="action" unique="0" required="1">
+		<getopt mixed="-o, --action=[action]" />
+		<content type="string" default="reboot"  />
+		<shortdesc lang="en">Fencing Action</shortdesc>
+	</parameter>
 	<parameter name="cipher" unique="0" required="0">
 		<getopt mixed="-C, --cipher=[cipher]" />
 		<content type="string"  />
@@ -79,10 +84,10 @@
 		</content>
 		<shortdesc lang="en">Privilege level on IPMI device</shortdesc>
 	</parameter>
-	<parameter name="action" unique="0" required="1">
-		<getopt mixed="-o, --action=[action]" />
-		<content type="string" default="reboot"  />
-		<shortdesc lang="en">Fencing Action</shortdesc>
+	<parameter name="timeout" unique="0" required="0">
+		<getopt mixed="-t [seconds]                   Timeout (sec) for IPMI operation" />
+		<content type="string"  />
+		<shortdesc lang="en">Timeout (sec) for IPMI operation</shortdesc>
 	</parameter>
 	<parameter name="login" unique="0" required="0">
 		<getopt mixed="-l, --username=[name]" />
@@ -119,16 +124,16 @@
 		<content type="string" default="5"  />
 		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
 	</parameter>
-	<parameter name="power_timeout" unique="0" required="0">
-		<getopt mixed="--power-timeout=[seconds]" />
-		<content type="string" default="20"  />
-		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
-	</parameter>
 	<parameter name="delay" unique="0" required="0">
 		<getopt mixed="--delay=[seconds]" />
 		<content type="string" default="0"  />
 		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
 	</parameter>
+	<parameter name="power_timeout" unique="0" required="0">
+		<getopt mixed="--power-timeout=[seconds]" />
+		<content type="string" default="20"  />
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
+	</parameter>
 	<parameter name="ipmitool_path" unique="0" required="0">
 		<getopt mixed="--ipmitool-path=[path]" />
 		<content type="string" default="/usr/bin/ipmitool"  />
diff --git a/tests/data/metadata/fence_ilo3.xml b/tests/data/metadata/fence_ilo3.xml
index 67e869b..1253539 100644
--- a/tests/data/metadata/fence_ilo3.xml
+++ b/tests/data/metadata/fence_ilo3.xml
@@ -64,6 +64,11 @@
 		</content>
 		<shortdesc lang="en">IPMI Lan Auth type.</shortdesc>
 	</parameter>
+	<parameter name="action" unique="0" required="1">
+		<getopt mixed="-o, --action=[action]" />
+		<content type="string" default="reboot"  />
+		<shortdesc lang="en">Fencing Action</shortdesc>
+	</parameter>
 	<parameter name="cipher" unique="0" required="0">
 		<getopt mixed="-C, --cipher=[cipher]" />
 		<content type="string"  />
@@ -79,10 +84,10 @@
 		</content>
 		<shortdesc lang="en">Privilege level on IPMI device</shortdesc>
 	</parameter>
-	<parameter name="action" unique="0" required="1">
-		<getopt mixed="-o, --action=[action]" />
-		<content type="string" default="reboot"  />
-		<shortdesc lang="en">Fencing Action</shortdesc>
+	<parameter name="timeout" unique="0" required="0">
+		<getopt mixed="-t [seconds]                   Timeout (sec) for IPMI operation" />
+		<content type="string"  />
+		<shortdesc lang="en">Timeout (sec) for IPMI operation</shortdesc>
 	</parameter>
 	<parameter name="login" unique="0" required="0">
 		<getopt mixed="-l, --username=[name]" />
@@ -119,16 +124,16 @@
 		<content type="string" default="5"  />
 		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
 	</parameter>
-	<parameter name="power_timeout" unique="0" required="0">
-		<getopt mixed="--power-timeout=[seconds]" />
-		<content type="string" default="20"  />
-		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
-	</parameter>
 	<parameter name="delay" unique="0" required="0">
 		<getopt mixed="--delay=[seconds]" />
 		<content type="string" default="0"  />
 		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
 	</parameter>
+	<parameter name="power_timeout" unique="0" required="0">
+		<getopt mixed="--power-timeout=[seconds]" />
+		<content type="string" default="20"  />
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
+	</parameter>
 	<parameter name="ipmitool_path" unique="0" required="0">
 		<getopt mixed="--ipmitool-path=[path]" />
 		<content type="string" default="/usr/bin/ipmitool"  />
diff --git a/tests/data/metadata/fence_ilo4.xml b/tests/data/metadata/fence_ilo4.xml
index b7dd31a..6498be8 100644
--- a/tests/data/metadata/fence_ilo4.xml
+++ b/tests/data/metadata/fence_ilo4.xml
@@ -64,6 +64,11 @@
 		</content>
 		<shortdesc lang="en">IPMI Lan Auth type.</shortdesc>
 	</parameter>
+	<parameter name="action" unique="0" required="1">
+		<getopt mixed="-o, --action=[action]" />
+		<content type="string" default="reboot"  />
+		<shortdesc lang="en">Fencing Action</shortdesc>
+	</parameter>
 	<parameter name="cipher" unique="0" required="0">
 		<getopt mixed="-C, --cipher=[cipher]" />
 		<content type="string"  />
@@ -79,10 +84,10 @@
 		</content>
 		<shortdesc lang="en">Privilege level on IPMI device</shortdesc>
 	</parameter>
-	<parameter name="action" unique="0" required="1">
-		<getopt mixed="-o, --action=[action]" />
-		<content type="string" default="reboot"  />
-		<shortdesc lang="en">Fencing Action</shortdesc>
+	<parameter name="timeout" unique="0" required="0">
+		<getopt mixed="-t [seconds]                   Timeout (sec) for IPMI operation" />
+		<content type="string"  />
+		<shortdesc lang="en">Timeout (sec) for IPMI operation</shortdesc>
 	</parameter>
 	<parameter name="login" unique="0" required="0">
 		<getopt mixed="-l, --username=[name]" />
@@ -119,16 +124,16 @@
 		<content type="string" default="5"  />
 		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
 	</parameter>
-	<parameter name="power_timeout" unique="0" required="0">
-		<getopt mixed="--power-timeout=[seconds]" />
-		<content type="string" default="20"  />
-		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
-	</parameter>
 	<parameter name="delay" unique="0" required="0">
 		<getopt mixed="--delay=[seconds]" />
 		<content type="string" default="0"  />
 		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
 	</parameter>
+	<parameter name="power_timeout" unique="0" required="0">
+		<getopt mixed="--power-timeout=[seconds]" />
+		<content type="string" default="20"  />
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
+	</parameter>
 	<parameter name="ipmitool_path" unique="0" required="0">
 		<getopt mixed="--ipmitool-path=[path]" />
 		<content type="string" default="/usr/bin/ipmitool"  />
diff --git a/tests/data/metadata/fence_imm.xml b/tests/data/metadata/fence_imm.xml
index 0e7588d..e6d67bc 100644
--- a/tests/data/metadata/fence_imm.xml
+++ b/tests/data/metadata/fence_imm.xml
@@ -64,6 +64,11 @@
 		</content>
 		<shortdesc lang="en">IPMI Lan Auth type.</shortdesc>
 	</parameter>
+	<parameter name="action" unique="0" required="1">
+		<getopt mixed="-o, --action=[action]" />
+		<content type="string" default="reboot"  />
+		<shortdesc lang="en">Fencing Action</shortdesc>
+	</parameter>
 	<parameter name="cipher" unique="0" required="0">
 		<getopt mixed="-C, --cipher=[cipher]" />
 		<content type="string"  />
@@ -79,10 +84,10 @@
 		</content>
 		<shortdesc lang="en">Privilege level on IPMI device</shortdesc>
 	</parameter>
-	<parameter name="action" unique="0" required="1">
-		<getopt mixed="-o, --action=[action]" />
-		<content type="string" default="reboot"  />
-		<shortdesc lang="en">Fencing Action</shortdesc>
+	<parameter name="timeout" unique="0" required="0">
+		<getopt mixed="-t [seconds]                   Timeout (sec) for IPMI operation" />
+		<content type="string"  />
+		<shortdesc lang="en">Timeout (sec) for IPMI operation</shortdesc>
 	</parameter>
 	<parameter name="login" unique="0" required="0">
 		<getopt mixed="-l, --username=[name]" />
@@ -119,16 +124,16 @@
 		<content type="string" default="5"  />
 		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
 	</parameter>
-	<parameter name="power_timeout" unique="0" required="0">
-		<getopt mixed="--power-timeout=[seconds]" />
-		<content type="string" default="20"  />
-		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
-	</parameter>
 	<parameter name="delay" unique="0" required="0">
 		<getopt mixed="--delay=[seconds]" />
 		<content type="string" default="0"  />
 		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
 	</parameter>
+	<parameter name="power_timeout" unique="0" required="0">
+		<getopt mixed="--power-timeout=[seconds]" />
+		<content type="string" default="20"  />
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
+	</parameter>
 	<parameter name="ipmitool_path" unique="0" required="0">
 		<getopt mixed="--ipmitool-path=[path]" />
 		<content type="string" default="/usr/bin/ipmitool"  />
diff --git a/tests/data/metadata/fence_ipmilan.xml b/tests/data/metadata/fence_ipmilan.xml
index 443365c..97edfbb 100644
--- a/tests/data/metadata/fence_ipmilan.xml
+++ b/tests/data/metadata/fence_ipmilan.xml
@@ -64,6 +64,11 @@
 		</content>
 		<shortdesc lang="en">IPMI Lan Auth type.</shortdesc>
 	</parameter>
+	<parameter name="action" unique="0" required="1">
+		<getopt mixed="-o, --action=[action]" />
+		<content type="string" default="reboot"  />
+		<shortdesc lang="en">Fencing Action</shortdesc>
+	</parameter>
 	<parameter name="cipher" unique="0" required="0">
 		<getopt mixed="-C, --cipher=[cipher]" />
 		<content type="string"  />
@@ -79,10 +84,10 @@
 		</content>
 		<shortdesc lang="en">Privilege level on IPMI device</shortdesc>
 	</parameter>
-	<parameter name="action" unique="0" required="1">
-		<getopt mixed="-o, --action=[action]" />
-		<content type="string" default="reboot"  />
-		<shortdesc lang="en">Fencing Action</shortdesc>
+	<parameter name="timeout" unique="0" required="0">
+		<getopt mixed="-t [seconds]                   Timeout (sec) for IPMI operation" />
+		<content type="string"  />
+		<shortdesc lang="en">Timeout (sec) for IPMI operation</shortdesc>
 	</parameter>
 	<parameter name="login" unique="0" required="0">
 		<getopt mixed="-l, --username=[name]" />
@@ -119,16 +124,16 @@
 		<content type="string" default="5"  />
 		<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
 	</parameter>
-	<parameter name="power_timeout" unique="0" required="0">
-		<getopt mixed="--power-timeout=[seconds]" />
-		<content type="string" default="20"  />
-		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
-	</parameter>
 	<parameter name="delay" unique="0" required="0">
 		<getopt mixed="--delay=[seconds]" />
 		<content type="string" default="0"  />
 		<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
 	</parameter>
+	<parameter name="power_timeout" unique="0" required="0">
+		<getopt mixed="--power-timeout=[seconds]" />
+		<content type="string" default="20"  />
+		<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
+	</parameter>
 	<parameter name="ipmitool_path" unique="0" required="0">
 		<getopt mixed="--ipmitool-path=[path]" />
 		<content type="string" default="/usr/bin/ipmitool"  />
-- 
1.9.3