; html-script: false ] #!/bin/bash
KEY_FILE="/root/.ssh/netapp.dsa"
SSH_OPTS="/root/.ssh/netapp-ssh_config"
if [ $# -ne 2 ] ; then
echo "fas-remove-lunmap: FAS_CONTROLLER TARGET_IGROUP"
echo
echo "Remove every mapped lun from the target igroup (for example reinstallation)"
echo
echo " Usage:"
echo " - FAS_CONTROLLER: Hostname/IP-adress of the DATA ONTAP controller"
echo " - TARGET_IGROUP: igroup that is actually modified"
echo
exit 1
fi
FAS_CTRL=$1
TARGET=$2
ssh_fas() {
# $@: commands for Data ONTAP
COMMANDS="$@"
/usr/bin/ssh -i $KEY_FILE -l root -F $SSH_OPTS $COMMANDS
}
# Get the hostname of the controller, necessary for the reporting
CTRL_HOSTNAME="$( ssh_fas $FAS_CTRL rdfile /etc/rc | grep ^hostname | cut -d -f2 | tr 'a-z' 'A-Z' )"
#set -x
# Get the lun list.
for lun in $( ssh_fas $FAS_CTRL lun show -g $SOURCE | awk '{ print $1 }' | sort -u ); do
# If the LUN id is 0, skip otherwise we would remove the boot LUN
if [ "$LUN_ID" != "0" ] ; then
# Actually remove the mapping to our host
echo "Removing $lun from $TARGET"
ssh_fas $FAS_CTRL lun unmap $lun $TARGET
fi
done
#set +x