don't error when trying to remove a dhcp entry that does not exist

This commit is contained in:
forest 2021-12-10 20:38:02 -05:00
parent f85f282854
commit f8415dbba5
1 changed files with 9 additions and 2 deletions

View File

@ -18,7 +18,14 @@ ipv4_address="$4"
if [ "$action" = 'add' ]; then
printf "trying to delete any existing (probably expired) dhcp associations for $ipv4_address..."
virsh net-update "$network_name" delete ip-dhcp-host "<host ip='$ipv4_address' />" --live --config || true
printf "adding $mac_address --> $ipv4_address to $network_name"
virsh net-update "$network_name" "$action" ip-dhcp-host "<host mac='$mac_address' ip='$ipv4_address' />" --live --config
else
printf "removing $mac_address and $ipv4_address from $network_name if they exist"
virsh net-update "$network_name" "$action" ip-dhcp-host "<host mac='$mac_address' />" --live --config || true
virsh net-update "$network_name" "$action" ip-dhcp-host "<host ip='$ipv4_address' />" --live --config || true
fi
printf "adding $mac_address --> $ipv4_address to $network_name"
virsh net-update "$network_name" "$action" ip-dhcp-host "<host mac='$mac_address' ip='$ipv4_address' />" --live --config