Don't delete if lease is static
This commit is contained in:
parent
a673e38cff
commit
436dc42576
|
@ -638,9 +638,13 @@ class ZKDatabase(object):
|
||||||
def delete(self, pattern):
|
def delete(self, pattern):
|
||||||
macaddr = pattern[0]
|
macaddr = pattern[0]
|
||||||
try:
|
try:
|
||||||
zkhandler.delete(self.zk_conn, '{}/{}'.format(self.key, macaddr))
|
timestamp = zkhandler.readdata(self.zk_conn, '{}/{}'.format(self.key, macaddr))
|
||||||
|
if timestamp != 'static':
|
||||||
|
zkhandler.delete(self.zk_conn, '{}/{}'.format(self.key, macaddr))
|
||||||
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
leases = []
|
leases = []
|
||||||
|
@ -716,8 +720,8 @@ class HostDatabase(object):
|
||||||
return list(map(Host.from_tuple, self.db.all()))
|
return list(map(Host.from_tuple, self.db.all()))
|
||||||
|
|
||||||
def replace(self, host):
|
def replace(self, host):
|
||||||
self.delete(host)
|
if self.delete(host):
|
||||||
self.add(host)
|
self.add(host)
|
||||||
|
|
||||||
def sorted_hosts(hosts):
|
def sorted_hosts(hosts):
|
||||||
hosts = list(hosts)
|
hosts = list(hosts)
|
||||||
|
|
Loading…
Reference in New Issue