From b25823213b6f0715acf2dd7d6873d10f8937b3e4 Mon Sep 17 00:00:00 2001 From: Wei Zhou <57355700+weizhouapache@users.noreply.github.com> Date: Tue, 1 Jun 2021 17:27:26 +0200 Subject: [PATCH] vr: remove old ips with same mac address in dhcpentry databag (#5059) This PR fixes #5058 when start a vm, the old entries in databag for the vm (with same mac addresses) should be removed then set again, to avoid duplicated records in dhcpentry databag and also /etc/dhcphosts.txt Testing with Isolated networks: (1) stop vm, change vm ip address, start vm vm info is updated in /etc/dhcphosts.txt and /etc/cloudstack/dhcpentry.json (2) stop vm, expunge vm. vm is removed from /etc/dhcphosts.txt and /var/lib/misc/dnsmasq.leases Testing with VPC: (1) create vm in 2 vpc tiers vm has 2 entries in /etc/dhcphosts.txt, and /etc/cloudstack/dhcpentry.json (2) stop vm, change ip addresses, change nics order, start vm entries are updated in /etc/dhcphosts.txt and /etc/cloudstack/dhcpentry.json (3) remove a nic from vm (hot unplug) vm nic is removed from /etc/dhcphosts.txt and /var/lib/misc/dnsmasq.leases entry in /etc/cloudstack/dhcpentry.json is updated. --- systemvm/debian/opt/cloud/bin/cs_dhcp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/cs_dhcp.py b/systemvm/debian/opt/cloud/bin/cs_dhcp.py index d949981db8b..8aa388a10f9 100755 --- a/systemvm/debian/opt/cloud/bin/cs_dhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs_dhcp.py @@ -28,7 +28,7 @@ def merge(dbag, data): else: remove_keys = set() for key, entry in dbag.iteritems(): - if key != 'id' and entry['mac_address'] == data['mac_address'] and data['remove']: + if key != 'id' and entry['mac_address'] == data['mac_address']: remove_keys.add(key) break