Blob Blame History Raw
From 0a34f115c378ed1791f2aceb5abdb0633c394d6f Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Tue, 9 Feb 2016 09:49:01 +0100
Subject: [PATCH 2/4] fence_cisco_ucs: Add --missing-as-off

---
 fence/agents/cisco_ucs/fence_cisco_ucs.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index 260925e..08da566 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -32,10 +32,16 @@ def get_power_status(conn, options):
 
 	result = RE_GET_PNDN.search(res)
 	if result == None:
-		fail(EC_STATUS)
+		pndn = ""
 	else:
 		pndn = result.group(1)
 
+	if pndn.strip() == "":
+		if "--missing-as-off" in options:
+			return "off"
+		else:
+			fail(EC_STATUS)
+
 	res = send_command(options, "<configResolveDn cookie=\"" + options["cookie"] +
 			"\" inHierarchical=\"false\" dn=\"" + pndn +
 			"\"/>", int(options["--shell-timeout"]))
@@ -139,7 +145,7 @@ def logout():
 
 def main():
 	global options_global
-	device_opt = ["ipaddr", "login", "passwd", "ssl", "notls", "port", "web", "suborg"]
+	device_opt = ["ipaddr", "login", "passwd", "ssl", "notls", "port", "web", "suborg", "missing_as_off"]
 
 	atexit.register(atexit_handler)
 	atexit.register(logout)
-- 
2.4.3