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

Merge pull request #6261 from bybai/cfg_alias

confignetwork need run twice when install NIC has multiple IPs
This commit is contained in:
zet809 2019-04-29 17:38:46 +08:00 committed by GitHub
commit e42c5252b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 46 deletions

View File

@ -26,18 +26,17 @@ fi
########################################################################
# networkmanager_active=0: use network.service
# networkmanager_active=1: use NetworkManager
# networkmanager_active=2: RH8 postscripts stage, NetworkManager is active but nmcli cannot modify NIC configure file
########################################################################
networkmanager_active=0
checkservicestatus NetworkManager > /dev/null
if [ $? -eq 0 ]; then
networkmanager_active=1
else
#In RH8 postscripts stage, NetworkManager is active but nmcli cannot modify NIC configure file
ps -ef|grep -v grep|grep NetworkManager >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
if [ -n "$NMCLI_USED" ] ; then
if [ "$NMCLI_USED" = "1" ]; then
networkmanager_active=1
elif [ "$NMCLI_USED" = "2" ]; then
networkmanager_active=2
fi
fi
str_conf_file=""
str_conf_file_xcatbak=""
tmp_con_name=""
@ -657,11 +656,11 @@ elif [ "$1" = "-s" ];then
echo $NODE > /etc/HOSTNAME
else
#write ifcfg-* file for redhat
con_name="xcat-install-"${str_inst_nic}
con_name="xcat-"${str_inst_nic}
str_inst_prefix=$(v4mask2prefix ${str_inst_mask})
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_inst_nic}"
if [ $networkmanager_active -eq 2 ]; then
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-xcat-install-${str_inst_nic}"
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-$con_name"
fi
if [ $networkmanager_active -eq 1 ]; then
is_nmcli_connection_exist "$con_name"
@ -683,7 +682,7 @@ elif [ "$1" = "-s" ];then
echo "NETMASK=${str_inst_mask}" >> $str_conf_file
echo "BOOTPROTO=none" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
echo "NAME=xcat-install-${str_inst_nic}" >> $str_conf_file
echo "NAME=${con_name}" >> $str_conf_file
echo "HWADDR=${str_inst_mac}" >> $str_conf_file
fi
if [ $networkmanager_active -eq 2 ]; then

View File

@ -63,9 +63,7 @@ function get_nic_cfg_file_content {
elif [ $is_debian -eq 1 ]; then
cfg_file="$nwdir/${cfg_dev}"
fi
#TODO:this is networkmanager_active=2
ps -ef|grep -v grep|grep NetworkManager >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
if [ "$networkmanager_active" != "0" ]; then
$ip address show dev ${cfg_dev}| $sed -e 's/^/[Ethernet] >> /g' | log_lines info
else
if [ -f $cfg_file ]; then
@ -474,9 +472,11 @@ function configure_nicdevice {
while [ $num -lt $max ];
do
nic_dev=`echo "$nics_pair" |sed -n "${num}p"|awk '{print $1}'`
ipaddrs=$(find_nic_ips $nic_dev)
multiple_ips=$(echo $ipaddrs|grep "|")
#If install nic is configured, skip to reconfigure it
if [ x"$nic_dev" = x"$installnic" -a $instnic_conf -eq 1 ]; then
log_warn "install nic $nic_dev has been configured, skip to reconfigure it."
if [ x"$nic_dev" = x"$installnic" -a $instnic_conf -eq 1 -a x"$multiple_ips" = x ]; then
log_warn "install nic $nic_dev has been configured, continue."
((num+=1))
continue
fi
@ -528,7 +528,6 @@ function configure_nicdevice {
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
nic_pair=`echo "$nics_pair" |sed -n "${num}p"`
echo "configure nic and its device : $nic_pair"
ipaddrs=$(find_nic_ips $nic_dev)
# if a device is middle device, it may have no IP, for example, configure eth0->vlan.1->br0, vlan1.1 is middle device
# is_mid_device is to label if ${nic_dev} is middle device
# if $is_mid_device has value, the ${nic_dev} is middle device, or else, it is not middle device
@ -543,8 +542,8 @@ function configure_nicdevice {
xcatnet=`query_nicnetworks_net $nic_dev`
if [ -n "$ipaddrs" ]; then
log_info "configure $nic_dev"
log_info "call: configeth $nic_dev $ipaddrs $xcatnet"
configeth $nic_dev $ipaddrs $xcatnet
log_info "call: NMCLI_USED=$networkmanager_active configeth $nic_dev $ipaddrs $xcatnet"
NMCLI_USED=$networkmanager_active configeth $nic_dev $ipaddrs $xcatnet
if [ $? -ne 0 ]; then
errorcode=1
fi
@ -637,27 +636,6 @@ errorcode=0
#nictypes should support capital letters, for example, Ethernet and ethernet
utolcmd="sed -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
#get for installnic
installnic=''
installnic=`get_installnic`
instnic_conf=0
if [ $boot_install_nic -eq 1 ];then
if [ -n "$installnic" ]; then
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log_info "configure the install nic $installnic. "
instnic_conf=1
configeth -s $installnic
if [ $? -ne 0 ]; then
errorcode=1
fi
get_nic_cfg_file_content $installnic
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
else
log_error "Can not determine proper install nic."
errorcode=1
fi
fi
#check if using NetworkManager or network service
networkmanager_active=3
check_NetworkManager_or_network_service
@ -672,6 +650,28 @@ else
exit 1
fi
#get for installnic
installnic=''
installnic=`get_installnic`
instnic_conf=0
if [ $boot_install_nic -eq 1 ];then
if [ -n "$installnic" ]; then
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log_info "configure the install nic $installnic."
log_info "NMCLI_USED=$networkmanager_active configeth -s $installnic"
instnic_conf=1
NMCLI_USED=$networkmanager_active configeth -s $installnic
if [ $? -ne 0 ]; then
errorcode=1
fi
get_nic_cfg_file_content $installnic
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
else
log_error "Can not determine proper install nic."
errorcode=1
fi
fi
#back up all network interface configure files
nwdirbak=$nwdir".xcatbak"
ls $nwdirbak > /dev/null 2>/dev/null

View File

@ -1587,6 +1587,17 @@ function decode_arguments {
#
##############################################################################
function check_NetworkManager_or_network_service() {
#In RH7.6 postscripts stage, network service is active, but xCAT uses NetworkManager to configure IP,
#after that, xCAT disable NetworkManager, when CN is booted, CN use network service.
#In RH8, there is only NetworkManager
#So check network service should before check NetworkManager.
checkservicestatus network > /dev/null 2>/dev/null || checkservicestatus wicked > /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
stopservice NetworkManager | log_lines info
disableservice NetworkManager | log_lines info
log_info "network service is active"
return 0
fi
#check NetworkManager is active
checkservicestatus NetworkManager > /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
@ -1604,13 +1615,6 @@ function check_NetworkManager_or_network_service() {
if [ $? -eq 0 ]; then
return 2
fi
checkservicestatus network > /dev/null 2>/dev/null || checkservicestatus wicked > /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
stopservice NetworkManager | log_lines info
disableservice NetworkManager | log_lines info
log_info "network service is active"
return 0
fi
checkservicestatus networking > /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
stopservice NetworkManager | log_lines info