Blame SOURCES/bz1286045-fence_ipmilan-add-diag-action.patch

e4ffb1
diff -uNr a/fence/agents/ipmilan/fence_ipmilan.py b/fence/agents/ipmilan/fence_ipmilan.py
e4ffb1
--- a/fence/agents/ipmilan/fence_ipmilan.py	2016-03-14 10:33:38.419438036 +0100
e4ffb1
+++ b/fence/agents/ipmilan/fence_ipmilan.py	2016-03-14 10:41:41.376326426 +0100
e4ffb1
@@ -27,6 +27,10 @@
e4ffb1
 	output = run_command(options, create_command(options, "cycle"))
e4ffb1
 	return bool(re.search('chassis power control: cycle', str(output).lower()))
e4ffb1
 
e4ffb1
+def reboot_diag(_, options):
e4ffb1
+	output = run_command(options, create_command(options, "diag"))
e4ffb1
+	return bool(re.search('chassis power control: diag', str(output).lower()))
e4ffb1
+
e4ffb1
 def create_command(options, action):
e4ffb1
 	cmd = options["--ipmitool-path"]
e4ffb1
 
e4ffb1
@@ -137,7 +141,7 @@
e4ffb1
 def main():
e4ffb1
 	atexit.register(atexit_handler)
e4ffb1
 
e4ffb1
-	device_opt = ["ipaddr", "ipport", "login", "no_login", "no_password", "passwd",
e4ffb1
+	device_opt = ["ipaddr", "login", "no_login", "no_password", "passwd", "diag", 
e4ffb1
 		"lanplus", "auth", "cipher", "privlvl", "sudo", "ipmitool_path", "method",
e4ffb1
 		"obsolete_ip", "timeout"]
e4ffb1
 	define_new_opts()
e4ffb1
@@ -179,7 +183,15 @@
e4ffb1
 	if not is_executable(options["--ipmitool-path"]):
e4ffb1
 		fail_usage("Ipmitool not found or not accessible")
e4ffb1
 
e4ffb1
-	result = fence_action(None, options, set_power_status, get_power_status, None, reboot_cycle)
e4ffb1
+	reboot_fn = reboot_cycle
e4ffb1
+	if options["--action"] == "diag":
e4ffb1
+		# Diag is a special action that can't be verified so we will reuse reboot functionality
e4ffb1
+		# to minimize impact on generic library
e4ffb1
+		options["--action"] = "reboot"
e4ffb1
+		options["--method"] = "cycle" 
e4ffb1
+		reboot_fn = reboot_diag
e4ffb1
+
e4ffb1
+	result = fence_action(None, options, set_power_status, get_power_status, None, reboot_fn)
e4ffb1
 	sys.exit(result)
e4ffb1
 
e4ffb1
 if __name__ == "__main__":
e4ffb1
diff -uNr a/fence/agents/lib/fence2man.xsl b/fence/agents/lib/fence2man.xsl
e4ffb1
--- a/fence/agents/lib/fence2man.xsl	2016-03-14 10:33:38.411438131 +0100
e4ffb1
+++ b/fence/agents/lib/fence2man.xsl	2016-03-14 10:41:41.377326413 +0100
e4ffb1
@@ -20,6 +20,7 @@
e4ffb1
 <xsl:when test="@name = 'enable'">Enable fabric access.</xsl:when>
e4ffb1
 <xsl:when test="@name = 'disable'">Disable fabric access.</xsl:when>
e4ffb1
 <xsl:when test="@name = 'reboot'">Reboot machine.</xsl:when>
e4ffb1
+<xsl:when test="@name = 'diag'">Pulse a diagnostic interrupt to the processor(s).</xsl:when> 
e4ffb1
 <xsl:when test="@name = 'monitor'">Check the health of fence device</xsl:when>
e4ffb1
 <xsl:when test="@name = 'metadata'">Display the XML metadata describing this resource.</xsl:when>
e4ffb1
 <xsl:when test="@name = 'list'">List available plugs with aliases/virtual machines if there is support for more then one device. Returns N/A otherwise.</xsl:when>
e4ffb1
diff -uNr a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
e4ffb1
--- a/fence/agents/lib/fencing.py.py	2016-03-14 10:33:38.418438048 +0100
e4ffb1
+++ b/fence/agents/lib/fencing.py.py	2016-03-14 10:41:44.366288571 +0100
e4ffb1
@@ -135,6 +135,10 @@
e4ffb1
 		"getopt" : "",
e4ffb1
 		"help" : "",
e4ffb1
 		"order" : 1},
