Blame SOURCES/bz1243485-3-fence_scsi_check.patch

97f65f
From 5bc23bc764326a8ea2a5ffffbe1e9bea9a32b868 Mon Sep 17 00:00:00 2001
97f65f
From: Marek 'marx' Grac <mgrac@redhat.com>
97f65f
Date: Mon, 17 Aug 2015 10:46:25 +0200
97f65f
Subject: [PATCH] fence_scsi: Watchdog script should pass on a system that is
97f65f
 not configured
97f65f
97f65f
---
97f65f
 fence/agents/scsi/fence_scsi.py | 18 ++++++++++++------
97f65f
 1 file changed, 12 insertions(+), 6 deletions(-)
97f65f
97f65f
diff --git a/fence/agents/scsi/fence_scsi.py b/fence/agents/scsi/fence_scsi.py
97f65f
index 7e7bc0d..e18e473 100644
97f65f
--- a/fence/agents/scsi/fence_scsi.py
97f65f
+++ b/fence/agents/scsi/fence_scsi.py
97f65f
@@ -205,12 +205,15 @@ def set_key(options):
97f65f
 
97f65f
 
97f65f
 # read node key from file
97f65f
-def get_key():
97f65f
+def get_key(fail=True):
97f65f
 	file_path = STORE_PATH + ".key"
97f65f
 	try:
97f65f
 		f = open(file_path, "r")
97f65f
 	except IOError:
97f65f
-		fail_usage("Failed: Cannot open file \""+ file_path + "\"")
97f65f
+		if fail:
97f65f
+			fail_usage("Failed: Cannot open file \""+ file_path + "\"")
97f65f
+		else:
97f65f
+			return None
97f65f
 	return f.readline().strip().lower()
97f65f
 
97f65f
 
97f65f
@@ -228,12 +231,15 @@ def dev_write(dev, options):
97f65f
 	f.close()
97f65f
 
97f65f
 
97f65f
-def dev_read():
97f65f
+def dev_read(fail=True):
97f65f
 	file_path = STORE_PATH + ".dev"
97f65f
 	try:
97f65f
 		f = open(file_path, "r")
97f65f
 	except IOError:
97f65f
-		fail_usage("Failed: Cannot open file \"" + file_path + "\"")
97f65f
+		if fail:
97f65f
+			fail_usage("Failed: Cannot open file \"" + file_path + "\"")
97f65f
+		else:
97f65f
+			return None
97f65f
 	# get not empty lines from file
97f65f
 	devs = [line.strip() for line in f if line.strip()]
97f65f
 	f.close()
97f65f
@@ -378,11 +384,11 @@ def scsi_check():
97f65f
 	options["--power-timeout"] = "5"
97f65f
 	if scsi_check_get_verbose():
97f65f
 		logging.getLogger().setLevel(logging.DEBUG)
97f65f
-	devs = dev_read()
97f65f
+	devs = dev_read(fail=False)
97f65f
 	if not devs:
97f65f
 		logging.error("No devices found")
97f65f
 		return 0
97f65f
-	key = get_key()
97f65f
+	key = get_key(fail=False)
97f65f
 	if not key:
97f65f
 		logging.error("Key not found")
97f65f
 		return 0
97f65f
-- 
97f65f
1.9.3
97f65f