fence-agents/SOURCES/bz1750596-fence_scsi-add-readonly-parameter.patch

80 lines
3.1 KiB
Diff
Raw Normal View History

2021-05-14 04:12:18 +00:00
From f1f8fe7791d0bf439f7caf1365c371153f9819ff Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 14 May 2020 15:41:52 +0200
Subject: [PATCH] fence_scsi: add readonly parameter
---
agents/scsi/fence_scsi.py | 21 ++++++++++++++++++---
tests/data/metadata/fence_scsi.xml | 5 +++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py
index 9b6af556..77817f35 100644
--- a/agents/scsi/fence_scsi.py
+++ b/agents/scsi/fence_scsi.py
@@ -150,7 +150,10 @@ def reserve_dev(options, dev):
def get_reservation_key(options, dev):
reset_dev(options,dev)
- cmd = options["--sg_persist-path"] + " -n -i -r -d " + dev
+ opts = ""
+ if "--readonly" in options:
+ opts = "-y "
+ cmd = options["--sg_persist-path"] + " -n -i " + opts + "-r -d " + dev
out = run_cmd(options, cmd)
if out["err"]:
fail_usage("Cannot get reservation key")
@@ -161,7 +164,10 @@ def get_reservation_key(options, dev):
def get_registration_keys(options, dev, fail=True):
reset_dev(options,dev)
keys = []
- cmd = options["--sg_persist-path"] + " -n -i -k -d " + dev
+ opts = ""
+ if "--readonly" in options:
+ opts = "-y "
+ cmd = options["--sg_persist-path"] + " -n -i " + opts + "-k -d " + dev
out = run_cmd(options, cmd)
if out["err"]:
fail_usage("Cannot get registration keys", fail)
@@ -342,6 +348,14 @@ def define_new_opts():
"shortdesc" : "Use the APTPL flag for registrations. This option is only used for the 'on' action.",
"order": 1
}
+ all_opt["readonly"] = {
+ "getopt" : "",
+ "longopt" : "readonly",
+ "help" : "--readonly Open DEVICE read-only. May be useful with PRIN commands if there are unwanted side effects with the default read-write open.",
+ "required" : "0",
+ "shortdesc" : "Open DEVICE read-only.",
+ "order": 4
+ }
all_opt["logfile"] = {
"getopt" : ":",
"longopt" : "logfile",
@@ -464,7 +478,8 @@ def main():
device_opt = ["no_login", "no_password", "devices", "nodename", "port",\
"no_port", "key", "aptpl", "fabric_fencing", "on_target", "corosync_cmap_path",\
- "sg_persist_path", "sg_turs_path", "logfile", "vgs_path", "force_on", "key_value"]
+ "sg_persist_path", "sg_turs_path", "readonly", "logfile", "vgs_path",\
+ "force_on", "key_value"]
define_new_opts()
diff --git a/tests/data/metadata/fence_scsi.xml b/tests/data/metadata/fence_scsi.xml
index b840f3cf..d0818b0d 100644
--- a/tests/data/metadata/fence_scsi.xml
+++ b/tests/data/metadata/fence_scsi.xml
@@ -36,6 +36,11 @@ When used as a watchdog device you can define e.g. retry=1, retry-sleep=2 and ve
<content type="string" />
<shortdesc lang="en">Name of the node to be fenced. The node name is used to generate the key value used for the current operation. This option will be ignored when used with the -k option.</shortdesc>
</parameter>
+ <parameter name="readonly" unique="0" required="0">
+ <getopt mixed="--readonly" />
+ <content type="boolean" />
+ <shortdesc lang="en">Open DEVICE read-only.</shortdesc>
+ </parameter>
<parameter name="logfile" unique="0" required="0">
<getopt mixed="-f, --logfile" />
<content type="string" />