mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 09:36:41 +00:00
polished networkmanager_active logic
This commit is contained in:
parent
45631ac217
commit
68925429a3
@ -46,7 +46,7 @@ function configipv4(){
|
||||
str_v4ip=$2
|
||||
str_v4net=$3
|
||||
str_v4mask=$4
|
||||
num_v4num=$5
|
||||
num_v4num=$5 #If NIC has multiple IPs, the ordinal number of IP is num_v4num
|
||||
str_extra_params=$6
|
||||
str_nic_mtu=$7
|
||||
|
||||
@ -137,13 +137,6 @@ function configipv4(){
|
||||
# Write the info to the ifcfg file for redhat
|
||||
con_name="xcat-"${str_if_name}
|
||||
str_conf_file=""
|
||||
if [ $num_v4num -ne 0 ] && [ $networkmanager_active -eq 0 ]; then
|
||||
str_if_name=${str_if_name}:${num_v4num}
|
||||
fi
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_if_name}"
|
||||
if [ $networkmanager_active -ne 0 ]; then
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}"
|
||||
fi
|
||||
if [ $networkmanager_active -eq 1 ]; then
|
||||
if [ $num_v4num -eq 0 ]; then
|
||||
is_nmcli_connection_exist $con_name
|
||||
@ -155,7 +148,16 @@ function configipv4(){
|
||||
else
|
||||
nmcli con modify $con_name +ipv4.addresses ${str_v4ip}/${str_prefix}
|
||||
fi
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}"
|
||||
str_conf_file_1="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}-1"
|
||||
if [ -f $str_conf_file_1 ]; then
|
||||
grep -x "NAME=$con_name" $str_conf_file_1 >/dev/null 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
str_conf_file=$str_conf_file_1
|
||||
fi
|
||||
fi
|
||||
elif [ $networkmanager_active -eq 2 ]; then
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}"
|
||||
if [ $num_v4num -eq 0 ]; then
|
||||
echo "DEVICE=${str_if_name}" > $str_conf_file
|
||||
echo "BOOTPROTO=none" >> $str_conf_file
|
||||
@ -169,6 +171,11 @@ function configipv4(){
|
||||
echo "NETMASK$num_v4num=${str_v4mask}" >> $str_conf_file
|
||||
fi
|
||||
else
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_if_name}"
|
||||
#If using network service, the NIC alias device format is <NIC>:<num_v4num> like eth0:1
|
||||
if [ $num_v4num -ne 0 ]; then
|
||||
str_if_name=${str_if_name}:${num_v4num}
|
||||
fi
|
||||
echo "DEVICE=${str_if_name}" > $str_conf_file
|
||||
echo "BOOTPROTO=none" >> $str_conf_file
|
||||
echo "NM_CONTROLLED=no" >> $str_conf_file
|
||||
@ -183,15 +190,6 @@ function configipv4(){
|
||||
echo "MTU=${str_nic_mtu}" >> $str_conf_file
|
||||
fi
|
||||
fi
|
||||
if [ $networkmanager_active -eq 1 ]; then
|
||||
str_conf_file_1="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}-1"
|
||||
if [ -f $str_conf_file_1 ]; then
|
||||
grep -x "NAME=$con_name" $str_conf_file_1 >/dev/null 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
str_conf_file=$str_conf_file_1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
|
||||
echo "VLAN=yes" >> $str_conf_file
|
||||
fi
|
||||
@ -672,6 +670,13 @@ elif [ "$1" = "-s" ];then
|
||||
nmcli con modify $con_name connection.id $tmp_con_name
|
||||
fi
|
||||
nmcli con add type ethernet con-name $con_name ifname ${str_inst_nic} ipv4.method manual ipv4.addresses ${str_inst_ip}/${str_inst_prefix} connection.autoconnect-priority 9
|
||||
str_conf_file_1="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}-1"
|
||||
if [ -f $str_conf_file_1 ]; then
|
||||
grep $con_name $str_conf_file_1 >/dev/null 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
$str_conf_file=$str_conf_file_1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "DEVICE=${str_inst_nic}" > $str_conf_file
|
||||
echo "IPADDR=${str_inst_ip}" >> $str_conf_file
|
||||
@ -698,15 +703,6 @@ elif [ "$1" = "-s" ];then
|
||||
else
|
||||
echo "GATEWAY=${str_inst_gateway}" >> /etc/sysconfig/network
|
||||
fi
|
||||
fi
|
||||
if [ $networkmanager_active -eq 1 ]; then
|
||||
str_conf_file_1="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_if_name}-1"
|
||||
if [ -f $str_conf_file_1 ]; then
|
||||
grep $con_name $str_conf_file_1 >/dev/null 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
$str_conf_file=$str_conf_file_1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#add extra params
|
||||
i=0
|
||||
|
@ -63,6 +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
|
||||
$ip address show dev ${cfg_dev}| $sed -e 's/^/[Ethernet] >> /g' | log_lines info
|
||||
@ -562,16 +563,20 @@ function configure_nicdevice {
|
||||
#linux bridge type is bridge
|
||||
#openvswitch bridge type is bridge_ovs
|
||||
elif [ x"$nic_dev_type" = "xbridge_ovs" -o x"$nic_dev_type" = "xbridge" ]; then
|
||||
if [ "$networkmanager_active" = "0" ]; then
|
||||
ps -ef|grep -v grep|grep NetworkManager >/dev/null 2>/dev/null
|
||||
nmcli_used=$?
|
||||
check_brctl $nic_dev_type
|
||||
if [ $? -ne 0 ] && [ $nmcli_used -ne 0 ]; then
|
||||
errorcode=1
|
||||
ps -ef|grep -v grep|grep NetworkManager >/dev/null 2>/dev/null
|
||||
nmcli_used=$?
|
||||
if [ "$networkmanager_active" != "1" ]; then
|
||||
if [ "$networkmanager_active" = "0" ]; then
|
||||
check_brctl $nic_dev_type
|
||||
if [ $? -ne 0 ]; then
|
||||
errorcode=1
|
||||
else
|
||||
create_bridge_interface ifname=$nic_dev _brtype=$nic_dev_type _port=$base_nic_dev _pretype=$base_nic_type
|
||||
if
|
||||
else
|
||||
create_bridge_interface ifname=$nic_dev _brtype=$nic_dev_type _port=$base_nic_dev _pretype=$base_nic_type
|
||||
fi
|
||||
elif [ "$networkmanager_active" = "1" ]; then
|
||||
else
|
||||
create_bridge_interface_nmcli ifname=$nic_dev _brtype=$nic_dev_type _port=$base_nic_dev _pretype=$base_nic_type _ipaddr=$ipaddrs
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
@ -588,9 +593,9 @@ function configure_nicdevice {
|
||||
vlanname=`echo "$nic_dev" | $sed -e 's/^\(.*\)vla\?n\?\([0-9]\+\)$/\1/'`
|
||||
fi
|
||||
ipaddrs=$(find_nic_ips $nic_dev)
|
||||
if [ "$networkmanager_active" = "0" ]; then
|
||||
if [ "$networkmanager_active" != "1" ]; then
|
||||
create_vlan_interface ifname=$vlanname vlanid=$vlanid
|
||||
elif [ "$networkmanager_active" = "1" ]; then
|
||||
else
|
||||
create_vlan_interface_nmcli ifname=$vlanname vlanid=$vlanid ipaddrs=$ipaddrs next_nic=$is_mid_device
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
@ -599,9 +604,9 @@ function configure_nicdevice {
|
||||
fi
|
||||
#configure bond
|
||||
elif [ x"$nic_dev_type" = "xbond" ]; then
|
||||
if [ "$networkmanager_active" = "0" ]; then
|
||||
if [ "$networkmanager_active" != "1" ]; then
|
||||
create_bond_interface ifname=$nic_dev slave_ports=$base_nic_for_bond slave_type=$base_nic_type
|
||||
elif [ "$networkmanager_active" = "1" ]; then
|
||||
else
|
||||
create_bond_interface_nmcli bondname=$nic_dev slave_ports=$base_nic_for_bond slave_type=$base_nic_type _ipaddr=$ipaddrs next_nic=$is_mid_device
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
@ -658,13 +663,15 @@ if [ $boot_install_nic -eq 1 ];then
|
||||
fi
|
||||
|
||||
#check if using NetworkManager or network service
|
||||
networkmanager_active=2
|
||||
networkmanager_active=3
|
||||
check_NetworkManager_or_network_service
|
||||
is_active=$?
|
||||
if [ $is_active -eq 0 ]; then
|
||||
networkmanager_active=0
|
||||
elif [ $is_active -eq 1 ]; then
|
||||
networkmanager_active=1
|
||||
elif [ $is_active -eq 2 ]; then
|
||||
networkmanager_active=2
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user