Blame SOURCES/bz1692413-1-iSCSITarget-create-iqn-when-it-doesnt-exist.patch

914f09
From 9273b83edf6ee72a59511f307e168813ca3d31fd Mon Sep 17 00:00:00 2001
914f09
From: colttt <shadow_7@gmx.net>
914f09
Date: Fri, 12 Oct 2018 15:29:48 +0200
914f09
Subject: [PATCH] possible fix for #1026
914f09
914f09
add an if-condition and remove an useless 'targetcli create'
914f09
---
914f09
 heartbeat/iSCSITarget.in | 6 +++---
914f09
 1 file changed, 3 insertions(+), 3 deletions(-)
914f09
914f09
diff --git a/heartbeat/iSCSITarget.in b/heartbeat/iSCSITarget.in
914f09
index e49a79016..9128fdc55 100644
914f09
--- a/heartbeat/iSCSITarget.in
914f09
+++ b/heartbeat/iSCSITarget.in
914f09
@@ -340,13 +340,13 @@ iSCSITarget_start() {
914f09
 		ocf_take_lock $TARGETLOCKFILE
914f09
 		ocf_release_lock_on_exit $TARGETLOCKFILE
914f09
 		ocf_run targetcli /iscsi set global auto_add_default_portal=false || exit $OCF_ERR_GENERIC
914f09
-		ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
914f09
+		if ! [ -d /sys/kernel/config/target/iscsi/${OCF_RESKEY_iqn} ] ; then
914f09
+			ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
914f09
+		fi
914f09
 		for portal in ${OCF_RESKEY_portals}; do
914f09
 			if [ $portal != ${OCF_RESKEY_portals_default} ] ; then
914f09
 				IFS=':' read -a sep_portal <<< "$portal"
914f09
 				ocf_run targetcli /iscsi/${OCF_RESKEY_iqn}/tpg1/portals create "${sep_portal[0]}" "${sep_portal[1]}" || exit $OCF_ERR_GENERIC
914f09
-			else
914f09
-				ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
914f09
 			fi
914f09
 		done
914f09
 		# in lio, we can set target parameters by manipulating