Blame SOURCES/bz1298430-2-fence_cisco_ucs-status.patch

e4ffb1
From 9f9a6829ead6199ecb65c4f85f400a0e403c8c47 Mon Sep 17 00:00:00 2001
e4ffb1
From: Marek 'marx' Grac <mgrac@redhat.com>
e4ffb1
Date: Mon, 15 Aug 2016 10:48:47 +0200
e4ffb1
Subject: [PATCH] fence_cisco_ucs: Improve a method to obtain status
e4ffb1
e4ffb1
On Cisco UCS there are two attributes which are important for obtaining
e4ffb1
correct power status of blade. One checks if slot is powered ON and other if
e4ffb1
the node is pulled off the blade.
e4ffb1
---
e4ffb1
 fence/agents/cisco_ucs/fence_cisco_ucs.py | 16 +++++++++++++---
e4ffb1
 1 file changed, 13 insertions(+), 3 deletions(-)
e4ffb1
e4ffb1
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
e4ffb1
index 648e45f..0d9609d 100644
e4ffb1
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
e4ffb1
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
e4ffb1
@@ -19,6 +19,7 @@ RE_STATUS = re.compile("
e4ffb1
 RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
e4ffb1
 RE_GET_PNDN = re.compile(" pndn=\"(.*?)\"", re.IGNORECASE)
e4ffb1
 RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
e4ffb1
+RE_GET_OPERPOWER = re.compile(" operPower=\"(.*?)\"", re.IGNORECASE)
e4ffb1
 RE_GET_PRESENCE = re.compile(" presence=\"(.*?)\"", re.IGNORECASE)
e4ffb1
 
e4ffb1
 options_global = None
e4ffb1
@@ -50,12 +51,21 @@ def get_power_status(conn, options):
e4ffb1
 	if result == None:
e4ffb1
 		fail(EC_STATUS)
e4ffb1
 	else:
e4ffb1
-		status = result.group(1)
e4ffb1
+		presence_status = result.group(1)
e4ffb1
 
e4ffb1
-	if status in ["missing", "mismatch"]:
e4ffb1
+	if presence_status in ["missing", "mismatch"]:
e4ffb1
 		return "off"
e4ffb1
 	else:
e4ffb1
-		return "on"
e4ffb1
+		result = RE_GET_OPERPOWER.search(res)
e4ffb1
+		if result == None:
e4ffb1
+			fail(EC_STATUS)
e4ffb1
+		else:
e4ffb1
+			power_status = result.group(1)
e4ffb1
+
e4ffb1
+		if power_status == "on":
e4ffb1
+			return "on"
e4ffb1
+		else:
e4ffb1
+			return "off"
e4ffb1
 
e4ffb1
 def set_power_status(conn, options):
e4ffb1
 	del conn
e4ffb1
-- 
e4ffb1
2.4.11
e4ffb1