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

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