1.要求先配置好horcm;2.存储清单文件STLISTFILE需根据实际情况更改,格式如下,可自行根据需要更改格式和脚本中的引用。GL_VSP_210     GL      PRD     JT      55034          horcm9         1       onGL_G1000_503   GL      PRD     JT      50990          horcm15        1       on3.实现的功能看具体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:$PATHCMDPWD=/HORCM/usr/binETCPWD=/HORCM/usr/bin/custom/etcRAIDCOM=$CMDPWD/raidcomSTLISTFILE=$ETCPWD/stlistfilePOOLINFO=/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 startPORTINFOFILE=/tmp/hdsop_PORTINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcmRGINFOFILE=/tmp/hdsop_RGINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcmPLDEVRGINFOFILE=/tmp/hdsop_PLDEVRGINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcmVLDEVPOOLINFOFILE=/tmp/hdsop_VLDEVPOOLINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcmPLDEVPOOLINFOFILE=/tmp/hdsop_PLDEVPOOLINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcmHGHOSTINFOFILE=/tmp/hdsop_HGHOSTINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcmHGLDEVINFOFILE=/tmp/hdsop_HGLDEVINFOFILE.`date +%y%m%d%H%M%S`.`uname -n`.opcm#for opcm endchmod 666 /tmp/hdsop*HNAME=`hostname`##user only checkCHKUSERNAME=userCHKUSERPWD=password##user can operateSTADMINUSER=stadminSTADMINPWD=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 noneHORCMNUM=$1NEWHGNAME=$2HOSTMODE=$3PORTLIST=$4VCSVALUE=$5SVCVALUE=$6OSTYPE=$3if [ $HORCMNUM"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HORCMNUM INPUT, EXIT NOW .";fiif [ $HORCMNUM"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $NEWHGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO NEWHGNAME INPUT, EXIT NOW.";fiif [ $NEWHGNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO NEWHGNAME INPUT, EXIT NOW.">>$LOGFILE;return;fiif [ $HOSTMODE"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HOSTMODE INPUT, EXIT NOW .";fiif [ $HOSTMODE"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO HOSTMODE INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $PORTLIST"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO PORTLIST INPUT, EXIT NOW .";fiif [ $PORTLIST"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $VCSVALUE"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO VCSVALUE INPUT, EXIT NOW .";fiif [ $VCSVALUE"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO VCSVALUE INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $SVCVALUE"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO SVCVALUE INPUT, EXIT NOW .";fiif [ $SVCVALUE"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:CreateHg:NO SVCVALUE INPUT, EXIT NOW .">>$LOGFILE;return;fiexport HORCMINST=$HORCMNUMecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -loginrm $TMPFILEEHOSTMODEOPT=""if [ $VCSVALUE = "Y" ]       ; then HOSTMODEOPT="2"               ; fiif [ $OSTYPE = "AIX" ]       ; then HOSTMODEOPT="$HOSTMODEOPT 22" ; fiif [ $SVCVALUE = "Y" ]       ; then HOSTMODEOPT="$HOSTMODEOPT 39" ; fiif [ $OSTYPE = "VMWARE" ]    ; then HOSTMODEOPT="$HOSTMODEOPT 54" ; fiif [ $HOSTMODEOPT"x" = "x" ] ; then $HOSTMODEOPT=100              ; fiecho $PORTLIST|sed 's/,/ /g'|xargs -n1|while read namedoNUM=`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 $NEWHGNAMEecho "[`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 $HOSTMODEOPTecho "#################################################################"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##Example: func_MapHost 12 1A hg_test_wangtao G4AH7020_HBA0 5001438001189C14##func_MapHost $HORCMNUM $PORTLIST $HGNAME $HOSTALIAS $HBAWWNHORCMNUM=$1PORTLIST=$2HGNAME=$3HOSTALIAS=$4HBAWWN=$5if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HORCMNUM INPUT, EXIT NOW  .";fiif [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HORCMNUM INPUT, EXIT NOW  .">>$LOGFILE;return;fiif [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO PORTLIST INPUT, EXIT NOW  .";fiif [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO PORTLIST INPUT, EXIT NOW  .">>$LOGFILE;return;fiif [ $HGNAME"x" = "x" ]   ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HGNAME INPUT, EXIT NOW    .";fiif [ $HGNAME"x" = "x" ]   ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HGNAME INPUT, EXIT NOW    .">>$LOGFILE;return;fiif [ $HBAWWN"x" = "x" ]   ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HBAWWN INPUT, EXIT NOW    .";fiif [ $HBAWWN"x" = "x" ]   ;then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HBAWWN INPUT, EXIT NOW    .">>$LOGFILE;return;fiif [ $HOSTALIAS"x" = "x" ];then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HOSTALIAS INPUT, EXIT NOW .";fiif [ $HOSTALIAS"x" = "x" ];then echo "`date +%Y%m%d%H%M%S`:MapHost:NO HOSTALIAS INPUT, EXIT NOW .">>$LOGFILE;return;fiexport HORCMINST=$HORCMNUMecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -login >/dev/nullrm $TMPFILEEPORTNAME=$PORTLISTecho "`date +%Y%m%d%H%M%S`:MapHost:Before ADD"echo "`date +%Y%m%d%H%M%S`:MapHost:Before ADD" >>$LOGFILEecho "`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`>>$LOGFILEecho "`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 $HOSTALIASecho "`date +%Y%m%d%H%M%S`:MapHost:$RAIDCOM set hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN -wwn_nickname $HOSTALIAS"  >>$LOGFILEecho "`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 1090519680HORCMNUM=$1POOLNAME=$2LDEVNAME=$3LDEVSIZE=$4if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HORCMNUM INPUT, EXIT NOW .";return;fiif [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $POOLNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO PORTLIST INPUT, EXIT NOW .";return;fiif [ $POOLNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $LDEVNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HBAWWN INPUT, EXIT NOW .";return;fiif [ $LDEVNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HBAWWN INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $LDEVSIZE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HOSTALIAS INPUT, EXIT NOW .";return;fiif [ $LDEVSIZE"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:CreateLdevFromPool:NO HOSTALIAS INPUT, EXIT NOW .">>$LOGFILE;return;fiecho $POOLNAMEexport HORCMINST=$HORCMNUMecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -login >/dev/nullSTNAME=`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/nullecho "raidcom logout ."}func_ListMappedLdev(){##Status:done##Usage:##func_MapLdev##Example: func_MapLdev 12 1A hg_test_wangtao 003eHORCMNUM=$1PORTLIST=$2HGNAME=$3LUNNAME_A=$4if [ $HORCMNUM"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .";fiif [ $HORCMNUM"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $HGNAME"x" = "x" ]    ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW   .";fiif [ $HGNAME"x" = "x" ]    ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW   .">>$LOGFILE;return;fiif [ $PORTLIST"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .";fiif [ $PORTLIST"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fiLUNNAME_B=`echo $LUNNAME_A|tr a-z A-Z`LDEVNAME=`echo "ibase=16;$LUNNAME_B"|bc`export HORCMINST=$HORCMNUMif [ $HORCMNUM"x" = "x" ] ;then echo "NO HORCMNUM INPUT, EXIT NOW .";return;fiAA=`echo $PORTLIST|cut -c 1`BB=`echo $PORTLIST|cut -c 2`PORTNAME=CL$AA"-"$BBecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -login >/dev/nullecho "`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##Example: func_MapLdev 12 1A hg_test_wangtao 003eHORCMNUM=$1PORTLIST=$2HGNAME=$3LUNNAME_A=$4if [ $HORCMNUM"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .";fiif [ $HORCMNUM"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HORCMNUM INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $HGNAME"x" = "x" ]    ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW   .";fiif [ $HGNAME"x" = "x" ]    ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO HGNAME INPUT, EXIT NOW   .">>$LOGFILE;return;fiif [ $PORTLIST"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .";fiif [ $PORTLIST"x" = "x" ]  ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO PORTLIST INPUT, EXIT NOW .">>$LOGFILE;return;fiif [ $LUNNAME_A"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO LUNNAME INPUT, EXIT NOW  .";fiif [ $LUNNAME_A"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:MapLdev:NO LUNNAME INPUT, EXIT NOW  .">>$LOGFILE;return;fiLUNNAME_B=`echo $LUNNAME_A|tr a-z A-Z`LDEVNAME=`echo "ibase=16;$LUNNAME_B"|bc`export HORCMINST=$HORCMNUMif [ $HORCMNUM"x" = "x" ] ;then echo "NO HORCMNUM INPUT, EXIT NOW .";return;fiAA=`echo $PORTLIST|cut -c 1`BB=`echo $PORTLIST|cut -c 2`PORTNAME=CL$AA"-"$BBecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -login >/dev/nullecho "`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 $LDEVNAMEecho "`date +%Y%m%d%H%M%S`:MapLdev:$RAIDCOM add lun -port $PORTNAME $HGNAME -ldev_id $LDEVNAME ">>$LOGFILEecho "`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,2Aexport HORCMINST=$1HGNAME=$2PORTLIST=$3echo $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEecho "cat $TMPFILEE|$RAIDCOM -login >/dev/null"echo $PORTLIST|sed 's/,/ /g'|xargs -n1|while read namedoNUM=`echo $name|cut -c 1`CHAR=`echo $name|cut -c 2`PORTNAME=CL"$NUM"-"$CHAR"echo $RAIDCOM get host_grp -port $PORTNAMEecho $RAIDCOM delete host_grp -port $PORTNAME $HGNAMEecho $RAIDCOM get host_grp -port $PORTNAMEdoneecho "$RAIDCOM -logout"}func_UnmapHost(){##Status:done##Usage:##func_UnmapHost##hdsop.sh -t deletehbawwn##Example: func_UnmapHost 12 1A hg_test_wangtao 5001438001189c14HORCMNUM=$1PORTLIST=$2HGNAME=$3HBAWWN=$4if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HORCMNUM INPUT, EXIT NOW .";return;fiif [ $PORTLIST"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO PORTLIST INPUT, EXIT NOW .";return;fiif [ $HGNAME"x" = "x" ]   ;then echo "`date +%Y%m%d%H%M%S`:NO HGNAME INPUT, EXIT NOW .";return;fiif [ $HBAWWN"x" = "x" ]   ;then echo "`date +%Y%m%d%H%M%S`:NO HBAWWN INPUT, EXIT NOW .";return;fiexport HORCMINST=$HORCMNUMecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -login >/dev/nullAA=`echo $PORTLIST|cut -c 1`BB=`echo $PORTLIST|cut -c 2`PORTNAME=CL$AA"-"$BBecho "Before DELETE"$RAIDCOM get hba_wwn -port $PORTNAME $HGNAMEecho "###########################################"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 $HBAWWNecho $RAIDCOM get hba_wwn  -port $PORTNAME $HGNAMEecho "$RAIDCOM -logout >/dev/null"#$RAIDCOM delete hba_wwn -port $PORTNAME $HGNAME -hba_wwn $HBAWWN#echo "After DELETE"#$RAIDCOM get hba_wwn  -port $PORTNAME $HGNAMEecho "###########################################"$RAIDCOM -logout}func_UnmapLdev(){##Status:done##Usage:##func_UnmapLdev##Example: func_UnmapLdev 12 1A hg_test_wangtao 003eHORCMNUM=$1PORTLIST=$2HGNAME=$3LUNNAME_A=$4LUNNAME_B=`echo $LUNNAME_A|tr a-z A-Z`LDEVNAME=`echo "ibase=16;$LUNNAME_B"|bc`export HORCMINST=$HORCMNUMif [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HORCMNUM INPUT, EXIT NOW .";return;fiAA=`echo $PORTLIST|cut -c 1`BB=`echo $PORTLIST|cut -c 2`PORTNAME=CL$AA"-"$BBecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $TMPFILEE|$RAIDCOM -login >/dev/nullecho "before unmap:"$RAIDCOM get lun -port $PORTNAME $HGNAME -fx$RAIDCOM delete lun -port $PORTNAME $HGNAME -ldev_id $LDEVNAMEecho "after unmap:"$RAIDCOM get lun -port $PORTNAME $HGNAME -fx$RAIDCOM -logout >/dev/null}func_DeleteLdevFromPool(){#Status:done##Usage:##func_DeleteLdevFromPool##Example: func_DeleteLdevFromPool 12 111bHORCMNUM=$1LDEVNAME=$3if [ $HORCMNUM"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HORCMNUM INPUT, EXIT NOW .";return;fiif [ $LDEVNAME"x" = "x" ] ;then echo "`date +%Y%m%d%H%M%S`:NO HBAWWN INPUT, EXIT NOW .";return;fiecho $STADMINUSER>$TMPFILEEecho $STADMINPWD>>$TMPFILEEcat $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##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 $TMPFILESTLISTif [ $1"x" != "x" ]then  cat $STLISTFILE|grep -v ^#|grep -vi off|grep -i "horcm$HORCMNUM " >$TMPFILESTLISTelse  cat $STLISTFILE|grep -v ^#|grep -vi off>$TMPFILESTLISTfirm /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}'>$POOLINFOecho "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"}'>>$POOLINFOcat $TMPFILESTLIST|while read namedo  (  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  )&donewaitchmod 644 $POOLINFOecho "***********************************************************************************"cat $POOLINFOrm $TMPFILESTLIST}func_GetFMCUsage(){##Status:done##Usage:##func_GetPoolUsage##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 " >$TMPFILEAelse  cat $STLISTFILE|grep -v ^#|grep -vi off >$TMPFILEAfiecho "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}'>$FMCPOOLINFOcat $TMPFILEA|while read namedo  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}'doneecho "."chmod 644 $FMCPOOLINFOecho "***********************************************************************************"cat $FMCPOOLINFOecho "***********************************************************************************"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}'>$HORCMSTATUSFILEps -ef|grep horcm|grep -v grep|awk '{print $NF}'|sed 's/d_0//g' >$TMPFILEAcat $STLISTFILE|grep -v ^#|grep -vi off|grep -v STNAME|while read namedoHORNAME=`echo $name|awk '{print $6}'`VALUE=`cat $TMPFILEA|grep $HORNAME$`if [ $VALUE"x" != "x" ] ;then HORCMSTATUS=ON ;else HORCMSTATUS=OFF ; fiecho $name $HORCMSTATUS|awk '{printf "%-15s%-5s%-5s%-5s%-10s%-12s%-5s\n",$1,$2,$3,$4,$5,$6,$9}' >>$HORCMSTATUSFILEdonecat $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_CheckHorcmdecho "**********  Status of HORCMD before running startscript **********"echo "==========================="if [ $1"x" != "x" ]thenexport HORCMINST=$1$CMDPWD/horcmstart.sh $HORCMINSTelsefunc_CheckHorcmdcat $HORCMSTATUSFILE|grep OFF|awk '{print $6}'|sed 's/horcm//g'|while read NUMdoexport HORCMINST=$NUM$CMDPWD/horcmstart.sh $HORCMINSTdonefiecho "==========================="echo "**********  Status of HORCMD after running startscript **********"func_CheckHorcmdecho "**********  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_CheckHorcmdecho "**********  Status of HORCMD before running shutdonwscript **********"echo "==========================="if [ $1"x" != "x" ]then  export HORCMINST=$1  $CMDPWD/horcmshutdown.sh $HORCMINSTelse  cat $HORCMSTATUSFILE|grep ON|awk '{print $6}'|sed 's/horcm//g'|while read NUM  do    export HORCMINST=$NUM    $CMDPWD/horcmshutdown.sh $HORCMINST  donefiecho "==========================="echo "**********  Status of HORCMD after running shutdonwscript **********"func_CheckHorcmdecho "**********  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 $TMPFILESTLISTecho "###################################################################"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;fiif [ $HORCMNUM"x" = "0x" ]then  cat $STLISTFILE|grep -v ^#|grep -vi off|awk '{print $6}'|sed 's/horcm//g' >$TMPFILESTLISTelse  echo $HORCMNUM >$TMPFILESTLISTfiecho "STNAME,STSN,PORTNAME,PORTWWN">$PORTINFOFILEecho "STNAME,PORTNAME,PORTWWN,HGNAME,HOSTWWN,HOSTALI">$HGHOSTINFOFILEecho "STNAME,PORTNAME,PORTWWN,HGNAME,LDEVNAME,HLUN">$HGLDEVINFOFILEcat $TMPFILESTLIST|while read namedo  (  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  )&donewaitecho $PORTINFOFILEecho $HGHOSTINFOFILEecho $HGLDEVINFOFILEecho "`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;fiif [ $HORCMNUM"x" = "0x" ]then  cat $STLISTFILE|grep -v ^#|grep -vi off|awk '{print $6}'|sed 's/horcm//g' >$TMPFILEAelse  echo $HORCMNUM >$TMPFILEAfiecho "STNAME,RGNAME,RGTYPE,RGSIZE">$RGINFOFILEecho "STNAME,RGNAME,PLDEVNAME,UDID,PLDEVSIZE">$PLDEVRGINFOFILEcat $TMPFILEA|while read namedo  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 >>$PLDEVRGINFOFILEdoneecho "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:RGINFOFILE          is [ $RGINFOFILE ] ."echo "`date +%Y%m%d%H%M%S`:GetPLDEVinfo:PLDEVRGINFOFILEFILE is [ $PLDEVRGINFOFILE ] .">$TMPFILEA;>$TMPFILEBecho "`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;fiif [ $HORCMNUM"x" = "0x" ]then  cat $STLISTFILE|grep -v ^#|grep -vi off|awk '{print $6}'|sed 's/horcm//g' >$TMPFILEAelse  echo $HORCMNUM >$TMPFILEAfiecho "STNAME,VLDEVNAME,UDID,VLDEVSIZE,POOLNAME">$VLDEVPOOLINFOFILEecho "STNAME,PLDEVNAME,POOLNAME">$PLDEVPOOLINFOFILEcat $TMPFILEA|while read namedo  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 -logoutdoneecho "`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>$TMPFILEEecho "`date +%Y%m%d%H%M%S`:GetPoolLdevinfo:Get ldevpool info progress END ."echo "###################################################################"}func_rmtmpfile(){rm $TMPFILEA          >/dev/null 2>&1rm $TMPFILEB          >/dev/null 2>&1rm $TMPFILEC          >/dev/null 2>&1rm $TMPFILED          >/dev/null 2>&1rm $TMPFILEE          >/dev/null 2>&1rm $TMPFILEF          >/dev/null 2>&1rm $TMPFILEG          >/dev/null 2>&1rm $TMPFILEH          >/dev/null 2>&1rm $TMPFILEI          >/dev/null 2>&1rm $PORTLISTFILE      >/dev/null 2>&1rm $PORTLDEVINFOFILE  >/dev/null 2>&1rm $PORTHGINFOFILE    >/dev/null 2>&1rm $UNUSEDLDEVFILE    >/dev/null 2>&1rm $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 [-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        # 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   # 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 # delete hostgroup"  echo "  -s : Specify one storage ."  echo "  -n : Define hgname ."  echo "  -p : PORTLIST AS [ 1A,2A ] ."  echo "9)hdsop.sh -t addhbawwn   # 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   # 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   # 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   # 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    # 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   # 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 OPTIONdo    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           ;;    esacdoneif [ "$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        ;;  esacfiif [ "$1"x = "x" ]thenfunc_help_infofunc_rmtmpfilefi
10-17 18:50