2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 11:42:05 +00:00

enhance ifdown/ifup for confignetwork and confignics (#5430)

* use ip link set to replace ifdown/ifup

* enhanced

* polished
This commit is contained in:
Yuan Bai 2018-07-26 17:28:32 +08:00 committed by yangsong
parent 29b5e07264
commit 9e161adf7c
2 changed files with 46 additions and 15 deletions

View File

@ -9,6 +9,15 @@ if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then
. $str_dir_name/nicutils.sh
fi
error_code=0
#########################################################################
# ifdown/ifup will not be executed in diskful provision postscripts stage
#########################################################################
reboot_nic_bool=1
if [ -z "$UPDATENODE" ] || [ $UPDATENODE -ne 1 ] ; then
if [ "$NODESETSTATE" = "install" ] && ! grep "REBOOT=TRUE" /opt/xcat/xcatinfo >/dev/null 2>&1; then
reboot_nic_bool=0
fi
fi
function configipv4(){
str_if_name=$1
str_v4ip=$2
@ -978,7 +987,9 @@ else
if [ "$str_os_type" = "debian" ];then
ifdown --force $str_nic_name > /dev/null
else
ifdown $str_nic_name > /dev/null
if [ $reboot_nic_bool -eq 1 ]; then
ifdown $str_nic_name > /dev/null
fi
fi
fi
#delete all old ip address
@ -1057,11 +1068,13 @@ else
error_code=1
fi
else
echo "bring up ip"
ifup $str_nic_name
if [ $? -ne 0 ]; then
log_error "ifup $str_nic_name failed."
error_code=1
if [ $reboot_nic_bool -eq 1 ]; then
echo "bring up ip"
ifup $str_nic_name
if [ $? -ne 0 ]; then
log_error "ifup $str_nic_name failed."
error_code=1
fi
fi
fi
fi

View File

@ -28,6 +28,16 @@ uniq="uniq"
xargs="xargs"
modprobe="modprobe"
#########################################################################
# ifdown/ifup will not be executed in diskful provision postscripts stage
#########################################################################
reboot_nic_bool=1
if [ -z "$UPDATENODE" ] || [ $UPDATENODE -ne 1 ] ; then
if [ "$NODESETSTATE" = "install" ] && ! grep "REBOOT=TRUE" /opt/xcat/xcatinfo >/dev/null 2>&1; then
reboot_nic_bool=0
fi
fi
######################################################
#
# log lines
@ -885,7 +895,7 @@ function create_bridge_interface {
local _pretype=""
local _port="" #pre nic
local _mtu=""
rc=0
# parser input arguments
while [ -n "$1" ];
do
@ -970,8 +980,10 @@ function create_bridge_interface {
inattrs="$cfg"
# bring up interface formally
lines=`$ifdown $ifname; $ifup $ifname`
rc=$?
if [ $reboot_nic_bool -eq 1 ]; then
lines=`$ifdown $ifname; $ifup $ifname`
rc=$?
fi
if [ $rc -ne 0 ]; then
log_warn "ifup $ifname failed with return code equals to $rc"
echo "$lines" \
@ -1062,8 +1074,10 @@ function create_ethernet_interface {
inattrs="$cfg"
# bring up interface formally
true || lines=`$ifdown $ifname; $ifup $ifname`
rc=$?
if [ $reboot_nic_bool -eq 1 ]; then
lines=`$ifdown $ifname; $ifup $ifname`
rc=$?
fi
if [ $rc -ne 0 ]; then
log_warn "ifup $ifname failed with return code equals to $rc"
echo "$lines" \
@ -1188,8 +1202,10 @@ function create_vlan_interface {
inattrs="$cfg"
if [ x$xcatnet != x ]; then
# bring up interface formally
lines=`$ifdown $ifname.$vlanid; $ifup $ifname.$vlanid`
rc=$?
if [ $reboot_nic_bool -eq 1 ]; then
lines=`$ifdown $ifname.$vlanid; $ifup $ifname.$vlanid`
rc=$?
fi
if [ $rc -ne 0 ]; then
log_warn "ifup $ifname.$vlanid failed with return code equals to $rc"
echo "$lines" \
@ -1486,8 +1502,10 @@ function create_bond_interface {
xcatnet=$xcatnet \
inattrs="$cfg"
if [ x$xcatnet != x ]; then
lines=`$ifdown $ifname; $ifup $ifname 2>&1`
rc=$?
if [ $reboot_nic_bool -eq 1 ]; then
lines=`$ifdown $ifname; $ifup $ifname 2>&1`
rc=$?
fi
if [ $rc -ne 0 ]; then
log_warn "ifup $ifname failed with return code equals to $rc"
echo "$lines" \