mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 01:26:38 +00:00
Merge pull request #6138 from bybai/bond
configure bond support using nmcli
This commit is contained in:
commit
1d9b3b4087
@ -524,6 +524,10 @@ function configure_nicdevice {
|
||||
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
|
||||
is_mid_device=$(echo "$nics_pair"|awk /${nic_dev}$/'{ print $1}')
|
||||
#ignore bmc interfaces. They're allowed in the nics table to generate DNS/hostname records, but they
|
||||
#can't be configured here (it's done in bmcsetup
|
||||
if [ x"$nic_dev_type" = "xbmc" ]; then
|
||||
@ -581,7 +585,7 @@ function configure_nicdevice {
|
||||
if [ "$networkmanager_active" = "0" ]; then
|
||||
create_vlan_interface ifname=$vlanname vlanid=$vlanid
|
||||
elif [ "$networkmanager_active" = "1" ]; then
|
||||
create_vlan_interface_nmcli ifname=$vlanname vlanid=$vlanid ipaddrs=$ipaddrs
|
||||
create_vlan_interface_nmcli ifname=$vlanname vlanid=$vlanid ipaddrs=$ipaddrs next_nic=$is_mid_device
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "configure VLAN failed."
|
||||
@ -592,7 +596,11 @@ function configure_nicdevice {
|
||||
if [ "$networkmanager_active" = "0" ]; then
|
||||
create_bond_interface ifname=$nic_dev slave_ports=$base_nic_for_bond slave_type=$base_nic_type
|
||||
elif [ "$networkmanager_active" = "1" ]; then
|
||||
create_bond_interface_nmcli ifname=$nic_dev slave_ports=$base_nic_for_bond slave_type=$base_nic_type
|
||||
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
|
||||
log_error "configure bond $nic_dev failed."
|
||||
errorcode=1
|
||||
fi
|
||||
elif [ x"$nic_dev_type" = "xinfiniband" ] || [ x"$nic_dev_type" = "xOmnipath" ]; then
|
||||
log_info "Call configib for IB nics: $nic_dev, ports: $num_iba_ports"
|
||||
@ -626,10 +634,10 @@ utolcmd="sed -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
nwdirbak=$nwdir".xcatbak"
|
||||
ls $nwdirbak > /dev/null 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
log_info "back up $nwdir to $newdirbak"
|
||||
log_info "back up $nwdir to $nwdirbak"
|
||||
cp -rf $nwdir $nwdirbak > /dev/null 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
log_warn "back up $nwdir to $newdirbak failed."
|
||||
log_warn "back up $nwdir to $nwdirbak failed."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -1677,7 +1677,7 @@ function get_first_addr_ipv4 {
|
||||
#
|
||||
# create vlan using nmcli
|
||||
#
|
||||
# input : ifname=<ifname> vlanid=<vlanid> ipaddrs=<ipaddrs>
|
||||
# input : ifname=<ifname> vlanid=<vlanid> ipaddrs=<ipaddrs> next_nic=<next_nic>
|
||||
# return : 0 success
|
||||
#
|
||||
###############################################################################
|
||||
@ -1690,6 +1690,7 @@ function create_vlan_interface_nmcli {
|
||||
local _xcatnet=""
|
||||
local _netmask=""
|
||||
local _mtu=""
|
||||
local next_nic=""
|
||||
# in case it's on top of bond, we need to migrate ip from its
|
||||
# member vlan ports.
|
||||
# parser input arguments
|
||||
@ -1698,6 +1699,7 @@ function create_vlan_interface_nmcli {
|
||||
key=`echo "$1" | $cut -s -d= -f1`
|
||||
if [ "$key" = "ifname" ] || \
|
||||
[ "$key" = "ipaddrs" ] || \
|
||||
[ "$key" = "next_nic" ] || \
|
||||
[ "$key" = "vlanid" ]; then
|
||||
eval "$1"
|
||||
fi
|
||||
@ -1708,41 +1710,40 @@ function create_vlan_interface_nmcli {
|
||||
log_error "No \"vlanid\" specificd for vlan interface. Abort!"
|
||||
return 1
|
||||
fi
|
||||
if [ -z "$next_nic" ]; then
|
||||
_xcatnet=$(query_nicnetworks_net $ifname.$vlanid)
|
||||
log_info "Pickup xcatnet, \"$_xcatnet\", from NICNETWORKS for interface \"$ifname\"."
|
||||
|
||||
_xcatnet=$(query_nicnetworks_net $ifname.$vlanid)
|
||||
log_info "Pickup xcatnet, \"$_xcatnet\", from NICNETWORKS for interface \"$ifname\"."
|
||||
_mtu_num=$(get_network_attr $xcatnet mtu)
|
||||
if [ -n "$_mtu_num" ]; then
|
||||
_mtu="mtu $_mtu_num"
|
||||
fi
|
||||
|
||||
_mtu_num=$(get_network_attr $xcatnet mtu)
|
||||
if [ $? -ne 0 ]; then
|
||||
_mtu=""
|
||||
else
|
||||
_mtu="mtu $_mtu_num"
|
||||
fi
|
||||
|
||||
if [ ! -z "$ipaddrs" ]; then
|
||||
_netmask_long=$(get_network_attr $_xcatnet mask)
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "No valid netmask get for $ifname.$vlanid"
|
||||
return 1
|
||||
else
|
||||
ipaddr=$(get_first_addr_ipv4 $ipaddrs)
|
||||
if [ ! -z "$ipaddrs" ]; then
|
||||
_netmask_long=$(get_network_attr $_xcatnet mask)
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "No valid IP address get for $ifname.$vlanid, please check $ipaddrs"
|
||||
log_error "No valid netmask get for $ifname.$vlanid"
|
||||
return 1
|
||||
else
|
||||
ipaddr=$(get_first_addr_ipv4 $ipaddrs)
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "No valid IP address get for $ifname.$vlanid, please check $ipaddrs"
|
||||
return 1
|
||||
fi
|
||||
_netmask=$(v4mask2prefix $_netmask_long)
|
||||
_ipaddrs="method none ip4 $ipaddr/$_netmask"
|
||||
fi
|
||||
_netmask=$(v4mask2prefix $_netmask_long)
|
||||
_ipaddrs="method none ip4 $ipaddr/$_netmask"
|
||||
fi
|
||||
fi
|
||||
check_and_set_device_managed $ifname
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "The parent interface $ifname is unmanaged, so skip $ifname.$vlanid"
|
||||
retrun 1
|
||||
return 1
|
||||
fi
|
||||
log_info "check parent interface $ifname whether it is managed by NetworkManager"
|
||||
#load the 8021q module if not loaded.
|
||||
load_kmod module=8021q retry=10 interval=0.5
|
||||
con_name="xcat.$ifname.$vlanid"
|
||||
con_name="xcat-vlan-$ifname.$vlanid"
|
||||
tmp_con_name=""
|
||||
is_nmcli_connection_exist $con_name
|
||||
if [ $? -eq 0 ]; then
|
||||
@ -1752,17 +1753,20 @@ function create_vlan_interface_nmcli {
|
||||
|
||||
$nmcli con add type vlan con-name $con_name dev $ifname id $(( 10#$vlanid )) $_ipaddrs $_mtu
|
||||
log_info "create NetworkManager connection for $ifname.$vlanid"
|
||||
$nmcli con up $con_name
|
||||
is_connection_activate_intime $con_name
|
||||
is_active=$?
|
||||
if [ "$is_active" -eq 0 ]; then
|
||||
log_error "The vlan configuration for $ifname.$vlanid can not be booted up"
|
||||
$nmcli con delete $con_name
|
||||
if [ ! -z "$tmp_con_name" ]; then
|
||||
$nmcli con modify $tmp_con_name connection.id $con_name
|
||||
if [ -z "$next_nic" ]; then
|
||||
$nmcli con up $con_name
|
||||
is_connection_activate_intime $con_name
|
||||
is_active=$?
|
||||
if [ "$is_active" -eq 0 ]; then
|
||||
log_error "The vlan configuration for $ifname.$vlanid can not be booted up"
|
||||
$nmcli con delete $con_name
|
||||
if [ ! -z "$tmp_con_name" ]; then
|
||||
$nmcli con modify $tmp_con_name connection.id $con_name
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
return 1
|
||||
elif [ ! -z "$tmp_con_name" ]; then
|
||||
fi
|
||||
if [ -n "$tmp_con_name" ]; then
|
||||
$nmcli con delete $tmp_con_name
|
||||
fi
|
||||
$ip address show dev $ifname.$vlanid | $sed -e 's/^/[vlan] >> /g' | log_lines info
|
||||
@ -1865,20 +1869,28 @@ function create_bridge_interface_nmcli {
|
||||
return 1
|
||||
fi
|
||||
# Create bridge connection
|
||||
xcat_con_name="xcat"$ifname
|
||||
xcat_con_name="xcat-bridge-"$ifname
|
||||
tmp_con_name=$xcat_con_name"-tmp"
|
||||
if [ x"$_brtype" = "xbridge" ]; then
|
||||
is_nmcli_connection_exist $xcat_con_name
|
||||
if [ $? -eq 0 ] ; then
|
||||
is_connection_activate_intime $xcat_con_name 1
|
||||
if [ $? -eq 1 ]; then
|
||||
log_info "$xcat_con_name exists, down it first"
|
||||
$nmcli con down $xcat_con_name
|
||||
$ip link set dev $ifname down
|
||||
fi
|
||||
log_info "$xcat_con_name exists, rename old $xcat_con_name to $tmp_con_name"
|
||||
$nmcli con modify $xcat_con_name connection.id $tmp_con_name
|
||||
$nmcli con modify $xcat_con_name connection.id $tmp_con_name autoconnect no
|
||||
if [ $? -ne 0 ] ; then
|
||||
log_error "$nmcli rename $xcat_con_name failed"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
log_info "create bridge connection $xcat_con_name"
|
||||
$nmcli con add type bridge con-name $xcat_con_name ifname $ifname
|
||||
cmd="$nmcli con add type bridge con-name $xcat_con_name ifname $ifname $_mtu"
|
||||
log_info $cmd
|
||||
$cmd
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "nmcli failed to add bridge $ifname"
|
||||
is_nmcli_connection_exist $tmp_con_name
|
||||
@ -1893,20 +1905,33 @@ function create_bridge_interface_nmcli {
|
||||
fi
|
||||
|
||||
# Create slaves connection
|
||||
xcat_slave_con="xcat_br_"$_port
|
||||
xcat_slave_con="xcat-br-slave-"$_port
|
||||
tmp_slave_con_name=$xcat_slave_con"-tmp"
|
||||
if [ x"$_pretype" = "xethernet" -o x"$_pretype" = "xvlan" -o x"$_pretype" = "xbond" ]; then
|
||||
is_nmcli_connection_exist $xcat_slave_con
|
||||
if [ $? -eq 0 ] ; then
|
||||
is_connection_activate_intime $xcat_slave_con 1
|
||||
if [ $? -eq 1 ]; then
|
||||
$nmcli con down $xcat_slave_con
|
||||
$ip link set dev $_port down
|
||||
fi
|
||||
log_info "$xcat_slave_con exists, rename old connetion $xcat_slave_con to $tmp_slave_con_name"
|
||||
$nmcli con modify $xcat_slave_con connection.id $tmp_slave_con_name
|
||||
$nmcli con modify $xcat_slave_con connection.id $tmp_slave_con_name autoconnect no
|
||||
if [ $? -ne 0 ] ; then
|
||||
log_error "$nmcli rename $xcat_slave_con failed"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
con_use_same_dev=$(nmcli dev show $_port|grep GENERAL.CONNECTION|awk -F: '{print $2}'|sed 's/^[ \t]*//g')
|
||||
if [ "$con_use_same_dev" != "--" -a -n "$con_use_same_dev" ]; then
|
||||
cmd="$nmcli con mod "$con_use_same_dev" master $ifname $_mtu"
|
||||
xcat_slave_con=$con_use_same_dev
|
||||
else
|
||||
cmd="$nmcli con add type $_pretype con-name $xcat_slave_con ifname $_port master $ifname $_mtu"
|
||||
fi
|
||||
log_info "create $_pretype slaves connetcion $xcat_slave_con for bridge"
|
||||
$nmcli con add type $_pretype con-name $xcat_slave_con ifname $_port master $ifname $_mtu
|
||||
log_info "$cmd"
|
||||
$cmd
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "nmcli failed to add bridge slave $_port"
|
||||
is_nmcli_connection_exist $tmp_slave_con_name
|
||||
@ -1926,20 +1951,12 @@ function create_bridge_interface_nmcli {
|
||||
$nmcli con mod $xcat_con_name ipv4.method manual ipv4.addresses $ipv4_addr/$str_prefix;
|
||||
fi
|
||||
|
||||
# Configure MTU
|
||||
if [ -n "$_mtu" ]; then
|
||||
$nmcli con mod $xcat_con_name $_mtu
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "$nmcli con mod $xcat_con_name $_mtu failed"
|
||||
rc=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# bring up interface formally
|
||||
log_info "$nmcli con up $xcat_slave_con; $nmcli con up $xcat_con_name"
|
||||
lines=`$nmcli con up $xcat_slave_con; $nmcli con up $xcat_con_name`
|
||||
log_info "$nmcli con up $xcat_con_name"
|
||||
$nmcli con up $xcat_con_name
|
||||
rc=$?
|
||||
|
||||
log_info "$nmcli con up $xcat_slave_con"
|
||||
$nmcli con up $xcat_slave_con
|
||||
# If bridge interface is active, delete tmp old connection
|
||||
# If bridge interface is not active, delete new bridge and slave connection, and restore old connection
|
||||
is_connection_activate_intime $xcat_con_name
|
||||
@ -1976,12 +1993,263 @@ function create_bridge_interface_nmcli {
|
||||
#############################################################################################################################
|
||||
#
|
||||
# create bond or bond->vlan interface
|
||||
# https://www.kernel.org/doc/Documentation/networking/bonding.txt
|
||||
# https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Using_Channel_Bonding.html
|
||||
#
|
||||
# input : ifname=<nic> xcatnet=<xcatnetwork> _ipaddr=<ip> _netmask=<netmask> _bonding_opts=<bonding_opts> _mtu=<mtu> slave_ports=<port1,port2>
|
||||
# input : bondname=<nic> _ipaddr=<ip> slave_ports=<port1,port2> slave_type=<base_nic_type> next_nic=<next_nic>
|
||||
# return : 0 successful
|
||||
# other unsuccessful
|
||||
#
|
||||
############################################################################################################################
|
||||
function create_bond_interface_nmcli {
|
||||
log_info "create_bond_interface $@"
|
||||
log_info "create_bond_interface_nmcli $@"
|
||||
local bondname=""
|
||||
local xcatnet=""
|
||||
local _ipaddr=""
|
||||
local _netmask=""
|
||||
local _bonding_opts=""
|
||||
local _mtu=""
|
||||
local slave_ports="" #bond slaves
|
||||
local slave_type=""
|
||||
local rc=0
|
||||
local next_nic=""
|
||||
# parser input arguments
|
||||
while [ -n "$1" ];
|
||||
do
|
||||
key=$(echo "$1" | $cut -s -d= -f1)
|
||||
if [ "$key" = "bondname" ] || \
|
||||
[ "$key" = "_ipaddr" ] || \
|
||||
[ "$key" = "slave_ports" ] || \
|
||||
[ "$key" = "next_nic" ] || \
|
||||
[ "$key" = "slave_type" ]; then
|
||||
eval "$1"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if [ "$slave_type" = "ethernet" ]; then
|
||||
slave_type="Ethernet"
|
||||
# - "802.3ad" mode requires a switch that is 802.3ad compliant.
|
||||
_bonding_opts="mode=802.3ad,miimon=100"
|
||||
elif [ "$slave_type" = "infiniband" ]; then
|
||||
slave_type="Infiniband"
|
||||
_bonding_opts="mode=1,miimon=100,fail_over_mac=1"
|
||||
else
|
||||
_bonding_opts="mode=active-backup"
|
||||
fi
|
||||
if [ -z "$next_nic" ]; then
|
||||
# query "nicnetworks" table about its target "xcatnet"
|
||||
xcatnet=$(query_nicnetworks_net $bondname)
|
||||
log_info "Pickup xcatnet, \"$xcatnet\", from NICNETWORKS for interface \"$bondname\"."
|
||||
|
||||
# Query mtu value from "networks" table
|
||||
_mtu_num=$(get_network_attr $xcatnet mtu)
|
||||
if [ -n "$_mtu_num" ]; then
|
||||
_mtu="mtu $_mtu_num"
|
||||
fi
|
||||
|
||||
# Query mask value from "networks" table
|
||||
_netmask=$(get_network_attr $xcatnet mask)
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "No valid netmask get for $bondname"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Calculate prefix based on mask
|
||||
str_prefix=$(v4mask2prefix $_netmask)
|
||||
|
||||
# Get first valid ip from nics.nicips
|
||||
ipv4_addr=$(get_first_addr_ipv4 $_ipaddr)
|
||||
if [ $? -ne 0 ]; then
|
||||
log_warn "No valid IP address get for $bondname, please check $ipaddrs"
|
||||
return 1
|
||||
fi
|
||||
|
||||
fi
|
||||
# check if all slave dev managed or not by nmcli
|
||||
xcat_slave_ports=$(echo "$slave_ports" | $sed -e 's/,/ /g')
|
||||
for ifslave in $xcat_slave_ports
|
||||
do
|
||||
check_and_set_device_managed $ifslave
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# check if bond connection exist or not
|
||||
xcat_con_name="xcat-bond-"$bondname
|
||||
tmp_con_name=""
|
||||
is_nmcli_connection_exist $xcat_con_name
|
||||
if [ $? -eq 0 ]; then
|
||||
is_connection_activate_intime $xcat_con_name 1
|
||||
if [ $? -eq 1 ]; then
|
||||
$nmcli con down $xcat_con_name
|
||||
$ip link set dev $bondname down
|
||||
wait_for_ifstate $bondname DOWN 40 1
|
||||
fi
|
||||
tmp_con_name="$xcat_con_name-tmp"
|
||||
log_info "$xcat_con_name exists, rename old $xcat_con_name to $tmp_con_name"
|
||||
$nmcli con modify $xcat_con_name connection.id $tmp_con_name autoconnect no
|
||||
if [ $? -ne 0 ] ; then
|
||||
log_error "$nmcli rename $xcat_con_name failed"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# create raw bond device
|
||||
log_info "create bond connection $xcat_con_name"
|
||||
cmd=""
|
||||
if [ -n "$next_nic" ]; then
|
||||
cmd="$nmcli con add type bond con-name $xcat_con_name ifname $bondname bond.options $_bonding_opts autoconnect yes"
|
||||
else
|
||||
cmd="$nmcli con add type bond con-name $xcat_con_name ifname $bondname bond.options $_bonding_opts method none ipv4.method manual ipv4.addresses $ipv4_addr/$str_prefix $_mtu"
|
||||
fi
|
||||
log_info $cmd
|
||||
$cmd
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "nmcli failed to add bond connection $xcat_con_name"
|
||||
if [ -n "$tmp_con_name" ] ; then
|
||||
$nmcli con modify $tmp_con_name connection.id $xcat_con_name
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Create slaves connection
|
||||
xcat_slave_con_names=""
|
||||
tmp_slave_con_names=""
|
||||
for ifslave in $xcat_slave_ports
|
||||
do
|
||||
tmp_slave_con_name=""
|
||||
xcat_slave_con="xcat-bond-slave-"$ifslave
|
||||
is_nmcli_connection_exist $xcat_slave_con
|
||||
if [ $? -eq 0 ] ; then
|
||||
is_connection_activate_intime $xcat_slave_con 1
|
||||
if [ $? -eq 1 ]; then
|
||||
$nmcli con down $xcat_slave_con
|
||||
ip link set dev $ifslave down
|
||||
wait_for_ifstate $ifslave DOWN 40 1
|
||||
fi
|
||||
tmp_slave_con_name=$xcat_slave_con"-tmp"
|
||||
log_info "rename $xcat_slave_con to $tmp_slave_con_name"
|
||||
$nmcli con modify $xcat_slave_con connection.id $tmp_slave_con_name autoconnect no
|
||||
if [ -n "$tmp_slave_con_names" ]; then
|
||||
tmp_slave_con_names="$tmp_slave_con_names $tmp_slave_con_name"
|
||||
else
|
||||
tmp_slave_con_names=$tmp_slave_con_name
|
||||
fi
|
||||
|
||||
fi
|
||||
con_use_same_dev=$(nmcli dev show $ifslave|grep GENERAL.CONNECTION|awk -F: '{print $2}'|sed 's/^[ \t]*//g')
|
||||
if [ "$con_use_same_dev" != "--" -a "$con_use_same_dev" != "$xcat_slave_con" ]; then
|
||||
$nmcli con down "$con_use_same_dev"
|
||||
$nmcli con mod "$con_use_same_dev" autoconnect no
|
||||
$ip link set dev $ifslave down
|
||||
wait_for_ifstate $ifslave DOWN 20 2
|
||||
fi
|
||||
cmd="$nmcli con add type $slave_type con-name $xcat_slave_con $_mtu method none ifname $ifslave master $xcat_con_name autoconnect yes"
|
||||
log_info $cmd
|
||||
$cmd
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "nmcli failed to add bond slave connection $xcat_slave_con"
|
||||
if [ -n "$tmp_slave_con_name" ] ; then
|
||||
$nmcli con modify $tmp_slave_con_name connection.id $xcat_slave_con
|
||||
fi
|
||||
rc=1
|
||||
break
|
||||
else
|
||||
if [ -n "$xcat_slave_con_names" ]; then
|
||||
xcat_slave_con_names="$xcat_slave_con_names $xcat_slave_con"
|
||||
else
|
||||
xcat_slave_con_names=$xcat_slave_con
|
||||
fi
|
||||
fi
|
||||
cmd="$nmcli con up $xcat_slave_con"
|
||||
log_info $cmd
|
||||
$cmd
|
||||
is_connection_activate_intime $xcat_slave_con
|
||||
is_active=$?
|
||||
if [ "$is_active" -eq 0 ]; then
|
||||
log_error "The bond slave connection $xcat_slave_con can not be booted up"
|
||||
$nmcli con delete $xcat_slave_con
|
||||
if [ -n "$tmp_slave_con_name" ]; then
|
||||
$nmcli con modify $tmp_slave_con_name connection.id $xcat_slave_con
|
||||
fi
|
||||
rc=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
# bring up interface formally
|
||||
if [ $rc -ne 1 ]; then
|
||||
log_info "$nmcli con up $xcat_con_name"
|
||||
$nmcli con up $xcat_con_name
|
||||
if [ -z "$next_nic" ]; then
|
||||
is_connection_activate_intime $xcat_con_name
|
||||
is_active=$?
|
||||
if [ "$is_active" -eq 0 ]; then
|
||||
log_error "connection $xcat_con_name failed to activate"
|
||||
rc=1
|
||||
else
|
||||
wait_for_ifstate $bondname UP 20 10
|
||||
if [ $? -ne 0 ]; then
|
||||
rc=1
|
||||
else
|
||||
$ip address show dev $bondname| $sed -e 's/^/[bond] >> /g' | log_lines info
|
||||
fi
|
||||
fi
|
||||
else
|
||||
rc=0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $rc -eq 1 ]; then
|
||||
# delete all bond slave and master which is created by xCAT
|
||||
if [ -n "$xcat_slave_con_names" ]; then
|
||||
log_info "delete connection $xcat_slave_con_names"
|
||||
delete_bond_slaves_con "$xcat_slave_con_names"
|
||||
fi
|
||||
if [ -n "$tmp_slave_con_names" ]; then
|
||||
for tmpslave in $tmp_slave_con_names
|
||||
do
|
||||
slavecon=$(echo $tmpslave|sed 's/-tmp$//')
|
||||
log_info "restore connection $slavecon"
|
||||
$nmcli con modify $tmpslave connection.id $slavecon
|
||||
done
|
||||
fi
|
||||
is_nmcli_connection_exist $xcat_con_name
|
||||
if [ $? -eq 0 ] ; then
|
||||
log_info "delete bond connection $xcat_con_name"
|
||||
$nmcli con delete $xcat_con_name
|
||||
fi
|
||||
if [ -n "$tmp_con_name" ] ; then
|
||||
log_info "restore bond connection $tmp_con_name"
|
||||
$nmcli con modify $tmp_con_name connection.id $xcat_con_name
|
||||
fi
|
||||
else
|
||||
# delete tmp master and tmp slaves
|
||||
if [ -n "$tmp_con_name" ] ; then
|
||||
$nmcli con delete $tmp_con_name
|
||||
fi
|
||||
if [ -n "$tmp_slave_con_names" ]; then
|
||||
delete_bond_slaves_con "$tmp_slave_con_names"
|
||||
fi
|
||||
fi
|
||||
return $rc
|
||||
}
|
||||
######################################################################
|
||||
#
|
||||
# delete bond slaves connection
|
||||
# imput format: <slave1> <slave2> <slave3> ... ...<slaven>
|
||||
#
|
||||
######################################################################
|
||||
function delete_bond_slaves_con {
|
||||
slaves_con_names=$1
|
||||
if [ -z "$slaves_con_names" ]; then
|
||||
log_error "bond slaves connection list is empty"
|
||||
return
|
||||
fi
|
||||
for slave in $slaves_con_names
|
||||
do
|
||||
is_nmcli_connection_exist $slave
|
||||
if [ $? -eq 0 ] ; then
|
||||
$nmcli con delete $slave
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user