Blob Blame History Raw
From 9f9a6829ead6199ecb65c4f85f400a0e403c8c47 Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Mon, 15 Aug 2016 10:48:47 +0200
Subject: [PATCH] fence_cisco_ucs: Improve a method to obtain status

On Cisco UCS there are two attributes which are important for obtaining
correct power status of blade. One checks if slot is powered ON and other if
the node is pulled off the blade.
---
 fence/agents/cisco_ucs/fence_cisco_ucs.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index 648e45f..0d9609d 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -19,6 +19,7 @@ RE_STATUS = re.compile("<lsPower .*? state=\"(.*?)\"", re.IGNORECASE)
 RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
 RE_GET_PNDN = re.compile(" pndn=\"(.*?)\"", re.IGNORECASE)
 RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
+RE_GET_OPERPOWER = re.compile(" operPower=\"(.*?)\"", re.IGNORECASE)
 RE_GET_PRESENCE = re.compile(" presence=\"(.*?)\"", re.IGNORECASE)
 
 options_global = None
@@ -50,12 +51,21 @@ def get_power_status(conn, options):
 	if result == None:
 		fail(EC_STATUS)
 	else:
-		status = result.group(1)
+		presence_status = result.group(1)
 
-	if status in ["missing", "mismatch"]:
+	if presence_status in ["missing", "mismatch"]:
 		return "off"
 	else:
-		return "on"
+		result = RE_GET_OPERPOWER.search(res)
+		if result == None:
+			fail(EC_STATUS)
+		else:
+			power_status = result.group(1)
+
+		if power_status == "on":
+			return "on"
+		else:
+			return "off"
 
 def set_power_status(conn, options):
 	del conn
-- 
2.4.11