Remove usage of deprecated ifconfig, bridge-utils 57/4457/2
authorTodd Malsbary <todd.malsbary@intel.com>
Tue, 14 Sep 2021 22:27:43 +0000 (15:27 -0700)
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
Thu, 30 Sep 2021 17:30:44 +0000 (17:30 +0000)
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Change-Id: I08d1430fff30801b5d034b3af5349e19839bb0ce

deploy/metal3-vm/02_configure_host.sh
deploy/metal3-vm/05_host_cleanup.sh
deploy/metal3-vm/ubuntu_bridge_network_configuration.sh
deploy/metal3-vm/vm-setup/roles/libvirt/tasks/network_teardown_tasks.yml
env/metal3/01_install_package.sh
env/metal3/02_configure.sh
env/metal3/06_host_cleanup.sh

index 634d4ee..2787750 100755 (executable)
@@ -63,14 +63,14 @@ else
       if [ ! -e /etc/sysconfig/network-scripts/ifcfg-provisioning ] ; then
           echo -e "DEVICE=provisioning\nTYPE=Bridge\nONBOOT=yes\nNM_CONTROLLED=no\nBOOTPROTO=static\nIPADDR=172.22.0.1\nNETMASK=255.255.255.0" | sudo dd of=/etc/sysconfig/network-scripts/ifcfg-provisioning
       fi
-      sudo ifdown provisioning || true
-      sudo ifup provisioning
+      sudo ip link set dev provisioning down || true
+      sudo ip link set dev provisioning up
 
       # Need to pass the provision interface for bare metal
       if [ "$PRO_IF" ]; then
           echo -e "DEVICE=$PRO_IF\nTYPE=Ethernet\nONBOOT=yes\nNM_CONTROLLED=no\nBRIDGE=provisioning" | sudo dd of="/etc/sysconfig/network-scripts/ifcfg-$PRO_IF"
-          sudo ifdown "$PRO_IF" || true
-          sudo ifup "$PRO_IF"
+          sudo ip link set dev "$PRO_IF" down || true
+          sudo ip link set dev "$PRO_IF" up
       fi
   fi
 
@@ -79,8 +79,8 @@ else
       if [ ! -e /etc/sysconfig/network-scripts/ifcfg-baremetal ] ; then
           echo -e "DEVICE=baremetal\nTYPE=Bridge\nONBOOT=yes\nNM_CONTROLLED=no" | sudo dd of=/etc/sysconfig/network-scripts/ifcfg-baremetal
       fi
-      sudo ifdown baremetal || true
-      sudo ifup baremetal
+      sudo ip link set dev baremetal down || true
+      sudo ip link set dev baremetal up
 
       # Add the internal interface to it if requests, this may also be the interface providing
       # external access so we need to make sure we maintain dhcp config if its available
@@ -100,7 +100,7 @@ else
       sudo virsh net-destroy baremetal
       sudo virsh net-start baremetal
       if [ "$INT_IF" ]; then #Need to bring UP the NIC after destroying the libvirt network
-          sudo ifup "$INT_IF"
+          sudo ip link set dev "$INT_IF" up
       fi
   fi
 fi
index c8edd48..9ad8088 100755 (executable)
@@ -48,12 +48,12 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
 sudo rm -rf /etc/NetworkManager/conf.d/dnsmasq.conf
 # There was a bug in this file, it may need to be recreated.
 if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
-    sudo ifdown provisioning || true
+    sudo ip link set dev provisioning down || true
     sudo rm -f /etc/sysconfig/network-scripts/ifcfg-provisioning || true
 fi
 # Leaving this around causes issues when the host is rebooted
 if [ "$MANAGE_BR_BRIDGE" == "y" ]; then
-    sudo ifdown baremetal || true
+    sudo ip link set dev baremetal down || true
     sudo rm -f /etc/sysconfig/network-scripts/ifcfg-baremetal || true
 fi
 
index 3f7b8b9..60875cb 100755 (executable)
@@ -10,24 +10,20 @@ if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
      # Adding an IP address in the libvirt definition for this network results in
      # dnsmasq being run, we don't want that as we have our own dnsmasq, so set
      # the IP address here
-     sudo brctl addbr provisioning
-     # sudo ifconfig provisioning 172.22.0.1 netmask 255.255.255.0 up
-     # Use ip command. ifconfig commands are deprecated now.
+     sudo ip link add dev provisioning type bridge
      sudo ip addr add dev provisioning 172.22.0.1/24
      sudo ip link set provisioning up
 
      # Need to pass the provision interface for bare metal
      if [ "$PRO_IF" ]; then
-       sudo brctl addif provisioning "$PRO_IF"
+       sudo ip link set dev "$PRO_IF" master provisioning
      fi
  fi
 
  if [ "$MANAGE_INT_BRIDGE" == "y" ]; then
      # Create the baremetal bridge
      if ! [[  $(ip a show baremetal) ]]; then
-       sudo brctl addbr baremetal
-       # sudo ifconfig baremetal 192.168.111.1 netmask 255.255.255.0 up
-       # Use ip command. ifconfig commands are deprecated now.
+       sudo ip link add dev baremetal type bridge
        sudo ip addr add dev baremetal 192.168.111.1/24
        sudo ip link set baremetal up
      fi
@@ -35,7 +31,7 @@ if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
      # Add the internal interface to it if requests, this may also be the interface providing
      # external access so we need to make sure we maintain dhcp config if its available
      if [ "$INT_IF" ]; then
-       sudo brctl addif "$INT_IF"
+       sudo ip link set dev "$INT_IF" master baremetal
      fi
  fi
 
@@ -44,6 +40,6 @@ if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
      sudo virsh net-destroy baremetal
      sudo virsh net-start baremetal
      if [ "$INT_IF" ]; then #Need to bring UP the NIC after destroying the libvirt network
-         sudo ifup "$INT_IF"
+         sudo ip link set dev "$INT_IF" up
      fi
  fi
index 8daae8a..ab77e35 100644 (file)
@@ -18,8 +18,8 @@
   shell: |
      sudo ip link set baremetal down 
      sudo ip link set provisioning down
-     brctl delbr baremetal | true
-     brctl delbr provisioning | true
+     ip link del baremetal type bridge | true
+     ip link del provisioning type bridge | true
 
   when:
     - ansible_distribution == 'Ubuntu'
index ce5aa2f..1ea151f 100755 (executable)
@@ -27,8 +27,7 @@ function install_essential_packages {
     vim \
     wget \
     git \
-    software-properties-common \
-    bridge-utils
+    software-properties-common
 
     update-alternatives --install /usr/bin/python python /usr/bin/python3 1
     update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
index 20077d2..c893f78 100755 (executable)
@@ -27,9 +27,9 @@ function check_interface_ip {
 }
 
 function configure_ironic_bridge {
-    brctl addbr provisioning
+    ip link add dev provisioning type bridge
     ip link set provisioning up
-    brctl addif provisioning $IRONIC_INTERFACE
+    ip link set dev $IRONIC_INTERFACE master provisioning
     ip addr add dev provisioning 172.22.0.1/24
 }
 
index b7ed5fd..a649511 100755 (executable)
@@ -12,6 +12,6 @@ for name in ironic ironic-inspector dnsmasq httpd mariadb ipa-downloader; do
 done
 
 ip link set provisioning down || true
-brctl delbr provisioning || true
+ip link del provisioning type bridge || true
 
 rm -rf ${IRONIC_DATA_DIR}