Only perform bond interface operations if it is not a cloud installation

This commit is contained in:
Wes
2023-03-30 16:11:50 +00:00
parent bdae8d5017
commit 3cd1598067

View File

@@ -54,33 +54,37 @@ add_interface_bond0() {
ethtool -K "$BNIC" $i off &>/dev/null ethtool -K "$BNIC" $i off &>/dev/null
fi fi
done done
# Check if the bond slave connection has already been created
nmcli -f name,uuid -p con | grep -q "bond0-slave-$BNIC"
local found_int=$?
if [[ $found_int != 0 ]]; then if ! [[ is_cloud ]]; then
# Create the slave interface and assign it to the bond # Check if the bond slave connection has already been created
nmcli con add type ethernet ifname "$BNIC" con-name "bond0-slave-$BNIC" master bond0 -- \ nmcli -f name,uuid -p con | grep -q "bond0-slave-$BNIC"
ethernet.mtu "$MTU" \ local found_int=$?
connection.autoconnect "yes"
else
local int_uuid
int_uuid=$(nmcli -f name,uuid -p con | sed -n "s/bond0-slave-$BNIC //p" | tr -d ' ')
nmcli con mod "$int_uuid" \ if [[ $found_int != 0 ]]; then
ethernet.mtu "$MTU" \ # Create the slave interface and assign it to the bond
connection.autoconnect "yes" nmcli con add type ethernet ifname "$BNIC" con-name "bond0-slave-$BNIC" master bond0 -- \
fi ethernet.mtu "$MTU" \
connection.autoconnect "yes"
else
local int_uuid
int_uuid=$(nmcli -f name,uuid -p con | sed -n "s/bond0-slave-$BNIC //p" | tr -d ' ')
nmcli con mod "$int_uuid" \
ethernet.mtu "$MTU" \
connection.autoconnect "yes"
fi
fi
ip link set dev "$BNIC" arp off multicast off allmulticast off promisc on ip link set dev "$BNIC" arp off multicast off allmulticast off promisc on
# Bring the slave interface up if ! [[ is_cloud ]]; then
if [[ $verbose == true ]]; then # Bring the slave interface up
nmcli con up "bond0-slave-$BNIC" if [[ $verbose == true ]]; then
else nmcli con up "bond0-slave-$BNIC"
nmcli con up "bond0-slave-$BNIC" &>/dev/null else
nmcli con up "bond0-slave-$BNIC" &>/dev/null
fi
fi fi
if [ "$nic_error" != 0 ]; then if [ "$nic_error" != 0 ]; then
return "$nic_error" return "$nic_error"
fi fi