升完后可以校验版本正确性,以及BMC状态,升级之前先检验BMC版本是否符合
#!/bin/bash
function check_ping(){
for p in `cat IPlist.txt | awk '{print $1}'`;do
ping -c 1 $p > /dev/null
if [ $? -eq 0 ];then
echo "ping $p success!" | tee -a CheckUpdateLog-$t/CheckPing.log
else
echo "ping $p fail,the server need AC for cpld update," | tee -a CheckUpdateLog-$t/CheckBmcPing.log
flag_ping=false
fi
done
}
###########不同机型使用不同的升级文件####################
function update_R4950(){
echo "Updating R4950 G5 CPLD...please wait"
nohup ./update.sh --cpld_fw='RS4M2C9S1000A.bin' --number=$1 &
sleep 400s
echo "CPLD update finished,Begin update R4950 G5 PFRCPLD...please wait"
nohup ./update.sh --pfrcpld_fw='RS4M2C9S1100A.bin' --number=$1 &
sleep 400s
echo "PFRCPLD update finished,Begin check CPLD&PFRCPLD update successfully or not"
}
function update_R4930(){
echo "Updating R4930 G5 CPLD...please wait"
nohup ./update.sh --cpld_fw='RS4M2C5S03006.bin' --number=$1 &
sleep 400s
echo "CPLD update finished,Begin update R4930 G5 PFRCPLD...please wait"
nohup ./update.sh --pfrcpld_fw='RS4M2C5S04006.bin' --number=$1 &
sleep 400s
echo "PFRCPLD update finished,Begin check CPLD&PFRCPLD update successfully or not"
}
#############################################
function check_update(){
for p in `cat IPlist.txt | awk '{print $1}'`;do
if [ -f log/$p/CPLD/status.txt ];then
result_cpld=`cat log/$p/CPLD/status.txt | grep "upgrade finished for CPLD" | wc -l`
sn_cpld=`cat log/$p/CPLD/status.txt | grep "the serial number" |awk '{print $8}'| uniq`
if [[ $result_cpld -ne 0 ]];then
echo "$p , $sn_cpld CPLD update finished " >> CheckUpdateLog-$t/UpdateSuccess.log
else
echo " $p update CPLD failed, the sn is $sn_cpld" | tee -a CheckUpdateLog-$t/UpdateFailed.log
flag_update=false
fi
fi
if [ -f log/$p/PFRCPLD/status.txt ];then
result_pfrcpld=`cat log/$p/PFRCPLD/status.txt | grep "upgrade finished for PFRCPLD" | wc -l`
sn_pfrcpld=`cat log/$p/PFRCPLD/status.txt | grep "the serial number" |awk '{print $8}' | uniq`
if [[ $result_pfrcpld -ne 0 ]];then
echo " $p,$sn_pfrcpld update finished " >> CheckUpdateLog-$t/UpdateSuccess.log
else
echo "$p update PFRCPLD failed,the sn is $sn_pfrcpld" | tee -a CheckUpdateLog-$t/UpdateFailed.log
flag_update=false
fi
fi
done
}
function reset_CPLD(){
while read LINE;do
{
[[ "$LINE" == "" ]] && continue
host=`echo $LINE | awk '{print $1}'`
user=`echo $LINE | awk '{print $2}'`
passwd=`echo $LINE | awk '{print $3}'`
ipmitool -I lanplus -H $host -U $user -P $passwd raw 0x36 0x02 0x20 0x14 0x00 0x80 0xfc 0x00 > /dev/null 2>&1 &
}
done < IPlist.txt
}
##############新增抓取升级后CPLD和PFRCPLD版本############
function check_Cpldversion(){
while read LINE
do
{
[[ "$LINE" == "" ]] && continue
host=`echo $LINE | awk '{print $1}'`
user=`echo $LINE | awk '{print $2}'`
passwd=`echo $LINE | awk '{print $3}'`
cpld_ver=` ./../hREST_Linux_V1.14/bin/hREST -H $host -U $user -P $passwd getfwv |grep -i MainBoard_CPLD -A 2 | grep Version | awk '{print $3}'`
tmp_pfrcpld_ver=`ipmitool -I lanplus -H $host -U $user -P $passwd raw 0x32 0xb4 0x00 0x01 | awk '{print $13}' | sed -n '1p' |tr a-z A-Z`
pfrcpld_ver=V0$tmp_pfrcpld_ver
echo "$host CPLD version is $cpld_ver"
echo "$host PFRCPLD version is $pfrcpld_ver"
}
done < IPlist.txt
}
###########################################################
function check_Bmcversion(){
while read LINE
do
{
[[ "$LINE" == "" ]] && continue
host=`echo $LINE | awk '{print $1}'`
user=`echo $LINE | awk '{print $2}'`
passwd=`echo $LINE | awk '{print $3}'`
version=`ipmitool -I lanplus -H $host -U $user -P $passwd fru print | grep -i MB_BMC -A 5 | grep Version | awk '{print $4}'| cut -c 1-4 | sed 's/\.//g'`
if [[ $version -lt 297 ]];then
flag_version=false
echo "$host BMC version need to update to 2.97.02 firstly !!!" >> CheckUpdateLog-$t/BmcVersionCheck.log
fi
}
done < IPlist.txt
}
t=`date +%Y-%m-%d-%H:%M:%S`
mkdir CheckUpdateLog-$t
touch CheckUpdateLog-$t/CheckBmcPing.log
touch CheckUpdateLog-$t/UpdateSuccess.log
touch CheckUpdateLog-$t/UpdateFailed.log
touch CheckUpdateLog-$t/BmcVersionCheck.log
flag_version=true
flag_update=true
flag_ping=true
check_Bmcversion
if $flag_version;then
echo "HDM version is OK!!"
#echo "$host"
model=` ./../hREST_Linux_V1.14/bin/hREST -H $host -U $user -P $passwd getproductinfo | grep -i Model | awk '{print $5,$6}'`
if [ "$model" = "R4950 G5" ];then
echo "OK,Begin update R4950 G5 CPLD&PFRCPLD"
update_R4950
elif [ "$model" = "R4930 G5" ];then
echo "OK,Begin update R4930 G5 CPLD&PFRCPLD"
update_R4930
else
echo "$model No need to update,exit!!"
exit
fi
check_update
if $flag_update;then
echo "ALL servers update Successfully,begin reset cpld ....After 8min ,we will check BMC network state "
sleep 30s
reset_CPLD
sleep 400s
echo "reset CPLD is OK ,now check BMC network state"
check_ping
if $flag_ping;then
echo "BMC network state is OK,check CPLD version!"
check_Cpldversion
else
echo "Some servers IP connect failed,maybe resetCPLD failed,Please check CheckUpdateLog-$t/CheckBmcPing.log and contact H3C supporter !!!"
fi
else
echo "Please check CheckUpdateLog-$t/UpdateFailed.log,some servers IP update failed,please collect SDS log and contact H3C supporter !!!"
fi
else
echo "BMC version is wrong!!!Please check CheckUpdateLog-$t/BmcVersionCheck.log for ip and update BMC version to 2.97.02"
fi
网友评论