unbound-dhcp-leases-bridge: Make Leases hashable and equal by IP address

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2024-05-10 17:07:23 +01:00
parent 038c9db2bd
commit edcea3e1c9

View File

@@ -488,20 +488,25 @@ class Lease(object):
self._properties = properties
def __repr__(self):
return "<%s %s for %s (%s)>" % (self.__class__.__name__,
self.ipaddr, self.hwaddr, self.hostname)
return "<%s for %s (%s)>" % (self.__class__.__name__, self.ipaddr, self.hostname)
def __eq__(self, other):
return self.ipaddr == other.ipaddr and self.hwaddr == other.hwaddr
if isinstance(other, self.__class__):
return self.ipaddr == other.ipaddr
return NotImplemented
def __gt__(self, other):
if not self.ipaddr == other.ipaddr:
return
if isinstance(other, self.__class__):
if not self.ipaddr == other.ipaddr:
return NotImplemented
if not self.hwaddr == other.hwaddr:
return
return self.time_starts > other.time_starts
return self.time_starts > other.time_starts
return NotImplemented
def __hash__(self):
return hash(self.ipaddr)
@property
def binding_state(self):