e4ffb1
+	"diag" : {
e4ffb1
+		"getopt" : "",
e4ffb1
+		"help" : "",
e4ffb1
+		"order" : ""},
e4ffb1
 	"passwd" : {
e4ffb1
 		"getopt" : "p:",
e4ffb1
 		"longopt" : "password",
e4ffb1
@@ -590,6 +594,8 @@
e4ffb1
 	print "\t<action name=\"list-status\" />"
e4ffb1
 	print "\t<action name=\"monitor\" />"
e4ffb1
 	print "\t<action name=\"metadata\" />"
e4ffb1
+	if avail_opt.count("diag") == 1:
e4ffb1
+		print "\t<action name=\"diag\" />"
e4ffb1
 	print "</actions>"
e4ffb1
 	print "</resource-agent>"
e4ffb1
 
e4ffb1
@@ -781,6 +787,9 @@
e4ffb1
 	if 1 == device_opt.count("no_status"):
e4ffb1
 		acceptable_actions.remove("status")
e4ffb1
 
e4ffb1
+	if 1 == device_opt.count("diag"):
e4ffb1
+		acceptable_actions.extend(["diag"])
e4ffb1
+
e4ffb1
 	if 0 == acceptable_actions.count(options["--action"]):
e4ffb1
 		fail_usage("Failed: Unrecognised action '" + options["--action"] + "'")
e4ffb1
 
e4ffb1
diff -uNr a/tests/data/metadata/fence_idrac.xml b/tests/data/metadata/fence_idrac.xml
e4ffb1
--- a/tests/data/metadata/fence_idrac.xml	2016-03-14 10:33:38.416438072 +0100
e4ffb1
+++ b/tests/data/metadata/fence_idrac.xml	2016-03-14 10:41:41.379326388 +0100
e4ffb1
@@ -169,5 +169,6 @@
e4ffb1
 	<action name="list-status" />
e4ffb1
 	<action name="monitor" />
e4ffb1
 	<action name="metadata" />
e4ffb1
+	<action name="diag" />
e4ffb1
 </actions>
e4ffb1
 </resource-agent>
e4ffb1
diff -uNr a/tests/data/metadata/fence_ilo3.xml b/tests/data/metadata/fence_ilo3.xml
e4ffb1
--- a/tests/data/metadata/fence_ilo3.xml	2016-03-14 10:33:38.416438072 +0100
e4ffb1
+++ b/tests/data/metadata/fence_ilo3.xml	2016-03-14 10:41:41.379326388 +0100
e4ffb1
@@ -169,5 +169,6 @@
e4ffb1
 	<action name="list-status" />
e4ffb1
 	<action name="monitor" />
e4ffb1
 	<action name="metadata" />
e4ffb1
+	<action name="diag" />
e4ffb1
 </actions>
e4ffb1
 </resource-agent>
e4ffb1
diff -uNr a/tests/data/metadata/fence_ilo4.xml b/tests/data/metadata/fence_ilo4.xml
e4ffb1
--- a/tests/data/metadata/fence_ilo4.xml	2016-03-14 10:33:38.416438072 +0100
e4ffb1
+++ b/tests/data/metadata/fence_ilo4.xml	2016-03-14 10:41:41.380326375 +0100
e4ffb1
@@ -169,5 +169,6 @@
e4ffb1
 	<action name="list-status" />
e4ffb1
 	<action name="monitor" />
e4ffb1
 	<action name="metadata" />
e4ffb1
+	<action name="diag" />
e4ffb1
 </actions>
e4ffb1
 </resource-agent>
e4ffb1
diff -uNr a/tests/data/metadata/fence_imm.xml b/tests/data/metadata/fence_imm.xml
e4ffb1
--- a/tests/data/metadata/fence_imm.xml	2016-03-14 10:33:38.416438072 +0100
e4ffb1
+++ b/tests/data/metadata/fence_imm.xml	2016-03-14 10:41:41.380326375 +0100
e4ffb1
@@ -169,5 +169,6 @@
e4ffb1
 	<action name="list-status" />
e4ffb1
 	<action name="monitor" />
e4ffb1
 	<action name="metadata" />
e4ffb1
+	<action name="diag" />
e4ffb1
 </actions>
e4ffb1
 </resource-agent>
e4ffb1
diff -uNr a/tests/data/metadata/fence_ipmilan.xml b/tests/data/metadata/fence_ipmilan.xml
e4ffb1
--- a/tests/data/metadata/fence_ipmilan.xml	2016-03-14 10:33:38.416438072 +0100
e4ffb1
+++ b/tests/data/metadata/fence_ipmilan.xml	2016-03-14 10:41:41.381326363 +0100
e4ffb1
@@ -169,5 +169,6 @@
e4ffb1
 	<action name="list-status" />
e4ffb1
 	<action name="monitor" />
e4ffb1
 	<action name="metadata" />
e4ffb1
+	<action name="diag" />
e4ffb1
 </actions>
e4ffb1
 </resource-agent>