1.要求先配置好horcm;
2.存储清单文件
STLISTFILE需根据实际情况更改,格式如下,可自行根据需要更改格式和脚本中的引用。
GL_VSP_210 GL PRD JT 55034 horcm9 1 on
GL_G1000_503 GL PRD JT 50990 horcm15 1 on
3.实现的功能看具体help信息。
4.根据实际情况修改password。
具体脚本信息如下:
---------------
#!/bin/ksh
#ScriptName : hdsop.sh
#AuthorName : wangtao039
#Version : 1.0 20161002
#Description:
export PATH=/usr/kerberos/bin:/usr/local/jdk6/bin:/usr/local/bin:/bin:/usr/bin:/home/stadmin/bin:/home/stadmin/strsms/bin/hsnm2cli:/home/stadmin/strsms/bin:/opt/Navisphere/bin:/home/stadmin/sanvc/bin:$PATH
CMDPWD=/HORCM/usr/bin
ETCPWD=/HORCM/usr/bin/custom/etc
RAIDCOM=$CMDPWD/raidcom
STLISTFILE=$ETCPWD/stlistfile
POOLINFO=/tmp/hdsop_POOLINFO.`date +%Y%m%d%H%M%S`
FMCPOOLINFO=/tmp/hdsop_FMCPOOLINFO.`date +%Y%m%d`
LOGFILE=/HORCM/usr/bin/custom/log/hdsop.log.`date +%Y%m%d`
TMPFILEA=/tmp/hdsop_TMPFILEA.`date +%y%m%d%H%M%S`
TMPFILEB=/tmp/hdsop_TMPFILEB.`date +%y%m%d%H%M%S`
TMPFILEC=/tmp/hdsop_TMPFILEC.`date +%y%m%d%H%M%S`
TMPFILED=/tmp/hdsop_TMPFILED.`date +%y%m%d%H%M%S`
TMPFILEE=/tmp/hdsop_TMPFILEE.`date +%y%m%d%H%M%S`
TMPFILEF=/tmp/hdsop_TMPFILEF.`date +%y%m%d%H%M%S`
TMPFILEG=/tmp/hdsop_TMPFILEG.`date +%y%m%d%H%M%S`
TMPFILEH=/tmp/hdsop_TMPFILEH.`date +%y%m%d%H%M%S`
TMPFILEI=/tmp/hdsop_TMPFILEI.`date +%y%m%d%H%M%S`
PORTLISTFILE=/tmp/hdsop_PORTLISTFILE.`date +%y%m%d%H%M%S`
HGINFOFILE=/tmp/hdsop_HGINFOFILE.`date +%y%m%d%H%M%S`
PORTLDEVINFOFILE=/tmp/hdsop_PORTLDEVINFOFILE.`date +%y%m%d%H%M%S`
PORTHGINFOFILE=/tmp/hdsop_PORTHGINFOFILE.`date +%y%m%d%H%M%S`
UNUSEDLDEVFILE=/tmp/hdsop_UNUSEDLDEVFILE.`date +%y%m%d%H%M%S`
HORCMSTATUSFILE=/tmp/hdsop_HORCMSTATUSFILE.`date +%y%m%d%H%M%S`
#for opcm start
PORTINFOFILE=/tmp/hdsop_PORTINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
RGINFOFILE=/tmp/hdsop_RGINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
PLDEVRGINFOFILE=/tmp/hdsop_PLDEVRGINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
VLDEVPOOLINFOFILE=/tmp/hdsop_VLDEVPOOLINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
PLDEVPOOLINFOFILE=/tmp/hdsop_PLDEVPOOLINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
HGHOSTINFOFILE=/tmp/hdsop_HGHOSTINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
HGLDEVINFOFILE=/tmp/hdsop_HGLDEVINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm
#for opcm end
chmod 666 /tmp/hdsop*
HNAME=`hostname`
##user only check
CHKUSERNAME=user
CHKUSERPWD=
password
##user can operate
STADMINUSER=stadmin
STADMINPWD=password
####g3ah1060&z4ah2030
#############################################################################
func_CreateHg()
{
#Status:done
##Usage:
##func_CreateHg
##func_CreateHg $HORCMNUM $HGNAME $OSTYPE $PORTLIST $VCSVALUE $SVCVALUE
##Example: func_CreateHg 12 hg_test HP-UX CL1-E Y N
#HOSTMODE&OSTYPE: HP-UX,SOLARIS,AIX,WIN,LINUX/IRIX,TRU64,DYNIX,OVMS,NETWARE,HI-UX,VMWARE,VMWARE_EX,WIN_EX,UVM
#HOSTMODEOPERATION: 2 for vcs;2&22 for vcs&aix;39 for svc;54 for VMWARE;100 for none
HORCMNUM=$1
NEWHGNAME=$2
HOSTMODE=$3
PORTLIST=$4
VCSVALUE=$5
SVCVALUE=$6
OSTYPE=$3
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HORCMNUM INPUT, EXIT NOW .";fi
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $NEWHGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO NEWHGNAME INPUT, EXIT NOW.";fi
if [ $NEWHGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO NEWHGNAME INPUT, EXIT NOW.">>$LOGFILE;return;fi
if [ $HOSTMODE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HOSTMODE INPUT, EXIT NOW .";fi
if [ $HOSTMODE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HOSTMODE INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO PORTLIST INPUT, EXIT NOW .";fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $VCSVALUE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO VCSVALUE INPUT, EXIT NOW .";fi
if [ $VCSVALUE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO VCSVALUE INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $SVCVALUE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO SVCVALUE INPUT, EXIT NOW .";fi
if [ $SVCVALUE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO SVCVALUE INPUT, EXIT NOW .">>$LOGFILE;return;fi
export HORCMINST=$HORCMNUM
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login
rm $TMPFILEE
HOSTMODEOPT=""
if [ $VCSVALUE = "Y" ] ; then HOSTMODEOPT="2" ; fi
if [ $OSTYPE = "AIX" ] ; then HOSTMODEOPT="$HOSTMODEOPT 22" ; fi
if [ $SVCVALUE = "Y" ] ; then HOSTMODEOPT="$HOSTMODEOPT 39" ; fi
if [ $OSTYPE = "VMWARE" ] ; then HOSTMODEOPT="$HOSTMODEOPT 54" ; fi
if [ $HOSTMODEOPT"x" = "x" ] ; then $HOSTMODEOPT=100 ; fi
echo $PORTLIST|sed 's/,/ /g'|xargs -n1|while read name
do
NUM=`echo $name|cut -c 1`
CHAR=`echo $name|cut -c 2`
PORTNAME=CL"$NUM"-"$CHAR"
$RAIDCOM get host_grp -port $PORTNAME|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateHg:">>$LOGFILE
$RAIDCOM get host_grp -port $PORTNAME|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateHg:"
echo "[`date +%Y%m%d%H%M%S`:CreateHg: $RAIDCOM add host_grp -port $PORTNAME -host_grp_name $NEWHGNAME ] ."
echo "[`date +%Y%m%d%H%M%S`:CreateHg: $RAIDCOM add host_grp -port $PORTNAME -host_grp_name $NEWHGNAME ] .">>$LOGFILE
$RAIDCOM add host_grp -port $PORTNAME -host_grp_name $NEWHGNAME
echo "[`date +%Y%m%d%H%M%S`:CreateHg: $RAIDCOM modify host_grp -port $PORTNAME $NEWHGNAME -host_mode $HOSTMODE -host_mode_opt $HOSTMODEOPT ]."
echo "[`date +%Y%m%d%H%M%S`:CreateHg: $RAIDCOM modify host_grp -port $PORTNAME $NEWHGNAME -host_mode $HOSTMODE -host_mode_opt $HOSTMODEOPT ].">>$LOGFILE
$RAIDCOM modify host_grp -port $PORTNAME $NEWHGNAME -host_mode $HOSTMODE -host_mode_opt $HOSTMODEOPT
echo "#################################################################"
echo "[`date +%Y%m%d%H%M%S`:CreateHg: $RAIDCOM get host_grp -port $PORTNAME ].">>$LOGFILE
$RAIDCOM get host_grp -port $PORTNAME|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateHg:">>$LOGFILE
$RAIDCOM get host_grp -port $PORTNAME|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateHg:"
done
$RAIDCOM -logout >/dev/null
}
func_MapHost()
{
#Status:done
##Usage:
##func_MapHost
##hdsop.sh -t addhbawwn <-s \$HORCMNUM> <-n \$HGNAME> <-p \$PORTLIST> <-a \$HOSTALIAS> <-w \$HBAWWN>
##Example: func_MapHost 12 1A hg_test_wangtao G4AH7020_HBA0 5001438001189C14
##func_MapHost $HORCMNUM $PORTLIST $HGNAME $HOSTALIAS $HBAWWN
HORCMNUM=$1
PORTLIST=$2
HGNAME=$3
HOSTALIAS=$4
HBAWWN=$5
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HORCMNUM INPUT, EXIT NOW .";fi
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO PORTLIST INPUT, EXIT NOW .";fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HGNAME INPUT, EXIT NOW .";fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HGNAME INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $HBAWWN"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HBAWWN INPUT, EXIT NOW .";fi
if [ $HBAWWN"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HBAWWN INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $HOSTALIAS"x" = "x" ];then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HOSTALIAS INPUT, EXIT NOW .";fi
if [ $HOSTALIAS"x" = "x" ];then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HOSTALIAS INPUT, EXIT NOW .">>$LOGFILE;return;fi
export HORCMINST=$HORCMNUM
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
rm $TMPFILEE
PORTNAME=$PORTLIST
echo "`date +%Y%m%d%H%M%S`:MapHost:Before ADD"
echo "`date +%Y%m%d%H%M%S`:MapHost:Before ADD" >>$LOGFILE
echo "`date +%Y%m%d%H%M%S`:MapHost:$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME" >>$LOGFILE
$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME|awk '{print time":MapHost: "$0}' time=`date +%Y%m%d%H%M%S`
$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME|awk '{print time":MapHost: "$0}' time=`date +%Y%m%d%H%M%S`>>$LOGFILE
echo "`date +%Y%m%d%H%M%S`:MapHost:$RAIDCOM add hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN " >>$LOGFILE
$RAIDCOM add hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN
$RAIDCOM set hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN -wwn_nickname $HOSTALIAS
echo "`date +%Y%m%d%H%M%S`:MapHost:$RAIDCOM set hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN -wwn_nickname $HOSTALIAS" >>$LOGFILE
echo "`date +%Y%m%d%H%M%S`:MapHost:After ADD"
echo "`date +%Y%m%d%H%M%S`:MapHost:After ADD" >>$LOGFILE
$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME|awk '{print time":MapHost: "$0}' time=`date +%Y%m%d%H%M%S`
$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME|awk '{print time":MapHost: "$0}' time=`date +%Y%m%d%H%M%S` >>$LOGFILE
$RAIDCOM -logout >/dev/null
}
func_CreateLdevFromPool()
{
#Status:done
##Usage:
##func_CreateLdevFromPool
##Example: func_CreateLdevFromPool 12 DATA_POOL 1100 1090519680
HORCMNUM=$1
POOLNAME=$2
LDEVNAME=$3
LDEVSIZE=$4
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HORCMNUM INPUT, EXIT NOW .";return;fi
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $POOLNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO PORTLIST INPUT, EXIT NOW .";return;fi
if [ $POOLNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $LDEVNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HBAWWN INPUT, EXIT NOW .";return;fi
if [ $LDEVNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HBAWWN INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $LDEVSIZE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HOSTALIAS INPUT, EXIT NOW .";return;fi
if [ $LDEVSIZE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HOSTALIAS INPUT, EXIT NOW .">>$LOGFILE;return;fi
echo $POOLNAME
export HORCMINST=$HORCMNUM
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
STNAME=`cat $STLISTFILE|grep -v ^#|grep -v off|grep horcm"$HORCMNUM "|awk '{print $1}'`
POOLID=`cat $POOLINFO|grep $STNAME|grep $POOLNAME|awk '{print $4}'`
echo "POOID : $POOLID"
echo "$RAIDCOM add ldev -pool $POOLID -ldev_id 0x$LDEVNAME -capacity $LDEVSIZE"|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateLdevFromPool:">>$LOGFILE
$RAIDCOM add ldev -pool $POOLID -ldev_id 0x$LDEVNAME -capacity $LDEVSIZE
$RAIDCOM get ldev -ldev_id 0x$LDEVNAME -fx|egrep "^LDEV :|B_POOLID|VOL_Capacity"|sed 's/ //g'|xargs|sed 's/ /,/g'|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateLdevFromPool:">>$LOGFILE
$RAIDCOM get ldev -ldev_id 0x$LDEVNAME -fx|egrep "^LDEV :|B_POOLID|VOL_Capacity"|sed 's/ //g'|xargs|sed 's/ /,/g'|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:CreateLdevFromPool:"
$RAIDCOM -logout >/dev/null
echo "raidcom logout ."
}
func_ListMappedLdev()
{
##Status:done
##Usage:
##func_MapLdev <$HORCMNUM>
##Example: func_MapLdev 12 1A hg_test_wangtao 003e
HORCMNUM=$1
PORTLIST=$2
HGNAME=$3
LUNNAME_A=$4
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .";fi
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW .";fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .";fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fi
LUNNAME_B=`echo $LUNNAME_A|tr a-z A-Z`
LDEVNAME=`echo "ibase=16;$LUNNAME_B"|bc`
export HORCMINST=$HORCMNUM
if [ $HORCMNUM"x" = "x" ] ;then echo "NO HORCMNUM INPUT, EXIT NOW .";return;fi
AA=`echo $PORTLIST|cut -c 1`
BB=`echo $PORTLIST|cut -c 2`
PORTNAME=CL$AA"-"$BB
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
echo "`date +%Y%m%d%H%M%S`:MappedLdevlist start:"
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:MapLdev: "
echo "`date +%Y%m%d%H%M%S`:MappedLdevlist end:"
$RAIDCOM -logout >/dev/null
}
func_MapLdev()
{
##Status:done
##Usage:
##func_MapLdev <$HORCMNUM>
##Example: func_MapLdev 12 1A hg_test_wangtao 003e
HORCMNUM=$1
PORTLIST=$2
HGNAME=$3
LUNNAME_A=$4
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .";fi
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW .";fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .";fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fi
if [ $LUNNAME_A"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO LUNNAME INPUT, EXIT NOW .";fi
if [ $LUNNAME_A"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO LUNNAME INPUT, EXIT NOW .">>$LOGFILE;return;fi
LUNNAME_B=`echo $LUNNAME_A|tr a-z A-Z`
LDEVNAME=`echo "ibase=16;$LUNNAME_B"|bc`
export HORCMINST=$HORCMNUM
if [ $HORCMNUM"x" = "x" ] ;then echo "NO HORCMNUM INPUT, EXIT NOW .";return;fi
AA=`echo $PORTLIST|cut -c 1`
BB=`echo $PORTLIST|cut -c 2`
PORTNAME=CL$AA"-"$BB
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
echo "`date +%Y%m%d%H%M%S`:MapLdev:Before map"
echo "`date +%Y%m%d%H%M%S`:MapLdev:Before map">>$LOGFILE
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:MapLdev: "
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:MapLdev: ">>$LOGFILE
$RAIDCOM add lun -port $PORTNAME $HGNAME -ldev_id $LDEVNAME
echo "`date +%Y%m%d%H%M%S`:MapLdev:$RAIDCOM add lun -port $PORTNAME $HGNAME -ldev_id $LDEVNAME ">>$LOGFILE
echo "`date +%Y%m%d%H%M%S`:MapLdev:After map"
echo "`date +%Y%m%d%H%M%S`:MapLdev:After map">>$LOGFILE
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:MapLdev: "
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx|awk '{print aa,$0}' aa="`date +%Y%m%d%H%M%S`:MapLdev: ">>$LOGFILE
$RAIDCOM -logout >/dev/null
}
func_DelHg()
{
#status:done
##Usage:
##func_DelHg
##func_DelHg 12 hg_test_wt2 1A,2A
export HORCMINST=$1
HGNAME=$2
PORTLIST=$3
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
echo "cat $TMPFILEE|$RAIDCOM -login >/dev/null"
echo $PORTLIST|sed 's/,/ /g'|xargs -n1|while read name
do
NUM=`echo $name|cut -c 1`
CHAR=`echo $name|cut -c 2`
PORTNAME=CL"$NUM"-"$CHAR"
echo $RAIDCOM get host_grp -port $PORTNAME
echo $RAIDCOM delete host_grp -port $PORTNAME $HGNAME
echo $RAIDCOM get host_grp -port $PORTNAME
done
echo "$RAIDCOM -logout"
}
func_UnmapHost()
{
##Status:done
##Usage:
##func_UnmapHost
##hdsop.sh -t deletehbawwn <-s \$HORCMNUM> <-n \$HGNAME> <-p \$PORTLIST> <-w \$HBAWWN>
##Example: func_UnmapHost 12 1A hg_test_wangtao 5001438001189c14
HORCMNUM=$1
PORTLIST=$2
HGNAME=$3
HBAWWN=$4
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HORCMNUM INPUT, EXIT NOW .";return;fi
if [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO PORTLIST INPUT, EXIT NOW .";return;fi
if [ $HGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HGNAME INPUT, EXIT NOW .";return;fi
if [ $HBAWWN"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HBAWWN INPUT, EXIT NOW .";return;fi
export HORCMINST=$HORCMNUM
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
AA=`echo $PORTLIST|cut -c 1`
BB=`echo $PORTLIST|cut -c 2`
PORTNAME=CL$AA"-"$BB
echo "Before DELETE"
$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME
echo "###########################################"
echo "Do it manually ."
echo "export HORCMINST=$HORCMNUM"
echo "cat $TMPFILEE|$RAIDCOM -login >/dev/null"
echo $RAIDCOM delete hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN
echo $RAIDCOM get hba_wwn -port $PORTNAME $HGNAME
echo "$RAIDCOM -logout >/dev/null"
#$RAIDCOM delete hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN
#echo "After DELETE"
#$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME
echo "###########################################"
$RAIDCOM -logout
}
func_UnmapLdev()
{
##Status:done
##Usage:
##func_UnmapLdev <$HORCMNUM>
##Example: func_UnmapLdev 12 1A hg_test_wangtao 003e
HORCMNUM=$1
PORTLIST=$2
HGNAME=$3
LUNNAME_A=$4
LUNNAME_B=`echo $LUNNAME_A|tr a-z A-Z`
LDEVNAME=`echo "ibase=16;$LUNNAME_B"|bc`
export HORCMINST=$HORCMNUM
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HORCMNUM INPUT, EXIT NOW .";return;fi
AA=`echo $PORTLIST|cut -c 1`
BB=`echo $PORTLIST|cut -c 2`
PORTNAME=CL$AA"-"$BB
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
echo "before unmap:"
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx
$RAIDCOM delete lun -port $PORTNAME $HGNAME -ldev_id $LDEVNAME
echo "after unmap:"
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx
$RAIDCOM -logout >/dev/null
}
func_DeleteLdevFromPool()
{
#Status:done
##Usage:
##func_DeleteLdevFromPool
##Example: func_DeleteLdevFromPool 12 111b
HORCMNUM=$1
LDEVNAME=$3
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HORCMNUM INPUT, EXIT NOW .";return;fi
if [ $LDEVNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HBAWWN INPUT, EXIT NOW .";return;fi
echo $STADMINUSER>$TMPFILEE
echo $STADMINPWD>>$TMPFILEE
cat $TMPFILEE|$RAIDCOM -login >/dev/null
$RAIDCOM get ldev -ldev_id 0x$LDEVNAME -fx|egrep "^LDEV :|B_POOLID|VOL_Capacity"|sed 's/ //g'|xargs|sed 's/ /,/g'
$RAIDCOM delete ldev -ldev_id 0x$LDEVNAME
$RAIDCOM get ldev -ldev_id 0x$LDEVNAME -fx|egrep "^LDEV :|VOL_TYPE :"|sed 's/ //g'|xargs|sed 's/ /,/g'
$RAIDCOM -logout >/dev/null
}
func_GetPoolUsage()
{
##Status:done
##Usage:
##func_GetPoolUsage <$HORCMNUM>
##Example: func_GetPoolUsage 1 for horcm1 storage.
##Example: func_GetPoolUsage for all storage.
TMPFILESTLIST=/tmp/func_GetPoolUsage.TMPFILESTLIST.`date +%y%m%d%H%M%S`;touch $TMPFILESTLIST
if [ $1"x" != "x" ]
then
cat $STLISTFILE|grep -v ^#|grep -vi off|grep -i "horcm$HORCMNUM " >$TMPFILESTLIST
else
cat $STLISTFILE|grep -v ^#|grep -vi off>$TMPFILESTLIST
fi
rm /tmp/hdsop_POOLINFO*
echo "STNAME STSN POOLNAME POOLID POOLSIZE ASSIGNSIZE FREESIZE ASSIGN% USAGE% WARN1% WARN2% " \
|awk '{printf "%-15s%-10s%-20s%-8s%-15s%-15s%-15s%-15s%-10s%-10s%-10s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}'>$POOLINFO
echo "STNAME STSN POOLNAME POOLID POOLSIZE ASSIGNSIZE FREESIZE ASSIGN% USAGE% WARN1% WARN2% " \
|awk '{printf "%-15s%-10s%-20s%-8s%-15s%-15s%-15s%-15s%-10s%-10s%-10s\n","1","2","3","4","5","6","7","8","9","10","11"}'>>$POOLINFO
cat $TMPFILESTLIST|while read name
do
(
STNAME=`echo $name|awk '{print $1}'`
TMPFILEPOOLNAME=/tmp/func_GetPoolUsage.TMPFILEPOOLNAME.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEPOOLNAME
TMPFILEPOOLID=/tmp/func_GetPoolUsage.TMPFILEPOOLID.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEPOOLID
STSN=`echo $name|awk '{print $5}'`
STHM=`echo $name|awk '{print $6}'|sed 's/horcm//g'`
export HORCMINST=$STHM
$RAIDCOM -login $CHKUSERNAME $CHKUSERPWD
$RAIDCOM get pool -key opt|grep -v POOL_NAME|awk '{print $1,$4,$5}'>$TMPFILEPOOLNAME
$RAIDCOM get dp_pool|grep -v PID|awk '{print $1,$3,$4,$5,$11,$6,$7}'>$TMPFILEPOOLID
join $TMPFILEPOOLNAME $TMPFILEPOOLID|awk '{printf "%-15s%-10s%-20s%-8s%-15d%-15d%-15d%-15d%-10d%-10d%-10d\n",stname,$3,$2,$1,$6/1024,$7/1024,$5/1024,$7/$6*100,$4,$8,$9}' stname=$STNAME
join $TMPFILEPOOLNAME $TMPFILEPOOLID|awk '{printf "%-15s%-10s%-20s%-8s%-15d%-15d%-15d%-15d%-10d%-10d%-10d\n",stname,$3,$2,$1,$6/1024,$7/1024,$5/1024,$7/$6*100,$4,$8,$9}' stname=$STNAME >>$POOLINFO
###for thick mod start
TMPFILED=/tmp/func_GetPoolUsage.TMPFILED.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILED
TMPFILEE=/tmp/func_GetPoolUsage.TMPFILEE.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEE
TMPFILEF=/tmp/func_GetPoolUsage.TMPFILEF.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEF
TMPFILEG=/tmp/func_GetPoolUsage.TMPFILEG.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEG
$RAIDCOM get ldev -ldev_list defined -key parity_grp -fx|grep -v POOL|awk '{print $2}'|grep -v LDEV >$TMPFILED
if [ `cat $TMPFILED|wc -l` -eq 0 ]
then
echo ""
else
####get thick mod ldev list
$RAIDCOM get ldev -ldev_list defined -fx|egrep "^LDEV :|^VOL_Capacity"|xargs -n6|awk '{printf"%s %d\n",$3,$6/2/1024/1024}'>$TMPFILEE
####get thick mod ldev size
$RAIDCOM get ldev -ldev_list mapped -fx |grep "^LDEV :"|awk '{print $3}'>$TMPFILEF
####get thick mod ldev's status : mapped
>$TMPFILEG
cat $TMPFILED|while read ldevname
do
LDEVSIZE=`cat $TMPFILEE|grep "^$ldevname "|awk '{print $2}'`
VALUE=`cat $TMPFILEF|grep "^$ldevname$"|wc -l`
if [ $VALUE -eq 0 ]
then
USEDSIZE=0
ASSIGNSIZE=0
else
ASSIGNSIZE=$LDEVSIZE
USEDSIZE=`echo $LDEVSIZE*0.75|bc|awk '{printf "%d\n",$1}'`
fi
echo $ldevname,$LDEVSIZE,$ASSIGNSIZE,$USEDSIZE >>$TMPFILEG
done
THICKMODSIZE=`cat $TMPFILEG|awk -F, '{sum+=$2}'END'{print sum}'`
THICKASSIGNSIZE=`cat $TMPFILEG|awk -F, '{sum+=$3}'END'{print sum}'`
THICKUSEDSIZE=`cat $TMPFILEG|awk -F, '{sum+=$4}'END'{print sum}'`
THICKFREESIZE=`echo $THICKMODSIZE-$THICKUSEDSIZE|bc`
THICKASSIGNUSAGE=`echo "scale=2;$THICKASSIGNSIZE/$THICKMODSIZE*100"|bc`
THICKMODUSAGE=`echo "scale=2;$THICKUSEDSIZE/$THICKMODSIZE*100"|bc`
echo "$STNAME,$STSN,THICK,999,$THICKMODSIZE,$THICKASSIGNSIZE,$THICKFREESIZE,$THICKASSIGNUSAGE,$THICKMODUSAGE,80,90" \
|awk -F, '{printf "%-15s%-10s%-20s%-8s%-15d%-15d%-15d%-15d%-10d%-10d%-10d\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}'
echo "$STNAME,$STSN,THICK,999,$THICKMODSIZE,$THICKASSIGNSIZE,$THICKFREESIZE,$THICKASSIGNUSAGE,$THICKMODUSAGE,80,90" \
|awk -F, '{printf "%-15s%-10s%-20s%-8s%-15d%-15d%-15d%-15d%-10d%-10d%-10d\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}'>>$POOLINFO
fi
###for thick mod end
###
$RAIDCOM -logout >/dev/null
rm $TMPFILEPOOLID $TMPFILEPOOLNAME $TMPFILED $TMPFILEE $TMPFILEF $TMPFILEG >/dev/null 2>&1
)&
done
wait
chmod 644 $POOLINFO
echo "***********************************************************************************"
cat $POOLINFO
rm $TMPFILESTLIST
}
func_GetFMCUsage()
{
##Status:done
##Usage:
##func_GetPoolUsage <$HORCMNUM>
##Example: func_GetPoolUsage 1 for horcm1 storage.
##Example: func_GetPoolUsage for all storage.
if [ $1"x" != "x" ]
then
cat $STLISTFILE|grep -v ^#|grep -vi off|grep -i "horcm$HORCMNUM " >$TMPFILEA
else
cat $STLISTFILE|grep -v ^#|grep -vi off >$TMPFILEA
fi
echo "STNAME STSN POOLNAME POOLID ACT_Usage ACT_AVP ACT_TP FMC_LOG_USED FMC_ACT_USED FR CR " \
|awk '{printf "%-15s%-10s%-20s%-8s%-15s%-15s%-15s%-15s%-15s%-15s%-10s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}'>$FMCPOOLINFO
cat $TMPFILEA|while read name
do
STNAME=`echo $name|awk '{print $1}'`
STSN=`echo $name|awk '{print $5}'`
STHM=`echo $name|awk '{print $6}'|sed 's/horcm//g'`
export HORCMINST=$STHM
$RAIDCOM -login $CHKUSERNAME $CHKUSERPWD
$RAIDCOM get pool -key opt|grep -v POOL_NAME|awk '{print $1,$4,$5}'|sed 's/ 3/ /g'>$TMPFILEB
$RAIDCOM get pool -key fmc |grep -v PID|awk '{if($5>0)print $0}'|awk '{if($6==0) $6=1;if($7==0)$7=1;print $0}'>$TMPFILEC
join $TMPFILEB $TMPFILEC|awk '{printf "%-15s%-10s%-20s%-8s%-15.2f%-15d%-15d%-15d%-15d%-15.2f%-10.2f\n",stname,$3,$2,$1,$4/100,$5/1024,$6/1024,$8/2/1024/1024,$9/2/1024/1024,$7/100,($8-$9)/$8}' stname=$STNAME>>$FMCPOOLINFO
$RAIDCOM -logout >/dev/null
echo .|awk '{printf"%s",$0}'
done
echo "."
chmod 644 $FMCPOOLINFO
echo "***********************************************************************************"
cat $FMCPOOLINFO
echo "***********************************************************************************"
rm $FMCPOOLINFO
}
func_CheckHorcmd()
{
##Status:done
##Usage:
##func_CheckHorcmd
##Example: func_CheckHorcmd for all storage.
echo "STNAME AREA ENV TYPE STSN HORCM HORSTATUS"|awk '{printf "%-15s%-5s%-5s%-5s%-10s%-12s%-5s\n",$1,$2,$3,$4,$5,$6,$7,$8}'>$HORCMSTATUSFILE
ps -ef|grep horcm|grep -v grep|awk '{print $NF}'|sed 's/d_0//g' >$TMPFILEA
cat $STLISTFILE|grep -v ^#|grep -vi off|grep -v STNAME|while read name
do
HORNAME=`echo $name|awk '{print $6}'`
VALUE=`cat $TMPFILEA|grep $HORNAME$`
if [ $VALUE"x" != "x" ] ;then HORCMSTATUS=ON ;else HORCMSTATUS=OFF ; fi
echo $name $HORCMSTATUS|awk '{printf "%-15s%-5s%-5s%-5s%-10s%-12s%-5s\n",$1,$2,$3,$4,$5,$6,$9}' >>$HORCMSTATUSFILE
done
cat $HORCMSTATUSFILE
}
func_StartHorcmd()
{
##Status:done
##Usage:
##func_StartHorcmd [$HORCMNUM]
##Example: func_StartHorcmd for all storage.
##Example: func_StartHorcmd 1 for horcm1 storage.
echo "********** Status of HORCMD before running startscript **********"
func_CheckHorcmd
echo "********** Status of HORCMD before running startscript **********"
echo "==========================="
if [ $1"x" != "x" ]
then
export HORCMINST=$1
$CMDPWD/horcmstart.sh $HORCMINST
else
func_CheckHorcmd
cat $HORCMSTATUSFILE|grep OFF|awk '{print $6}'|sed 's/horcm//g'|while read NUM
do
export HORCMINST=$NUM
$CMDPWD/horcmstart.sh $HORCMINST
done
fi
echo "==========================="
echo "********** Status of HORCMD after running startscript **********"
func_CheckHorcmd
echo "********** Status of HORCMD after running startscript **********"
}
func_ShutdownHorcmd()
{
##Status:done
##Usage:
##func_ShutdownHorcmd [$HORCMNUM]
##Example: func_ShutdownHorcmd for all storage.
##Example: func_ShutdownHorcmd 1 for horcm1 storage.
echo "********** Status of HORCMD before running shutdonwscript **********"
func_CheckHorcmd
echo "********** Status of HORCMD before running shutdonwscript **********"
echo "==========================="
if [ $1"x" != "x" ]
then
export HORCMINST=$1
$CMDPWD/horcmshutdown.sh $HORCMINST
else
cat $HORCMSTATUSFILE|grep ON|awk '{print $6}'|sed 's/horcm//g'|while read NUM
do
export HORCMINST=$NUM
$CMDPWD/horcmshutdown.sh $HORCMINST
done
fi
echo "==========================="
echo "********** Status of HORCMD after running shutdonwscript **********"
func_CheckHorcmd
echo "********** Status of HORCMD after running shutdonwscript **********"
}
func_GetHginfo()
{
#Status:done
#Usage:func_GetHginfo for one storage $HORCMNUM
#Usage:func_GetHginfo 0 for all storage
#Description:
#
TMPFILESTLIST=/tmp/func_GetHginfo.TMPFILESTLIST.`date +%y%m%d%H%M%S`;touch $TMPFILESTLIST
echo "###################################################################"
echo "`date +%Y%m%d%H%M%S`:GetHginfo:Get HG & PORT info process START ."
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:GetHginfo:NO HORCMNUM INPUT, EXIT NOW .";return;fi
if [ $HORCMNUM"x" = "0x" ]
then
cat $STLISTFILE|grep -v ^#|grep -vi off|awk '{print $6}'|sed 's/horcm//g' >$TMPFILESTLIST
else
echo $HORCMNUM >$TMPFILESTLIST
fi
echo "STNAME,STSN,PORTNAME,PORTWWN">$PORTINFOFILE
echo "STNAME,PORTNAME,PORTWWN,HGNAME,HOSTWWN,HOSTALI">$HGHOSTINFOFILE
echo "STNAME,PORTNAME,PORTWWN,HGNAME,LDEVNAME,HLUN">$HGLDEVINFOFILE
cat $TMPFILESTLIST|while read name
do
(
STNAME=`cat $STLISTFILE|grep -v ^#|grep -vi off|grep -i "horcm$name "|awk '{print $1}'`
PORTLISTFILE=/tmp/func_GetHginfo.PORTLISTFILE.`date +%y%m%d%H%M%S`.$STNAME;touch $PORTLISTFILE
TMPFILEB=/tmp/func_GetHginfo.TMPFILEB.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEB
TMPFILEC=/tmp/func_GetHginfo.TMPFILEC.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEC
TMPFILED=/tmp/func_GetHginfo.TMPFILED.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILED
TMPFILEE=/tmp/func_GetHginfo.TMPFILEE.`date +%y%m%d%H%M%S`.$STNAME;touch $TMPFILEE
echo "`date +%Y%m%d%H%M%S`:GetHginfo:$STNAME START......................................"
export HORCMINST=$name
$RAIDCOM -login $CHKUSERNAME $CHKUSERPWD
$RAIDCOM get port|grep -v PORT|sed 's/ 3/ /g'|awk '{print $1,$11,$10}' >$PORTLISTFILE
cat $PORTLISTFILE|awk '{print stname","$3","$1","toupper($2)}' stname=$STNAME >>$PORTINFOFILE
>$TMPFILEB
cat $PORTLISTFILE|while read name
do
PORTNAME=`echo $name|awk '{print $1}'`
PORTWWN=`echo $name|awk '{print $2}'`
$RAIDCOM get host_grp -port $PORTNAME|awk '{print portwwn,$0}' portwwn=$PORTWWN >>$TMPFILEB
echo .|awk '{printf"%s",$1}'
done
cat $TMPFILEB |grep -v GROUP_NAME|grep -v "G00 "|awk '{if($7=="")$7="null"}''{print $0}' >$TMPFILEC
echo ""
>$TMPFILED
>$TMPFILEE
cat $TMPFILEC|while read name
do
PORTWWN=`echo $name|awk '{print $1}'`
PORTNAME=`echo $name|awk '{print $2}'`
HGNAME=`echo $name|awk '{print $4}'`
$RAIDCOM get hba_wwn -port $PORTNAME $HGNAME|awk '{print stn","$1","toupper(pw)","$3","toupper($4)","$6}' stn=$STNAME pw=$PORTWWN|grep -v GROUP_NAME>>$TMPFILED
$RAIDCOM get lun -port $PORTNAME $HGNAME -fx|grep -v HMO_BITs|awk '{print stn","$1","toupper(pw)","hgname","$6","$4}' stn=$STNAME pw=$PORTWWN hgname=$HGNAME\
|awk -F, '{if(length($5)==3)$5="0"$5;if(length($5)==2)$5="00"$5;if(length($5)==1)$5="000"$5}''{printf"%s,%s,%s,%s,%s,%s\n",$1,$2,$3,$4,$5,$6}'>>$TMPFILEE
echo .|awk '{printf"%s",$1}'
done
$RAIDCOM -logout >/dev/null
cat $TMPFILED|grep -v NICK_NAME>>$HGHOSTINFOFILE
cat $TMPFILEE|grep -v NICK_NAME>>$HGLDEVINFOFILE
echo ""
echo "`date +%Y%m%d%H%M%S`:GetHginfo:$STNAME END......................................."
rm $PORTLISTFILE $TMPFILEB $TMPFILEC $TMPFILED $TMPFILEE $TMPFILEF >/dev/null 2>&1
)&
done
wait
echo $PORTINFOFILE
echo $HGHOSTINFOFILE
echo $HGLDEVINFOFILE
echo "`date +%Y%m%d%H%M%S`:GetHginfo:Get HG & PORT info progress END ."
echo "###################################################################"
}
func_GetPLDEVinfo()
{
#Status:done
#Usage:func_GetPLDEVinfo for one storage $HORCMNUM
#Usage:func_GetPLDEVinfo 0 for all storage
#Description:
#
echo "###################################################################"
echo "`date +%Y%m%d%H%M%S`:GetHginfo:Get RG&PLDEV info process START ."
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:GetHginfo:NO HORCMNUM INPUT, EXIT NOW .";return;fi
if [ $HORCMNUM"x" = "0x" ]
then
cat $STLISTFILE|grep -v ^#|grep -vi off|awk '{print $6}'|sed 's/horcm//g' >$TMPFILEA
else
echo $HORCMNUM >$TMPFILEA
fi
echo "STNAME,RGNAME,RGTYPE,RGSIZE">$RGINFOFILE
echo "STNAME,RGNAME,PLDEVNAME,UDID,PLDEVSIZE">$PLDEVRGINFOFILE
cat $TMPFILEA|while read name
do
export HORCMINST=$name
STNAME=`cat $STLISTFILE|grep -v ^#|grep -vi off|grep "horcm$name "|awk '{print $1}'`
echo "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:$STNAME START......................................"
$RAIDCOM -login $CHKUSERNAME $CHKUSERPWD
$RAIDCOM get ldev -ldev_list defined -key parity_grp -fx|grep -v Serial>$TMPFILEB
$RAIDCOM get ldev -ldev_list defined -fx|egrep "^LDEV |^VOL_Capacity"|xargs -n6|awk '{printf"%s %d\n",$3,$6/2/1024/1024}' \
|awk '{if(length($1)==3)$1="0"$1;if(length($1)==2)$1="00"$1;if(length($1)==1)$1="000"$1}''{print $1,$2}'>$TMPFILEC
$RAIDCOM -logout
cat $TMPFILEB|awk '{print $12}'|sort -u|while read name
do
RGSIZE=`cat $TMPFILEB|awk '{if($12==rgname)sum+=$10/1024/1024}'END'{print sum}' rgname=$name`
cat $TMPFILEB|awk '{if($12==rgname)printf"%s,%s,%s,%d\n",stname,$12,$7,rgsize}' stname=$STNAME rgsize=$RGSIZE rgname=$name|sort -u >>$RGINFOFILE
done
cat $TMPFILEB|awk '{printf "%s,%s,%s,%d\n",stname,$12,$2,$10/1024/1024}' stname=$STNAME|sed 's/ //g' \
|awk -F, '{if(length($3)==3)$3="0"$3;if(length($3)==2)$3="00"$3;if(length($3)==1)$3="000"$3}''{printf"%s,%s,%s,%s,%d\n",$1,$2,$3,$3,$4}' >$TMPFILED
cat $TMPFILED|while read info
do
PLDEVNAME=`echo $info|awk -F, '{print $3}'`
PLDEVSIZE=`cat $TMPFILEC|grep -i "^$PLDEVNAME "|awk '{if($2==0)$2=1}''{print $2/2}'`
echo $info|awk -F, '{print $1","$2","$3","$4","plsize}' plsize=$PLDEVSIZE
done >>$PLDEVRGINFOFILE
done
echo "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:RGINFOFILE is [ $RGINFOFILE ] ."
echo "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:PLDEVRGINFOFILEFILE is [ $PLDEVRGINFOFILE ] ."
>$TMPFILEA;>$TMPFILEB
echo "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:Get RG&PLDEV info progress END ."
echo "###################################################################"
}
func_GetPoolLdevinfo()
{
#Status:done
#Usage:func_GetPLDEVinfo for one storage $HORCMNUM
#Usage:func_GetPLDEVinfo 0 for all storage
#Description:
#
echo "###################################################################"
echo "`date +%Y%m%d%H%M%S`:GetHginfo:Get RG&PLDEV info process START ."
if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:GetHginfo:NO HORCMNUM INPUT, EXIT NOW .";return;fi
if [ $HORCMNUM"x" = "0x" ]
then
cat $STLISTFILE|grep -v ^#|grep -vi off|awk '{print $6}'|sed 's/horcm//g' >$TMPFILEA
else
echo $HORCMNUM >$TMPFILEA
fi
echo "STNAME,VLDEVNAME,UDID,VLDEVSIZE,POOLNAME">$VLDEVPOOLINFOFILE
echo "STNAME,PLDEVNAME,POOLNAME">$PLDEVPOOLINFOFILE
cat $TMPFILEA|while read name
do
export HORCMINST=$name
STNAME=`cat $STLISTFILE|grep -v ^#|grep -vi off|grep "horcm$name "|awk '{print $1}'`
echo "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:$STNAME START......................................"
$RAIDCOM -login $CHKUSERNAME $CHKUSERPWD
$RAIDCOM get pool -key opt|grep -v POOL_NAME|awk '{printf"%d %s\n",$1,$4}' >$TMPFILEB
$RAIDCOM get ldev -ldev_list dp_volume -fx >$TMPFILEC
cat $TMPFILEC|egrep "^LDEV :|VOL_Capacity|B_POOLID"|xargs -n9|awk '{printf"%s %d %d\n",$3,$6/1024/1024/2,$9}'>$TMPFILED
cat $TMPFILEB|while read poolinfo
do
POOLID=`echo $poolinfo|awk '{print $1}'`
POOLNAME=`echo $poolinfo|awk '{print $2}'`
cat $TMPFILED|awk '{if($3==poolid)$3=poolname;print $1,$2,$3}' poolid=$POOLID poolname=$POOLNAME >$TMPFILEE
mv $TMPFILEE $TMPFILED
done
cat $TMPFILED|awk '{if(length($1)==3)$1="0"$1;if(length($1)==2)$1="00"$1;if(length($1)==1)$1="000"$1}''{print stname","$1","$1","$2","$3}' stname=$STNAME>>$VLDEVPOOLINFOFILE
$RAIDCOM get ldev -ldev_list defined -key parity_grp -fx|grep -v Serial|awk '{if($5!="-")print stname,$2,$5}' stname=$STNAME >$TMPFILEC
cat $TMPFILEC|awk '{if(length($2)==3)$2="0"$2;if(length($2)==2)$2="00"$2;if(length($2)==1)$2="000"$2}''{printf"%s,%s,%s\n",$1,$2,$3}'>$TMPFILED
cat $TMPFILEB|while read poolinfo
do
POOLID=`echo $poolinfo|awk '{print $1}'`
POOLNAME=`echo $poolinfo|awk '{print $2}'`
cat $TMPFILED|sed 's/,/ /g'|awk '{if($3==poolid)$3=poolname}''{print $1,$2,$3}' poolid=$POOLID poolname=$POOLNAME >$TMPFILEE
mv $TMPFILEE $TMPFILED
done
cat $TMPFILED|awk '{print $1","$2","$3}' >>$PLDEVPOOLINFOFILE
$RAIDCOM -logout
done
echo "`date +%Y%m%d%H%M%S`:GetPoolLdevinfo:VLDEVPOOLINFOFILE is [ $VLDEVPOOLINFOFILE ] ."
echo "`date +%Y%m%d%H%M%S`:GetPoolLdevinfo:PLDEVPOOLINFOFILE is [ $PLDEVPOOLINFOFILE ] ."
>$TMPFILEA
>$TMPFILEB
>$TMPFILEC
>$TMPFILED
>$TMPFILEE
echo "`date +%Y%m%d%H%M%S`:GetPoolLdevinfo:Get ldevpool info progress END ."
echo "###################################################################"
}
func_rmtmpfile()
{
rm $TMPFILEA >/dev/null 2>&1
rm $TMPFILEB >/dev/null 2>&1
rm $TMPFILEC >/dev/null 2>&1
rm $TMPFILED >/dev/null 2>&1
rm $TMPFILEE >/dev/null 2>&1
rm $TMPFILEF >/dev/null 2>&1
rm $TMPFILEG >/dev/null 2>&1
rm $TMPFILEH >/dev/null 2>&1
rm $TMPFILEI >/dev/null 2>&1
rm $PORTLISTFILE >/dev/null 2>&1
rm $PORTLDEVINFOFILE >/dev/null 2>&1
rm $PORTHGINFOFILE >/dev/null 2>&1
rm $UNUSEDLDEVFILE >/dev/null 2>&1
rm $HORCMSTATUSFILE >/dev/null 2>&1
}
######## func_help_info START #################################
func_help_info()
{
echo "-----------HORCMD Operation Start ------------------------"
echo "1)hdsop.sh -t checkhorcmd # query all horcmd's status ."
echo "2)hdsop.sh -t starthorcmd [ -s \$HORCMNUM ] # start horcmd,default is all, -s specify one horcmd ."
echo "3)hdsop.sh -t shutdownhorcmd [ -s \$HORCMNUM ] # shutdown horcmd,default is all, -s specify one horcmd ."
echo "-----------HORCMD Operation End ------------------------"
echo ""
echo "-----------POOL Operation Start ------------------------"
echo "4)hdsop.sh -t poolusage [ -s \$HORCMNUM ] # query storage's poolinfo. default is all, -s specify one horcmd ."
echo "15)hdsop.sh -t fmcpoolusage [ -s \$HORCMNUM ] # query storage's fmcpoolinfo. default is all, -s specify one horcmd ."
echo "-----------POOL Operation End ------------------------"
echo ""
echo "-----------HG Operation Start ------------------------"
echo "5)hdsop.sh -t gethginfo < -s \$HORCMNUM > [-p \$PORTLIST] # query one storage's hg info . 0 for all storage."
echo " -p : PORTLIST AS [ 1A,2A ] .get spefify port's hginfo"
echo "-----------HG Operation Start ------------------------"
echo "6)hdsop.sh -t getinfoforopcm < -s \$HORCMNUM > # query one storage's hg info . 0 for all storage."
echo " -s : HORCMNUM=0 for all storage."
echo " -s : HORCMNUM=XX for specify storage."
echo "7)hdsop.sh -t createhg <-s \$HORCMNUM> <-n \$HGNAME> <-o \$OSTYPE> <-p \$PORTLIST> <-v Y|N> <-c Y|N > # create one storage's hg ."
echo " -o : OSTYPE as [ HP-UX|SOLARIS|AIX|WIN|LINUX/IRIX|TRU64|DYNIX|OVMS|NETWARE|HI-UX|VMWARE|VMWARE_EX|WIN_EX|UVM ]."
echo " -s : Specify one storage ."
echo " -n : Define hgname ."
echo " -p : PORTLIST AS [ 1A,2A ] ."
echo " -v : For VCS or NOT."
echo " -c : For SVC or NOT."
echo " Example:hdsop.sh -t createhg -s 12 -n hg_test -o HP-UX -p 1A,2A -v Y -c N"
echo "8)hdsop.sh -t deletehg <-s \$HORCMNUM> <-n \$HGNAME> <-p \$PORTLIST> # delete hostgroup"
echo " -s : Specify one storage ."
echo " -n : Define hgname ."
echo " -p : PORTLIST AS [ 1A,2A ] ."
echo "9)hdsop.sh -t addhbawwn <-s \$HORCMNUM> <-n \$HGNAME> <-p \$PORTLIST> <-w \$HBAWWN> <-a \$HOSTALIAS> # create one storage's hg ."
echo " -s : Specify one storage ."
echo " -n : hgname(exist already) ."
echo " -p : PORTLIST AS [ 1A ] ,ONLY FOR SINGLE ONE . NOT SUPPORT MORE PORT ONE TIME ."
echo " -w : hbawwn ."
echo " -a : hostalias ."
echo " Example:hdsop.sh -t addhbawwn -s 12 -n hg_test -p 1A -w 2100001b320495c5 -a G4AS7080_HBA3"
echo "10)hdsop.sh -t deletehbawwn <-s \$HORCMNUM> <-n \$HGNAME> <-p \$PORTLIST> <-w \$HBAWWN> # create one storage's hg ."
echo " -s : Specify one storage ."
echo " -n : hgname(exist already) ."
echo " -p : PORTLIST AS [ 1A ] ,ONLY FOR SINGLE ONE . NOT SUPPORT MORE PORT ONE TIME ."
echo " -w : hbawwn ."
echo " Example:hdsop.sh -t deletehbawwn -s 12 -n hg_test -p 1A -w 2100001b320495c5"
echo "-----------HG Operation End ------------------------"
echo "-----------LDEV Operation Start ------------------------"
echo "11)hdsop.sh -t creteldev <-s \$HORCMNUM> <-b \$POOLNAME> <-l \$LDEVNAME> <-d \$LDEVSIZE> # create ldev from pool ."
echo " -s : Specify one storage ."
echo " -b : poolname ."
echo " -l : ldev name ."
echo " -d : ldev size ."
echo " Example:hdsop.sh -t creteldev -s 12 -b MIX01_DATA -l 1121 -d 545259520"
echo "12)hdsop.sh -t mapldev <-s \$HORCMNUM> <-p \$PORTNAME> <-n \$HGNAME> <-l \$LDEVNAME> # create ldev from pool ."
echo " -s : Specify one storage ."
echo " -p : portname ."
echo " -n : hgname ."
echo " -l : ldev name ."
echo " Example:hdsop.sh -t mapldev -s 12 -p 1A -n testhg -l 1121"
echo "13)hdsop.sh -t listmapldev<-s \$HORCMNUM> <-p \$PORTNAME> <-n \$HGNAME> # list ldevlist"
echo " -s : Specify one storage ."
echo " -p : portname ."
echo " -n : hgname ."
echo " Example:hdsop.sh -t listmapldev -s 12 -p 1A -n testhg"
echo "14)hdsop.sh -t unmapldev <-s \$HORCMNUM> <-p \$PORTNAME> <-n \$HGNAME> <-l \$LDEVNAME> # create ldev from pool ."
echo " -s : Specify one storage ."
echo " -p : portname ."
echo " -n : hgname ."
echo " -l : ldev name ."
echo " Example:hdsop.sh -t unmapldev -s 12 -p 1A -n testhg -l 1121"
echo "-----------LDEV Operation End ------------------------"
}
######## func_help_info END ###################################
#############main###############
while getopts t:s:i:v:n:o:p:b:l:c:a:w:d:h OPTION
do
case $OPTION in
a) HOSTALIAS=$OPTARG
;;
b) POOLNAME=$OPTARG
;;
c) SVCVALUE=$OPTARG
;;
d) LDEVSIZE=$OPTARG
;;
l) LDEVNAME=$OPTARG
;;
t) TYPE=$OPTARG
;;
s) HORCMNUM=$OPTARG
;;
n) HGNAME=$OPTARG
;;
o) OSTYPE=$OPTARG
;;
p) PORTLIST=$OPTARG
;;
v) VCSVALUE=$OPTARG
;;
w) HBAWWN=$OPTARG
;;
i) ACTION=$OPTARG
;;
h) func_help_info
;;
*) echo "Error: use -h for help"
exit 1
;;
esac
done
if [ "$TYPE"x != "x" ]
then
case $TYPE in
checkhorcmd)
func_CheckHorcmd
func_rmtmpfile
;;
starthorcmd)
func_StartHorcmd $HORCMNUM
func_rmtmpfile
;;
shutdownhorcmd)
func_ShutdownHorcmd $HORCMNUM
func_rmtmpfile
;;
poolusage)
func_GetPoolUsage $HORCMNUM
func_rmtmpfile
;;
fmcpoolusage)
func_GetFMCUsage $HORCMNUM
;;
gethginfo)
func_GetHginfo $HORCMNUM
func_rmtmpfile
;;
getinfoforopcm)
rm /tmp/*opcm
func_GetHginfo
func_GetPLDEVinfo
func_GetPoolLdevinfo
func_rmtmpfile
chmod 666 /tmp/*opcm
;;
createhg)
func_CreateHg $HORCMNUM $HGNAME $OSTYPE $PORTLIST $VCSVALUE $SVCVALUE
func_rmtmpfile
;;
addhbawwn)
func_MapHost $HORCMNUM $PORTLIST $HGNAME $HOSTALIAS $HBAWWN
func_rmtmpfile
;;
deletehbawwn)
func_UnmapHost
func_rmtmpfile
;;
deletehg)
func_DelHg $HORCMNUM $HGNAME $PORTLIST
func_rmtmpfile
;;
creteldev)
echo $POOLNAME
func_CreateLdevFromPool $HORCMNUM $POOLNAME $LDEVNAME $LDEVSIZE
func_rmtmpfile
;;
mapldev)
func_MapLdev $HORCMNUM $PORTLIST $HGNAME $LDEVNAME
func_rmtmpfile
;;
listmapldev)
func_ListMappedLdev $HORCMNUM $PORTLIST $HGNAME
func_rmtmpfile
;;
unmapldev)
func_UnmapLdev $HORCMNUM $PORTLIST $HGNAME $LDEVNAME
func_rmtmpfile
;;
*) echo "Error: use -h for help"
func_rmtmpfile
exit 1
;;
esac
fi
if [ "$1"x = "x" ]
then
func_help_info
func_rmtmpfile
fi