File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,7 @@ attach_default_interface_cleanup: export BGP_NIC_2_MAC=${CRC_BGP_NIC_2_MAC}
341341endif
342342attach_default_interface_cleanup : export INSTANCE_NAME=${NETWORK_ISOLATION_INSTANCE_NAME}
343343attach_default_interface_cleanup : export NETWORK_NAME=${NETWORK_ISOLATION_NET_NAME}
344+ attach_default_interface_cleanup : export IP_ADDRESS=${NETWORK_ISOLATION_IP_ADDRESS}
344345attach_default_interface_cleanup : # # Detach default libvirt network from CRC
345346 bash scripts/interfaces-setup-cleanup.sh
346347
Original file line number Diff line number Diff line change @@ -6,16 +6,24 @@ if [ "$EUID" -eq 0 ]; then
66 exit
77fi
88
9- MAC_ADDRESS=$( virsh --connect=qemu:///system dumpxml $INSTANCE_NAME | xmllint --xpath " string(/domain/devices/interface/source[@network=\" $NETWORK_NAME \" ]/../mac/@address)" -)
9+ MAC_ADDRESS=$( virsh --connect=qemu:///system dumpxml $INSTANCE_NAME | xmllint --xpath " string(/domain/devices/interface/source[@network=\" $NETWORK_NAME \" ]/../mac/@address)" - 2> /dev/null )
1010if [ -n " ${MAC_ADDRESS} " ]; then
1111 virsh --connect=qemu:///system detach-interface $INSTANCE_NAME network --mac $MAC_ADDRESS
1212 # First try to remove the DHCP static IP entry by MAC, if it fails try by hostname
13- if ! virsh --connect=qemu:///system net-update $NETWORK_NAME delete ip-dhcp-host " <host mac='$MAC_ADDRESS '/>" --config --live; then
14- virsh --connect=qemu:///system net-update $NETWORK_NAME delete ip-dhcp-host " <host name=' $INSTANCE_NAME '/> " --config --live
13+ if virsh --connect=qemu:///system net-update $NETWORK_NAME delete ip-dhcp-host " <host mac='$MAC_ADDRESS '/>" --config --live 2> /dev/null ; then
14+ DHCP_REMOVED=true
1515 fi
16- sleep 5
1716fi
1817
18+ # Without MAC we try to remove it using the host name or IP address
19+ if [ -z " ${DHCP_REMOVED} " ]; then
20+ if ! virsh --connect=qemu:///system net-update $NETWORK_NAME delete ip-dhcp-host " <host name='$INSTANCE_NAME '/>" --config --live 2> /dev/null; then
21+ virsh --connect=qemu:///system net-update $NETWORK_NAME delete ip-dhcp-host " <host ip='$IP_ADDRESS '/>" --config --live 2> /dev/null
22+ fi
23+ fi
24+
25+ sleep 5
26+
1927if [ -n " $BGP " ]; then
2028 # We don't destroy the PCI devices here but before adding them, to avoid having to restart the CRC VM twice
2129
You can’t perform that action at this time.
0 commit comments