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

Merge pull request #6361 from cxhong/50route

Use `ip addr` instead of `ifconfig` command
This commit is contained in:
Victor Hu 2019-06-24 16:51:29 -04:00 committed by GitHub
commit 0bf9d08745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,31 +30,16 @@ function check_destiny() {
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="";
echo "MASTERIP=$MASTERIP"
echo "MASTERNET=$MASTERNET"
echo "NET2=$NET2"
echo "NET2IP=$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
echo "Something is set for $NET2IPstring ... using it."
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
# Seems like this NET2IP doesn't do anything with it, what happens if it's not in the 60 network
echo "The original NET2 IP is $NET2IP"
cmd="ifconfig $NET2 $MASTER_PRIVATE_IP netmask $MASTER_PRIVATE_NETMASK";
cmd="ip addr add $MASTER_PRIVATE_IP/$MASTER_PRIVATE_NETMASK dev $NET2";
runcmd $cmd;
cmd="makenetworks";
runcmd $cmd;
@ -62,7 +47,7 @@ function check_destiny() {
grep ${TESTNODE} /etc/hosts
cmd="nodeset ${TESTNODE} shell";
runcmd $cmd;
cmd="ifconfig $NET2 $NET2IP";
cmd="ip addr del $MASTER_PRIVATE_IP/$MASTER_PRIVATE_NETMASK dev $NET2";
runcmd $cmd;
echo "Check if 'nodeset ${TESTNODE} shell' is added to ${SHELLFOLDER}/${TESTNODE}"
echo "==============================================="