2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 01:26:38 +00:00

modify reventlog testcase for code change

This commit is contained in:
junxiawang 2017-09-01 09:17:48 -04:00
parent af0d99d8a3
commit 69598e0b51

View File

@ -112,55 +112,67 @@ function clear_env()
fi
return 1;
}
function change_gateway
function change_nonip
{
echo "Prepare to change gateway.";
echo "Start to check gateway valid or not.";
test_ip $1;
if [[ $? -ne 0 ]];then echo "Gateway is invalid";return 1;fi
echo "Start to change bmc's gateway.";
rspconfig $2 gateway=$1;
echo "Prepare to change $4.";
echo "Start to check $4 valid or not.";
if [[ $4 =~ "gateway" ]]||[[ $4 =~ "netmask" ]];then
test_ip $1;
if [[ $? -ne 0 ]];then
echo "$4 is invalid";
return 1;
fi
fi
echo "Start to change bmc's $4.";
rspconfig $2 $4=$1;
if [[ $? -eq 0 ]];then
echo "Could set bmc's gateway.";
else
echo "Could not set bmc's gateway.";
echo "Could set bmc's $4.";
else
echo "Could not set bmc's $4.";
return 1;
fi
echo "Start to check gateway setting successfully or not.";
check_result $2 $3 $1
if [[ $? -ne 0 ]] ;then
echo "Set bmc's gateway failed.";
return 1;
else
echo "Set bmc's gateway successfully.";
fi
echo "Start to check $4 setting successfully or not.";
check_result $2 $3 $1
if [[ $? -ne 0 ]] ;then
echo "Set bmc's $4 failed.";
return 1;
else
echo "Set bmc's $4 successfully.";
return 0;
fi
fi
}
function change_netmask
function change_all
{
echo "Prepare to change netmask";
echo "Start to check netmask valid or not.";
test_ip $1;
if [[ $? -ne 0 ]];then echo "Net mask is invalid.";return 1;fi
rspconfig $2 netmask=$1;
echo "Prepare to change all for bmc."
echo "Start to change all for bmc."
rspconfig $2 gateway netmask vlan ip
if [[ $? -eq 0 ]];then
echo "Could set bmc's netmask using rspconfig.";
else
echo "Could not set bmc's netmask using rspconfig.";
return 1;
fi
check_result $2 $3 $1
if [[ $? -ne 0 ]] ;then
echo "Set bmc's netmask failed.";
return 1;
else
echo "Set bmc's netmask successfully.";
return 0;
BMCIP=`rspconfig $2 ip |awk -F":" '{print $3}'`;
BMCNETMASK=`rspconfig $2 netmask |awk -F":" '{print $3}'`;
BMCGGATEWAY=`rspconfig $2 gateway |awk -F":" '{print $3}'`;
output=`rspconfig $2 vlan`
if [[ $output =~ "BMC VLAN ID enabled" ]];then
BMCVLAN=`rspconfig $2 vlan |awk -F":" '{print $3}'`
else
echo "------------------Bmc vlan disabled so could not change vlan id using rspconfig.--------------------"
return 1;
fi
rspconfig $2 ip=$BMCIP netmask=$BMCNETMASK gateway=$BMCGGATEWAY vlan=$BMCVLAN
if [[ $? -eq 0 ]];then
echo "Could set bmc's all options.";
else
echo "Could not set bmc's all options.";
return 1;
fi
fi
}
BMCIP=""
BMCIP_LSDEF=""
BMCGTEWAT=""
BMCNETMASK=""
BMCVLAN=""
FIRSTIP=""
LASTIP=""
NODEIP=""
@ -168,6 +180,7 @@ while [ "$#" -gt "0" ]
do
case $1 in
"-i"|"--ip" )
echo "--------------------To test bmc ip could be changed using rspconfig.--------------------"
rspconfig $2 ip
if [[ $? -eq 0 ]];then
BMCIP=`rspconfig $2 ip |awk -F":" '{print $3}'`
@ -177,44 +190,161 @@ do
fi
change_ip $BMCIP $2 $BMCNETMASK $3
if [[ $? -eq 1 ]];then
echo "--------------------To test bmc ip could be changed using rspconfig failed.--------------------"
exit 1
else
else
echo "--------------------To test bmc ip could be change using rspconfig successfully.-------------------"
exit 0
fi
;;
"-lip"|"--list ip" )
echo "--------------------To test bmc ip could be listed using rspconfig.--------------------"
BMCIP_LSDEF=`lsdef $2 |grep bmc |awk -F "=" '{print $2}'`
rspconfig $2 ip
if [[ $? -eq 0 ]];then
BMCIP=`rspconfig $2 ip |awk -F":" '{print $3}'`
if [[ $BMCIP =~ "$BMCIP_LSDEF" ]];then
echo "-----------------To test bmc ip could be listed using rspconfig successfully.-----------------"
exit 0;
else
echo "-------------------To test bmc ip could be listed using rspconfig failed.----------------"
exit 1;
fi
else
echo "------------------To test bmc ip could be listed using rspconfig failed.-------------------"
exit 1;
fi
;;
"-g"|"--gateway" )
echo "--------------------To test bmc gateway could be changed using rspconfig.---------------------"
rspconfig $2 gateway
if [[ $? -eq 0 ]];then
BMCGATEWAYE=`rspconfig $2 gateway |awk -F":" '{print $3}'`
else
exit 1;
fi
change_gateway $BMCGATEWAYE $2 $3
change_nonip $BMCGATEWAYE $2 $3 gateway
if [[ $? -eq 1 ]];then
echo "--------------------To test bmc gateway could be changed using rspconfig failed.--------------------"
exit 1
else
echo "--------------------To test bmc gateway could be changed using rspconfig successfully.--------------------"
exit 0
fi
;;
"-lg"|"--list gateway" )
output=rpconfig $2 gateway
if [[ $? -eq 0 ]];then
if [[ $output =~ "$2 BMC Gateway:" ]];then
echo "-------------------To test bmc gateway could be listed using rspconfig successfully.-----------------"
exit 0;
else
echo "-----------------To test bmc gateway could be listed using rsconfig failed.-------------------"
exit 1;
fi
else
echo "-------------------To test bmc gateway could be listed using rspconfig failed.---------------"
exit 1;
fi
;;
"-n"|"--netmask" )
rspconfig $2 netmask
echo "---------------------To test bmc netmask could be changed using rspconfig.--------------------"
if [[ $? -eq 0 ]];then
BMCNETMASK=`rspconfig $2 netmask |awk -F":" '{print $3}'`
else
exit 1;
fi
change_netmask $BMCNETMASK $2 $3
change_nonip $BMCNETMASK $2 $3 netmask
if [[ $? -eq 1 ]];then
echo "--------------------To test bmc netmask could be changed using rspconfig failed.------------------"
exit 1
else
echo "--------------------To test bmc netmask could be changed using rspconfig successfully.-------------------"
exit 0
fi
;;
"-ln"|"--list netmask" )
output=rpconfig $2 netmask
if [[ $? -eq 0 ]];then
if [[ $output =~ "$2 BMC Netmask:" ]];then
echo "-------------------To test bmc Netmask could be listed using rspconfig successfully.-----------------"
exit 0;
else
echo "-----------------To test bmc Netmask could be listed using rsconfig failed.-------------------"
exit 1;
fi
else
echo "-------------------To test bmc Netmask could be listed using rspconfig failed.---------------"
exit 1;
fi
;;
"-v"|"--vlan" )
output=rspconfig $2 vlan
echo "---------------------To test bmc vlan could be changed using rspconfig.--------------------"
if [[ $? -eq 0 ]]&&[[ $output =~ "BMC VLAN ID enabled" ]];then
BMCVLAN=`rspconfig $2 vlan |awk -F":" '{print $3}'`
else
echo "------------------Bmc vlan disabled so could not change vlan id using rspconfig.--------------------"
exit 1;
fi
change_nonip $BMCVLAN $2 $3 vlan
if [[ $? -eq 1 ]];then
echo "--------------------To test bmc vlan could be changed using rspconfig failed.------------------"
exit 1
else
echo "--------------------To test bmc vlan could be changed using rspconfig successfully.-------------------"
exit 0
fi
;;
"-lv"|"--list vlan" )
output=rpconfig $2 vlan
if [[ $? -eq 0 ]];then
if [[ $output =~ "$2 BMC VLAN ID:" ]];then
echo "-------------------To test bmc Vlan could be listed using rspconfig successfully.-----------------"
exit 0;
else
echo "-----------------To test bmc Vlan could be listed using rsconfig failed.-------------------"
exit 1;
fi
else
echo "-------------------To test bmc Vlan could be listed using rspconfig failed.---------------"
exit 1;
fi
;;
"-a"|"--all" )
change_all $2
if [[ $? -eq 1 ]];then
echo "--------------------To test bmc's all options could be changed using rspconfig failed.------------------"
exit 1
else
echo "--------------------To test bmc's all options could be changed using rspconfig successfully.-------------------"
exit 0
fi
;;
"-la"|"--list all" )
BMCIP_LSDEF=`lsdef $2 |grep bmc |awk -F "=" '{print $2}'`
BMCIP=`rspconfig $2 ip |awk -F":" '{print $3}'`
output=rspconfig $2 ip gateway netmask vlan
if [[ $? -eq 0 ]];then
if [[ $output =~ "$2 BMC VLAN ID:" ]]&&[[ $output =~ "$2 BMC Netmask:" ]]&&[[ $output =~ "$2 BMC Gateway:" ]]&&[[ $BMCIP =~ "$BMCIP_LSDEF" ]];then
echo "------------------To test bmc's all option could be listed using rspconfig succssfully.-----------------"
exit 0
else
echo "--------------------To test bmc's all options could be listed using rspconfig failed.--------------------"
exit 1
fi
fi
;;
"-c"|"--clear" )
echo "--------------------To clear the test envionment.--------------------"
clear_env $1 $2 $3
if [[ $? -eq 1 ]];then
echo "--------------------To clear the test environment failed.-----------------"
exit 1
else
echo "--------------------To clear the test environment sucessfully.-----------------"
exit 0
fi
;;