diff --git a/xCAT-test/autotest/testcase/genesis/test.sh b/xCAT-test/autotest/testcase/genesis/test.sh index 242f1d141..d528a3395 100755 --- a/xCAT-test/autotest/testcase/genesis/test.sh +++ b/xCAT-test/autotest/testcase/genesis/test.sh @@ -15,26 +15,26 @@ function runcmd(){ fi } -function check_destiny(){ -cmd="chdef testnode arch=ppc64le cons=ipmi groups=all ip=60.1.1.1 mac=4e:ee:ee:ee:ee:0e netboot=$NETBOOT"; -runcmd $cmd; -masterip=`lsdef -t site -i master -c 2>&1 | awk -F'=' '{print $2}'`; -masternet=`ifconfig | awk "BEGIN{RS=\"\"}/\<$masterip\>/{print \$1}"|head -n 1 | awk -F ' ' '{print $1}'|awk -F ":" '{print \$1}' 2>&1`; -net2=`netstat -i -a|grep -v Kernel|grep -v Iface |grep -v lo|grep -v $masternet|head -n 1|awk '{print $1}'`; -net2ip=""; +function check_destiny() { + cmd="chdef testnode arch=ppc64le cons=ipmi groups=all ip=60.1.1.1 mac=4e:ee:ee:ee:ee:0e netboot=$NETBOOT"; + runcmd $cmd; + masterip=`lsdef -t site -i master -c 2>&1 | awk -F'=' '{print $2}'`; + masternet=`ifconfig | awk "BEGIN{RS=\"\"}/\<$masterip\>/{print \$1}"|head -n 1 | awk -F ' ' '{print $1}'|awk -F ":" '{print \$1}' 2>&1`; + net2=`netstat -i -a|grep -v Kernel|grep -v Iface |grep -v lo|grep -v $masternet|head -n 1|awk '{print $1}'`; + net2ip=""; if [[ -z $net2 ]];then echo "There is no second network, could not verify the test" return 1; else net2ipstring=`ifconfig $net2 |grep inet|grep -v inet6`; - if [[ $? -eq 0 ]];then - net2ip=`ifconfig $net2 |grep inet|grep -v inet6|awk -F ' ' '{print $2}'|awk -F ":" '{print $2}'`; - if [[ -z $net2ip ]];then - net2ip=`ifconfig $net2 |grep inet|grep -v inet6|awk -F ' ' '{print $2}'`; - fi - else - net2ip=0.0.0.0; + if [[ $? -eq 0 ]];then + net2ip=`ifconfig $net2 |grep inet|grep -v inet6|awk -F ' ' '{print $2}'|awk -F ":" '{print $2}'`; + if [[ -z $net2ip ]];then + net2ip=`ifconfig $net2 |grep inet|grep -v inet6|awk -F ' ' '{print $2}'`; fi + else + net2ip=0.0.0.0; + fi echo "The original net2 IP is $net2ip" cmd="ifconfig $net2 60.3.3.3"; runcmd $cmd; @@ -47,58 +47,59 @@ net2ip=""; runcmd $cmd; echo "Check if nodeset testnode shell is added to $SHELLFOLDER" cat "$SHELLFOLDER"testnode |grep "xcatd=60.3.3.3:3001 destiny=shell"; - if [[ $? -eq 0 ]] ;then - return 0; - else - echo "nodeset testnode shell failed"; - return 1; - fi + if [[ $? -eq 0 ]] ;then + return 0; + else + echo "nodeset testnode shell failed"; + return 1; + fi fi } -function clear_env(){ -rmdef -t network -o 60_0_0_0-255_0_0_0 -makehosts -d testnode -rmdef testnode + +function clear_env() { + rmdef -t network -o 60_0_0_0-255_0_0_0 + makehosts -d testnode + rmdef testnode if [[ $? -eq 0 ]];then return 0; else return 1; fi } + NETBOOT="" SHELLFOLDER="" -while [ "$#" -ge "0" ] -do - case $1 in - "--check" ) - NETBOOT=$2; - if [[ $NETBOOT =~ petitboot ]];then - SHELLFOLDER="/tftpboot/petitboot/"; - elif [[ $NETBOOT =~ xnba ]];then - SHELLFOLDER="/tftpboot/xcat/xnba/nodes/" - else - SHELLFOLDER="/tftpboot/boot/grub2/"; - fi - check_destiny ; - if [[ $? -eq 1 ]];then - exit 1 - else - exit 0 - fi - ;; - "-c"|"--clear" ) - clear_env; - if [[ $? -eq 1 ]];then - exit 1 - else - exit 0 - fi - ;; - *) - echo - echo "Error: Usage: $0: -cd|-c" - echo - exit 1; - ;; - esac +while [ "$#" -ge "0" ]; do + case $1 in + "--check" ) + NETBOOT=$2; + if [[ $NETBOOT =~ petitboot ]];then + SHELLFOLDER="/tftpboot/petitboot/"; + elif [[ $NETBOOT =~ xnba ]];then + SHELLFOLDER="/tftpboot/xcat/xnba/nodes/" + else + SHELLFOLDER="/tftpboot/boot/grub2/"; + fi + check_destiny ; + if [[ $? -eq 1 ]];then + exit 1 + else + exit 0 + fi + ;; + "-c"|"--clear" ) + clear_env; + if [[ $? -eq 1 ]];then + exit 1 + else + exit 0 + fi + ;; + *) + echo + echo "Error: Usage: $0: -cd|-c" + echo + exit 1; + ;; + esac done