Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

targetcli 3.x support #1072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions heartbeat/iSCSILogicalUnit
Original file line number Diff line number Diff line change
Expand Up @@ -402,19 +402,25 @@ iSCSILogicalUnit_start() {
lio-t)
ocf_take_lock $TARGETLOCKFILE
ocf_release_lock_on_exit $TARGETLOCKFILE
iblock_attrib_path="/sys/kernel/config/target/core/iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE}/attrib"
# For lio, we first have to create a target device, then
# add it to the Target Portal Group as an LU.
ocf_run targetcli /backstores/block create name=${OCF_RESOURCE_INSTANCE} dev=${OCF_RESKEY_path} || exit $OCF_ERR_GENERIC
wwn=""
if [ -n "${OCF_RESKEY_scsi_sn}" ]; then
echo ${OCF_RESKEY_scsi_sn} > /sys/kernel/config/target/core/iblock_${OCF_RESKEY_lio_iblock}/${OCF_RESOURCE_INSTANCE}/wwn/vpd_unit_serial
wwn="wwn=${OCF_RESKEY_scsi_sn} "
fi
ocf_run targetcli /iscsi/${OCF_RESKEY_target_iqn}/tpg1/luns create /backstores/block/${OCF_RESOURCE_INSTANCE} ${OCF_RESKEY_lun} || exit $OCF_ERR_GENERIC
ocf_run targetcli /backstores/iblock create name=${OCF_RESOURCE_INSTANCE} dev=${OCF_RESKEY_path} ${wwn} || exit $OCF_ERR_GENERIC

if $(ip a | grep -q inet6); then
ocf_run -q targetcli /iscsi/${OCF_RESKEY_target_iqn}/tpg1/portals delete 0.0.0.0 3260
ocf_run -q targetcli /iscsi/${OCF_RESKEY_target_iqn}/tpg1/portals create ::0
if [ -n "${OCF_RESKEY_emulate_tpu}" ]; then
ocf_run targetcli /backstores/iblock/${OCF_RESOURCE_INSTANCE} set attribute emulate_tpu=1
fi
if [ -n "${OCF_RESKEY_emulate_3pc}" ]; then
ocf_run targetcli /backstores/iblock/${OCF_RESOURCE_INSTANCE} set attribute emulate_3pc=1
fi
if [ -n "${OCF_RESKEY_emulate_caw}" ]; then
ocf_run targetcli /backstores/iblock/${OCF_RESOURCE_INSTANCE} set attribute emulate_caw=1
fi

ocf_run targetcli /iscsi/${OCF_RESKEY_target_iqn}/tpg1/luns create /backstores/iblock/${OCF_RESOURCE_INSTANCE} ${OCF_RESKEY_lun} || exit $OCF_ERR_GENERIC

if [ -n "${OCF_RESKEY_allowed_initiators}" ]; then
for initiator in ${OCF_RESKEY_allowed_initiators}; do
Expand All @@ -423,15 +429,6 @@ iSCSILogicalUnit_start() {
done
fi

if [ -n "${OCF_RESKEY_emulate_tpu}" ]; then
echo ${OCF_RESKEY_emulate_tpu} > ${iblock_attrib_path}/emulate_tpu || exit $OCF_ERR_GENERIC
fi
if [ -n "${OCF_RESKEY_emulate_3pc}" ]; then
echo ${OCF_RESKEY_emulate_3pc} > ${iblock_attrib_path}/emulate_3pc || exit $OCF_ERR_GENERIC
fi
if [ -n "${OCF_RESKEY_emulate_caw}" ]; then
echo ${OCF_RESKEY_emulate_caw} > ${iblock_attrib_path}/emulate_caw || exit $OCF_ERR_GENERIC
fi
;;
esac

Expand Down Expand Up @@ -504,7 +501,7 @@ iSCSILogicalUnit_stop() {
# delete the backstore, then something is seriously
# wrong and we need to fail the stop operation
# (potentially causing fencing)
ocf_run targetcli /backstores/block delete ${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
ocf_run targetcli /backstores/iblock delete ${OCF_RESOURCE_INSTANCE} || exit $OCF_ERR_GENERIC
;;
esac

Expand Down
6 changes: 6 additions & 0 deletions heartbeat/iSCSITarget
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ iSCSITarget_start() {
ocf_run targetcli /iscsi/${OCF_RESKEY_iqn}/tpg1/portals create "${sep_portal[0]}" "${sep_portal[1]}" || exit $OCF_ERR_GENERIC
else
ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
if [ ${OCF_RESKEY_portals_default} = "0.0.0.0:3260" ]; then
if $(ip a | grep -q inet6); then
ocf_run -q targetcli /iscsi/${OCF_RESKEY_iqn}/tpg1/portals delete 0.0.0.0 3260
ocf_run -q targetcli /iscsi/${OCF_RESKEY_iqn}/tpg1/portals create ::0 3260
fi
fi
fi
done
# in lio, we can set target parameters by manipulating
Expand Down