fence-agents/RHEL-5397-3-fence_scsi-fix-run_cmd.patch

85 lines
3.1 KiB
Diff
Raw Normal View History

--- a/agents/scsi/fence_scsi.py 2024-01-03 14:06:10.155417318 +0100
+++ b/agents/scsi/fence_scsi.py 2024-01-03 14:07:40.737369588 +0100
@@ -84,14 +84,14 @@
# check if host is ready to execute actions
def do_action_monitor(options):
# Check if required binaries are installed
- if bool(run_cmd(options, options["--sg_persist-path"] + " -V")["err"]):
+ if bool(run_cmd(options, options["--sg_persist-path"] + " -V")["rc"]):
logging.error("Unable to run " + options["--sg_persist-path"])
return 1
- elif bool(run_cmd(options, options["--sg_turs-path"] + " -V")["err"]):
+ elif bool(run_cmd(options, options["--sg_turs-path"] + " -V")["rc"]):
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"])):
+ bool(run_cmd(options, options["--vgs-path"] + " --version")["rc"])):
logging.error("Unable to run " + options["--vgs-path"])
return 1
@@ -102,11 +102,13 @@
return 0
-#run command, returns dict, ret["err"] = exit code; ret["out"] = output
+# run command, returns dict, ret["rc"] = exit code; ret["out"] = output;
+# ret["err"] = error
def run_cmd(options, cmd):
ret = {}
- (ret["err"], ret["out"], _) = run_command(options, cmd)
+ (ret["rc"], ret["out"], ret["err"]) = run_command(options, cmd)
ret["out"] = "".join([i for i in ret["out"] if i is not None])
+ ret["err"] = "".join([i for i in ret["err"] if i is not None])
return ret
@@ -122,11 +124,11 @@
def preempt_abort(options, host, dev):
reset_dev(options,dev)
cmd = options["--sg_persist-path"] + " -n -o -A -T 5 -K " + host + " -S " + options["--key"] + " -d " + dev
- return not bool(run_cmd(options, cmd)["err"])
+ return not bool(run_cmd(options, cmd)["rc"])
def reset_dev(options, dev):
- return run_cmd(options, options["--sg_turs-path"] + " " + dev)["err"]
+ return run_cmd(options, options["--sg_turs-path"] + " " + dev)["rc"]
def register_dev(options, dev, key):
@@ -171,13 +173,13 @@
reset_dev(options, dev)
cmd = options["--sg_persist-path"] + " -n -o -I -S " + key + " -d " + dev
cmd += " -Z" if "--aptpl" in options else ""
- return not bool(run_cmd(options, cmd)["err"])
+ return not bool(run_cmd(options, cmd)["rc"])
def reserve_dev(options, dev):
reset_dev(options,dev)
cmd = options["--sg_persist-path"] + " -n -o -R -T 5 -K " + options["--key"] + " -d " + dev
- return not bool(run_cmd(options, cmd)["err"])
+ return not bool(run_cmd(options, cmd)["rc"])
def get_reservation_key(options, dev, fail=True):
@@ -201,7 +203,7 @@
opts = "-y "
cmd = options["--sg_persist-path"] + " -n -i " + opts + "-k -d " + dev
out = run_cmd(options, cmd)
- if out["err"]:
+ if out["rc"]:
fail_usage("Cannot get registration keys", fail)
if not fail:
return []
@@ -319,7 +321,7 @@
"--options vg_attr,pv_name "+\
"--config 'global { locking_type = 0 } devices { preferred_names = [ \"^/dev/dm\" ] }'"
out = run_cmd(options, cmd)
- if out["err"]:
+ if out["rc"]:
fail_usage("Failed: Cannot get shared devices")
for line in out["out"].splitlines():
vg_attr, pv_name = line.strip().split(":")