Well, today I had another idea (basically like the one I wrote for SVC’s VDisk mappings a while back) for a script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| #!/bin/bash
KEY_FILE="/root/.ssh/netapp.dsa"
SSH_OPTS="/root/.ssh/netapp-ssh_config"
if [ $# -ne 3 ] ; then
echo "fas-copy-lunmap: FAS_CONTROLLER SOURCE_IGROUP TARGET_IGROUP"
echo
echo "Copy the LUN map from one igroup to another, ie for ESX reinstallation"
echo
echo " Usage:"
echo " - FAS_CONTROLLER: Hostname/IP-adress of the DATA ONTAP controller"
echo " - SOURCE_IGROUP: igroup that is used as a reference for the copy process"
echo " - TARGET_IGROUP: igroup that is actually modified"
echo
exit 1
fi
FAS_CTRL=$1
SOURCE=$2
TARGET=$3
ssh_fas() {
# $@: commands for Data ONTAP
COMMANDS="$@"
/usr/bin/ssh -i $KEY_FILE -l root -F $SSH_OPTS $COMMANDS
}
#set -x
# Get the lun list.
for lun in $( ssh_fas $FAS_CTRL lun show -g $SOURCE | awk '{ print $1 }' | sort -u ); do
# Get the LUN number its mapped
LUN_ID="$( ssh_fas $FAS_CTRL lun show -m $lun | grep "^/vol" | awk '{ print $3 }' )"
# If the LUN id is 0, skip otherwise we would copy the boot LUN
if [ "$LUN_ID" != "0" ] ; then
# Actually map the lun to our host
echo "Mapping $lun to $TARGET as LUN_ID $LUN_ID"
ssh_fas $FAS_CTRL lun map $lun $TARGET $LUN_ID
fi
done
#set +x
|
I’ll post the counterpart of the script (to remove the LUNs) in a second post later on.