Blame SOURCES/bz1750596-fence_scsi-add-readonly-parameter.patch

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