Skip to content

Commit e01dd89

Browse files
widoyadvr
authored andcommitted
CLOUDSTACK-10217: Clean up old MAC addresses from DHCP lease file (#2393)
When the IPv4 address of a Instance changes we need to make sure the old entry is removed from the DHCP lease file on the Virtual Router otherwise the Instance will still get the old lease. Signed-off-by: Wido den Hollander <wido@widodh.nl>
1 parent c9afa8e commit e01dd89

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

systemvm/debian/opt/cloud/bin/cs_dhcp.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ def merge(dbag, data):
2525
if data['ipv4_address'] in dbag:
2626
del(dbag[data['ipv4_address']])
2727
else:
28-
remove_key = None
28+
remove_keys = set()
2929
for key, entry in dbag.iteritems():
3030
if key != 'id' and entry['host_name'] == data['host_name']:
31-
remove_key = key
31+
remove_keys.add(key)
3232
break
33-
if remove_key is not None:
33+
34+
for key, entry in dbag.iteritems():
35+
if key != 'id' and entry['mac_address'] == data['mac_address']:
36+
remove_keys.add(key)
37+
break
38+
39+
for remove_key in remove_keys:
3440
del(dbag[remove_key])
3541

3642
dbag[data['ipv4_address']] = data

0 commit comments

Comments
 (0)