在 ds4kscript.sh 运行的目录下,一系列文件将会被创建出来:crtlun.cmd, crthost.cmd, maplun.cmd, delmap.cmd, delhost.cmd, dellun.cmd, setup.cmd, destroy.cmd。下面逐一对这些文件的功能进行描述:
创建 Lun、host group、host、host port,映射 Lun。它包括了 crtlun.cmd, crthost.cmd, maplun.cmd 的所有功能,算是一个功能集合的脚本。
创建 Luns;
创建 host group、host、host port;
映射端口到 host 上;
删除 Lun、host group、host、host port,映射 Lun。它包括了 delmap.cmd, delhost.cmd, dellun.cmd 的所有功能,算是一个功能集合的脚本;
删除 Lun 映射
删除 host group、host、host port
删除 Lun
复制 setup.cmd 的内容到 IBM Storage Manager 脚本编辑器中,然后运行它。或者用户也可以单独的复制 crtlun.cmd, crthost.cmd, maplun.cmd 中的内容,来实现单独的一些功能。这时 Lun 已经在 DS4000 上建立好了,同时也映射到了主机上。
当然,同时可以执行 destroy.cmd 内的内容来进行删除操作,或者单独地执行 delmap.cmd, delhost.cmd, dellun.cmd 内的内容来清除刚才执行的创建操作。
下面是 ds4kscript.sh 的详细内容,请注意其中的注解内容,会帮助您的理解:下面是 ds4kscript.sh 的详细内容,请注意其中的注解内容,会帮助您的理解:
#
ConfigFile=./config
ProgramName=./ds4kscript.sh
if [ -f $ConfigFile ]
then
echo "OK" >> /dev/null
else
echo "$ConfigFile not exist!"
exit -1
fi
# 从配置文件中依次获取参数值
sed -n '/LunNumber:/'p $ConfigFile >tmp
lunNumber=`sed 's/LunNumber://' tmp`
echo lunNumber=$lunNumber
sed -n '/ArrayNumber:/'p $ConfigFile >tmp
arrayNumber=`sed 's/ArrayNumber://' tmp`
echo arrayNumber=$arrayNumber
sed -n '/LunName:/'p $ConfigFile >tmp
lunName=`sed 's/LunName://' tmp`
echo lunName=$lunName
sed -n '/Capacity:/'p $ConfigFile >tmp
capacity=`sed 's/Capacity://' tmp`
echo capacity=$capacity
sed -n '/HostGroupName:/'p $ConfigFile >tmp
hostGroupName=`sed 's/HostGroupName://' tmp`
echo hostGroupName=$hostGroupName
sed -n '/HostName:/'p $ConfigFile >tmp
hostName=`sed 's/HostName://' tmp`
echo hostName=$hostName
sed -n '/Port0:/'p $ConfigFile >tmp
port0=`sed 's/Port0://' tmp`
echo port0=$port0
sed -n '/Port1:/'p $ConfigFile >tmp
port1=`sed 's/Port1://' tmp`
echo port1=$port1
sed -n '/HostType:/'p $ConfigFile >tmp
hostType=`sed 's/HostType://' tmp`
echo hostType=$hostType
# 创建 IBM storage manager 使用的脚本中创建 Lun 的部分,并保存为 crtlun.cmd。
if [ -f crtlun.cmd ]
then
rm crtlun.cmd
else
echo "OK" >> /dev/null
fi
x=0
while [ $x -lt $lunNumber ]
do
y=`expr $x % 2`
if [ $y -eq 0 ]
then
echo "create logicalDrive array=$arrayNumber userLabel="${lunName}_${x}"
capacity=$capacity owner=a;" >> crtlun.cmd
else
echo "create logicalDrive array=$arrayNumber userLabel="${lunName}_${x}"
capacity=$capacity owner=b;" >> crtlun.cmd
fi
x=`expr $x + 1`
done
# 创建 IBM storage manager 使用的脚本中创建 host group,host 和 host port 的部分,并保存为 crthost.cmd。
if [ -f crthost.cmd ]
then
rm crthost.cmd
else
echo "OK" >> /dev/null
fi
echo "create hostGroup userLabel="$hostGroupName";" >>crthost.cmd
echo "create host userLabel = "$hostName" hostGroup = "$hostGroupName";" >>crthost.cmd
echo "create hostPort identifIEr = "$port0" userLabel = "${hostName}_hba0"
host = "$hostName" hostType = $hostType;" >>crthost.cmd
echo "create hostPort identifier = "$port1" userLabel = "${hostName}_hba1"
host = "$hostName" hostType = $hostType;" >>crthost.cmd
# 创建 IBM storage manager 使用的脚本中映射 Lun 的部分,并保存为 maplun.cmd。
if [ -f maplun.cmd ]
then
rm maplun.cmd
else
echo "OK" >> /dev/null
fi
x=0
while [ $x -lt $lunNumber ]
do
echo "set logicalDrive ["${lunName}_${x}"] logicalUnitNumber=$x
hostGroup="$hostGroupName";" >>maplun.cmd
x=`expr $x + 1`
done
# 创建 IBM storage manager 使用的脚本中删除 Lun 映射的部分,并保存为 delmap.cmd。
if [ -f delmap.cmd ]
then
rm delmap.cmd
else
echo "OK" >> /dev/null
fi
x=0
while [ $x -lt $lunNumber ]
do
echo "remove logicalDrive ["${lunName}_${x}"] lunMapping
hostGroup="$hostGroupName";" >>delmap.cmd
x=`expr $x + 1`
done
# 创建 IBM storage manager 使用的脚本中删除 Lun 的部分,并保存为 dellun.cmd。
if [ -f dellun.cmd ]
then
rm dellun.cmd
else
echo "OK" >> /dev/null
fi
x=0
while [ $x -lt $lunNumber ]
do
echo "delete logicalDrive ["${lunName}_${x}"];" >>dellun.cmd
x=`expr $x + 1`
done
# 创建 IBM storage manager 使用的脚本中删除 host port 的部分,并保存为 delhost.cmd。
if [ -f delhost.cmd ]
then
rm delhost.cmd
else
echo "OK" >> /dev/null
fi
echo "delete hostPort ["$port0"];" >>delhost.cmd
echo "delete hostPort ["$port1"];" >>delhost.cmd
echo "delete host ["$hostName"];" >>delhost.cmd
echo "delete hostGroup ["$hostGroupName"];" >>delhost.cmd
# 创建 IBM storage manager 使用的 2 个功能集合脚本,并分别保存为 setup.cmd 和 destroy.cmd。
if [ -f setup.cmd ]
then
rm setup.cmd
else
echo "OK" >> /dev/null
fi
cat crtlun.cmd >>setup.cmd
cat crthost.cmd >>setup.cmd
cat maplun.cmd >>setup.cmd
if [ -f destroy.cmd ]
then
rm destroy.cmd
else
echo "OK" >> /dev/null
fi
cat delmap.cmd >>destroy.cmd
cat delhost.cmd >>destroy.cmd
cat dellun.cmd >>destroy.cmd
标签: