Blame SOURCES/bz1213571-fence_scsi-add_monitor.patch

97f65f
From d452969b172da23604d58e14a7b60d19f87967df Mon Sep 17 00:00:00 2001
97f65f
From: Marek 'marx' Grac <mgrac@redhat.com>
97f65f
Date: Wed, 17 Jun 2015 19:34:53 +0200
97f65f
Subject: [PATCH 02/10] fence_scsi: Add support for monitor action
97f65f
97f65f
Resolves: rhbz#1196068
97f65f
---
97f65f
 fence/agents/scsi/fence_scsi.py | 18 ++++++++++++++++++
97f65f
 1 file changed, 18 insertions(+)
97f65f
97f65f
diff --git a/fence/agents/scsi/fence_scsi.py b/fence/agents/scsi/fence_scsi.py
97f65f
index 3a899d1..de301a5 100644
97f65f
--- a/fence/agents/scsi/fence_scsi.py
97f65f
+++ b/fence/agents/scsi/fence_scsi.py
97f65f
@@ -83,6 +83,21 @@ def set_status(conn, options):
97f65f
 		sys.exit(1)
97f65f
 
97f65f
 
97f65f
+# check if host is ready to execute actions
97f65f
+def do_action_monitor(options):
97f65f
+	if bool(run_cmd(options, options["--sg_persist-path"] + " -V")["err"]):
97f65f
+		logging.error("Unable to run " + options["--sg_persist-path"])
97f65f
+		return 1
97f65f
+	elif bool(run_cmd(options, options["--sg_turs-path"] + " -V")["err"]):
97f65f
+		logging.error("Unable to run " + options["--sg_turs-path"])
97f65f
+		return 1
97f65f
+	elif ("--devices" not in options and 
97f65f
+			bool(run_cmd(options,	options["--vgs-path"] + " --version")["err"])):
97f65f
+		logging.error("Unable to run " + options["--vgs-path"])
97f65f
+		return 1
97f65f
+	return 0
97f65f
+
97f65f
+
97f65f
 #run command, returns dict, ret["err"] = exit code; ret["out"] = output
97f65f
 def run_cmd(options, cmd):
97f65f
 	ret = {}
97f65f
@@ -423,6 +438,9 @@ longer be able to write to the device(s). A manual reboot is required."
97f65f
 	options["store_path"] = STORE_PATH
97f65f
 
97f65f
 	# Input control BEGIN
97f65f
+	if options["--action"] == "monitor":
97f65f
+		sys.exit(do_action_monitor(options))
97f65f
+
97f65f
 	if not (("--nodename" in options and options["--nodename"])\
97f65f
 	or ("--key" in options and options["--key"])):
97f65f
 		fail_usage("Failed: nodename or key is required")
97f65f
-- 
97f65f
1.9.3
97f65f