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