Blame SOURCES/bz1298430-fence_cisco_ucs-status.patch

d5f3d8
From 8f106de6bed0626787cae79aa2607992f1bbacec Mon Sep 17 00:00:00 2001
d5f3d8
From: Marek 'marx' Grac <mgrac@redhat.com>
d5f3d8
Date: Mon, 1 Feb 2016 16:07:48 +0100
d5f3d8
Subject: [PATCH] fence_cisco_ucs: Obtain status of device from different
d5f3d8
 endpoint
d5f3d8
d5f3d8
Resolves: rhbz#1298430
d5f3d8
---
d5f3d8
 fence/agents/cisco_ucs/fence_cisco_ucs.py | 18 +++++++++++++++---
d5f3d8
 1 file changed, 15 insertions(+), 3 deletions(-)
d5f3d8
d5f3d8
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
d5f3d8
index 6288207..331f309 100644
d5f3d8
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
d5f3d8
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
d5f3d8
@@ -17,7 +17,9 @@ BUILD_DATE="March, 2008"
d5f3d8
 RE_COOKIE = re.compile("
d5f3d8
 RE_STATUS = re.compile("
d5f3d8
 RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
d5f3d8
+RE_GET_PNDN = re.compile(" pndn=\"(.*?)\"", re.IGNORECASE)
d5f3d8
 RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
d5f3d8
+RE_GET_OPERPOWER = re.compile(" operPower=\"(.*?)\"", re.IGNORECASE)
d5f3d8
 
d5f3d8
 options_global = None
d5f3d8
 
d5f3d8
@@ -26,15 +28,25 @@ def get_power_status(conn, options):
d5f3d8
 
d5f3d8
 	res = send_command(options, "
d5f3d8
 			"\" inHierarchical=\"false\" dn=\"org-root" + options["--suborg"] + "/ls-" +
d5f3d8
-			options["--plug"] + "/power\"/>", int(options["--shell-timeout"]))
d5f3d8
+			options["--plug"] + "\"/>", int(options["--shell-timeout"]))
d5f3d8
 
d5f3d8
-	result = RE_STATUS.search(res)
d5f3d8
+	result = RE_GET_PNDN.search(res)
d5f3d8
+	if result == None:
d5f3d8
+		fail(EC_STATUS)
d5f3d8
+	else:
d5f3d8
+		pndn = result.group(1)
d5f3d8
+
d5f3d8
+	res = send_command(options, "
d5f3d8
+			"\" inHierarchical=\"false\" dn=\"" + pndn +
d5f3d8
+			"\"/>", int(options["--shell-timeout"]))
d5f3d8
+
d5f3d8
+	result = RE_GET_OPERPOWER.search(res)
d5f3d8
 	if result == None:
d5f3d8
 		fail(EC_STATUS)
d5f3d8
 	else:
d5f3d8
 		status = result.group(1)
d5f3d8
 
d5f3d8
-	if status == "up":
d5f3d8
+	if status == "on":
d5f3d8
 		return "on"
d5f3d8
 	else:
d5f3d8
 		return "off"
d5f3d8
-- 
d5f3d8
2.4.3
d5f3d8