From 5bb782871b8dbd9827e6659f96ac2c0e42b157a1 Mon Sep 17 00:00:00 2001 From: Todd Malsbary Date: Tue, 14 Sep 2021 15:27:43 -0700 Subject: [PATCH] Remove usage of deprecated ifconfig, bridge-utils Signed-off-by: Todd Malsbary Change-Id: I08d1430fff30801b5d034b3af5349e19839bb0ce --- deploy/metal3-vm/02_configure_host.sh | 14 +++++++------- deploy/metal3-vm/05_host_cleanup.sh | 4 ++-- deploy/metal3-vm/ubuntu_bridge_network_configuration.sh | 14 +++++--------- .../roles/libvirt/tasks/network_teardown_tasks.yml | 4 ++-- env/metal3/01_install_package.sh | 3 +-- env/metal3/02_configure.sh | 4 ++-- env/metal3/06_host_cleanup.sh | 2 +- 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/deploy/metal3-vm/02_configure_host.sh b/deploy/metal3-vm/02_configure_host.sh index 634d4ee..2787750 100755 --- a/deploy/metal3-vm/02_configure_host.sh +++ b/deploy/metal3-vm/02_configure_host.sh @@ -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 diff --git a/deploy/metal3-vm/05_host_cleanup.sh b/deploy/metal3-vm/05_host_cleanup.sh index c8edd48..9ad8088 100755 --- a/deploy/metal3-vm/05_host_cleanup.sh +++ b/deploy/metal3-vm/05_host_cleanup.sh @@ -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 diff --git a/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh b/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh index 3f7b8b9..60875cb 100755 --- a/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh +++ b/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh @@ -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 diff --git a/deploy/metal3-vm/vm-setup/roles/libvirt/tasks/network_teardown_tasks.yml b/deploy/metal3-vm/vm-setup/roles/libvirt/tasks/network_teardown_tasks.yml index 8daae8a..ab77e35 100644 --- a/deploy/metal3-vm/vm-setup/roles/libvirt/tasks/network_teardown_tasks.yml +++ b/deploy/metal3-vm/vm-setup/roles/libvirt/tasks/network_teardown_tasks.yml @@ -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' diff --git a/env/metal3/01_install_package.sh b/env/metal3/01_install_package.sh index ce5aa2f..1ea151f 100755 --- a/env/metal3/01_install_package.sh +++ b/env/metal3/01_install_package.sh @@ -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 diff --git a/env/metal3/02_configure.sh b/env/metal3/02_configure.sh index 20077d2..c893f78 100755 --- a/env/metal3/02_configure.sh +++ b/env/metal3/02_configure.sh @@ -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 } diff --git a/env/metal3/06_host_cleanup.sh b/env/metal3/06_host_cleanup.sh index b7ed5fd..a649511 100755 --- a/env/metal3/06_host_cleanup.sh +++ b/env/metal3/06_host_cleanup.sh @@ -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} -- 2.16.6