# Remove the old lease first
self.unbound.remove_lease(old_lease)
+ self._remove_lease(old_lease)
# Apply the lease
self.unbound.apply_lease(lease)
# Remove the lease
self.unbound.remove_lease(lease)
+ self._remove_lease(lease)
# Raise an error if the event is not supported
else:
elif not lease.active or lease.expired:
return
+ # Remove any previous leases
+ self._remove_lease(lease)
+
# Store the lease
self.leases.add(lease)
if lease.ipaddr == ipaddr:
return lease
+ def _remove_lease(self, lease):
+ try:
+ self.leases.remove(lease)
+ except KeyError:
+ pass
+
def read_static_hosts(self):
log.info("Reading static hosts from %s" % self.hosts_file)