Blame SOURCES/bz1376588-iSCSITarget-properly-create-portals-for-lio-t.patch

15862b
From b10e2de76ccb143fdfd69988c8105ad4336d57d2 Mon Sep 17 00:00:00 2001
15862b
From: Patrick Emer <pemer@afdata.de>
15862b
Date: Sat, 27 Jun 2015 15:29:12 +0200
15862b
Subject: [PATCH] iSCSITarget: properly create portals for lio-t implementation
15862b
15862b
Even when defining the "portals" parameter, targetcli creates a
15862b
default portal at 0.0.0.0:3260 if the auto_add_default_portal option
15862b
is set to true (default), causing the resource to fail with
15862b
OCF_ERR_GENERIC.
15862b
15862b
Suppress creation of the default portal by setting
15862b
auto_add_default_portal=false if the "portals" parameter is set,
15862b
and retain the original behavior if it is not.
15862b
15862b
Fixes ClusterLabs/resource-agents#630.
15862b
---
15862b
 heartbeat/iSCSITarget | 5 ++++-
15862b
 1 file changed, 4 insertions(+), 1 deletion(-)
15862b
15862b
diff --git a/heartbeat/iSCSITarget b/heartbeat/iSCSITarget
15862b
index 72ec64a..401e98c 100755
15862b
--- a/heartbeat/iSCSITarget
15862b
+++ b/heartbeat/iSCSITarget
15862b
@@ -326,10 +326,13 @@ iSCSITarget_start() {
15862b
 		# automatically creates the corresponding target if it
15862b
 		# doesn't already exist.
15862b
 		for portal in ${OCF_RESKEY_portals}; do
15862b
-			ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
15862b
 			if [ $portal != ${OCF_RESKEY_portals_default} ] ; then
15862b
+				ocf_run targetcli /iscsi set global auto_add_default_portal=false || exit $OCF_ERR_GENERIC
15862b
+				ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
15862b
 				IFS=':' read -a sep_portal <<< "$portal"
15862b
 				ocf_run targetcli /iscsi/${OCF_RESKEY_iqn}/tpg1/portals create "${sep_portal[0]}" "${sep_portal[1]}" || exit $OCF_ERR_GENERIC
15862b
+			else
15862b
+				ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
15862b
 			fi
15862b
 		done
15862b
 		# in lio, we can set target parameters by manipulating