File 0002-fencing-Monitor-is-not-working-correctly-without-lis.patch of Package fence-agents

From 5a1fd08c7cf4a4c7d41db3db0a83eed226804b40 Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Tue, 1 Jul 2014 15:27:27 +0200
Subject: [PATCH 02/11] fencing: Monitor is not working correctly without
 'list' or 'status'

Action monitor either executes 'status' (without --plug) or 'list' (with --plug). But
it is not required to have 'list' action. If they do not then 'monitor' has to be done
in different way, e.g. login/logout.
---
 fence/agents/ovh/fence_ovh.py         | 13 ++++++++++---
 fence/agents/raritan/fence_raritan.py |  5 ++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index f9a1c39..14a0706 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -94,10 +94,10 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 	docs["vendorurl"] = "http://www.ovh.net"
 	show_docs(options, docs)
 
-	if options["--action"] in ["list", "status"]:
-		fail_usage("Action '" + options["--action"] + "' is not supported in this fence agent")
+	if options["--action"] == "list":
+		fail_usage("Action 'list' is not supported in this fence agent")
 
-	if not options["--plug"].endswith(".ovh.net"):
+	if options["--action"] != "monitor" and not options["--plug"].endswith(".ovh.net"):
 		options["--plug"] += ".ovh.net"
 
 	if not options.has_key("--email"):
@@ -107,6 +107,13 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 
 	conn = soap_login(options)
 
+	if options["--action"] == 'monitor':
+		try:
+			conn.service.logout(options["session"])
+		except Exception:
+			pass
+		sys.exit(0)
+
 	# Save datetime just before changing netboot
 	before_netboot_reboot = datetime.now()
 
diff --git a/fence/agents/raritan/fence_raritan.py b/fence/agents/raritan/fence_raritan.py
index 3506e25..bb6ad52 100644
--- a/fence/agents/raritan/fence_raritan.py
+++ b/fence/agents/raritan/fence_raritan.py
@@ -79,7 +79,10 @@ block any necessary fencing actions."
 	except pexpect.TIMEOUT:
 		fail(EC_LOGIN_DENIED)
 
-	result = fence_action(conn, options, set_power_status, get_power_status)
+	result = 0
+	if options["--action"] != "monitor":
+		result = fence_action(conn, options, set_power_status, get_power_status)
+
 	fence_logout(conn, "exit\n")
 	sys.exit(result)
 
-- 
1.8.4.5

openSUSE Build Service is sponsored by