2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00

implement a script to achieve retry mechanism against rinstall

This commit is contained in:
litingt 2019-01-11 02:53:29 -05:00
parent de351fbd47
commit e2939f6605

View File

@ -0,0 +1,60 @@
#!/bin/bash
echo "Try to retry rinstall 5 times ......"
declare -i installsuccess=0
declare -i a=0
declare -i tryreinstall=1
node=$1
osimage=$2
for (( tryreinstall = 1 ; tryreinstall < 6 ; ++tryreinstall ))
do
echo "Try to install $node on the $tryreinstall time..."
echo "rinstall $node osimage=$osimage"
rinstall $node osimage=$osimage
if [ $? != 0 ];then
echo "rinstall failed, double check xcat command rinstall to see if it is a bug..."
exit 1
fi
#sleep while for installation.
sleep 360
while [ ! `lsdef -l $node|grep status|grep booted` ]
do
sleep 10
echo "The status is not booted..."
a=++a
if [ $a -gt 400 ];then
a=0
break
fi
done
lsdef -l $node|grep status|grep booted
tobooted=$?
echo "The tobooted is $tobooted"
ping -c 2 $node
pingable=$?
echo "The pingable is $pingable"
xdsh $node date
canruncmd=$?
echo "The canruncmd is $canruncmd"
if [[ $canruncmd -eq 0 && $tobooted -eq 0 && $pingable -eq 0 ]];then
echo "The provision succeed on the $tryreinstall time....."
installsuccess=1
break
fi
done
if [ $installsuccess -eq 1 ];then
echo "The provision succeed......"
exit 0
else
echo "The provision failed......"
exit 1
fi