vr: Ensuring dnsmasq.leases file is populated (#4529)

This commit is contained in:
davidjumani 2020-12-14 14:36:24 +05:30 committed by GitHub
parent 96cfe27504
commit 4d33e159f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,7 @@ class CsDhcp(CsDataBag):
self.cloud = CsFile(DHCP_HOSTS)
self.dhcp_opts = CsFile(DHCP_OPTS)
self.conf = CsFile(CLOUD_CONF)
self.dhcp_leases = CsFile(LEASES)
self.cloud.repopulate()
self.dhcp_opts.repopulate()
@ -60,6 +61,9 @@ class CsDhcp(CsDataBag):
if self.cloud.commit():
restart_dnsmasq = True
if self.dhcp_leases.commit():
restart_dnsmasq = True
self.dhcp_opts.commit()
if restart_dnsmasq:
@ -186,6 +190,9 @@ class CsDhcp(CsDataBag):
entry['ipv4_address'],
entry['host_name'],
lease))
self.dhcp_leases.search(entry['mac_address'], "0 %s %s %s *" % (entry['mac_address'],
entry['ipv4_address'],
entry['host_name']))
else:
tag = entry['ipv4_address'].replace(".", "_")
self.cloud.add("%s,set:%s,%s,%s,%s" % (entry['mac_address'],
@ -196,6 +203,9 @@ class CsDhcp(CsDataBag):
self.dhcp_opts.add("%s,%s" % (tag, 3))
self.dhcp_opts.add("%s,%s" % (tag, 6))
self.dhcp_opts.add("%s,%s" % (tag, 15))
self.dhcp_leases.search(entry['mac_address'], "0 %s %s %s *" % (entry['mac_address'],
entry['ipv4_address'],
entry['host_name']))
i = IPAddress(entry['ipv4_address'])
# Calculate the device