diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2011-04-18 15:26:10 +0200 |
---|---|---|
committer | root <root@target.spline.inf.fu-berlin.de> | 2011-04-18 15:26:10 +0200 |
commit | 1a6a9a86f6a037343800380e9e619047383b1d2a (patch) | |
tree | 38ff994e54e13302192e02f3ec1e37fd97f1429c | |
download | iscsi-helper-1a6a9a86f6a037343800380e9e619047383b1d2a.tar.gz iscsi-helper-1a6a9a86f6a037343800380e9e619047383b1d2a.tar.bz2 iscsi-helper-1a6a9a86f6a037343800380e9e619047383b1d2a.zip |
addIscsiDisk: added script
the addIscsiDisk script adds the required config for a new iscsi
disk and tries to live upgrade the iete daemon to exporting the disk
-rwxr-xr-x | addIscsiDisk | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/addIscsiDisk b/addIscsiDisk new file mode 100755 index 0000000..1bda195 --- /dev/null +++ b/addIscsiDisk @@ -0,0 +1,43 @@ +#!/bin/bash + +lvname=$(basename $1) +if [ -z "${lvname}" -o ! -b "/dev/scsiRaid/${lvname}" ]; then + echo "Usage: $0 <lvname>" + exit 1 +fi + +# check if disk exists in config +if grep -qs "Path=/dev/scsiRaid/${lvname},Type=diskio" /etc/iet/ietd.conf ; then + echo "Disk is already in config file. Not adding it again." >&2 +else + echo -n "Adding disk to 'ietd.conf' config file... " >&2 + cat <<EOF >> /etc/iet/ietd.conf + +Target iqn.2011-04.de.spline:${lvname} + Lun 0 Path=/dev/scsiRaid/${lvname},Type=diskio,ScsiId=1,ScsiSN=2 +EOF + echo "Done." >&2 +fi + +if [ -r /proc/net/iet/volume ]; then + if grep -qs "path:/dev/scsiRaid/${lvname}$" /proc/net/iet/volume ; then + echo "Disk is already configured in ietd. Skipping live update." >&2 + else + # get the next avilable tid + tid=$(awk '$1 ~ /tid:/ { \ + gsub(/tid:/,"",$1); \ + if ( max < $1 ) { \ + max=$1 \ + } \ + } \ + \ + END { print max+1 }' /proc/net/iet/volume) + + echo -n "Adding disk to running ietd... " >&2 + ietadm --op new --tid=${tid} --params "Name=iqn.2011-04.de.spline:${lvname}" + ietadm --op new --tid=${tid} --lun=0 --params "Path=/dev/scsiRaid/${lvname},Type=diskio,ScsiId=1,ScsiSN=2" + echo "Done." >&2 + fi +else + echo "ietd not running. Skipping live update." >&2 +fi |