From a19faf9eaf606d8a177d490aa224ebe5c8c7448a Mon Sep 17 00:00:00 2001 From: davidjumani Date: Thu, 10 Dec 2020 16:58:31 +0530 Subject: [PATCH 1/2] vr: Ensuring dnsmasq.leases file is populated --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index ef1a52dec1c9..c67bdd2e5a65 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -28,7 +28,6 @@ DHCP_OPTS = "/etc/dhcpopts.txt" CLOUD_CONF = "/etc/dnsmasq.d/cloud.conf" - class CsDhcp(CsDataBag): """ Manage dhcp entries """ @@ -40,6 +39,7 @@ def process(self): 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 +60,9 @@ def process(self): if self.cloud.commit(): restart_dnsmasq = True + if self.dhcp_leases.commit(): + restart_dnsmasq = True + self.dhcp_opts.commit() if restart_dnsmasq: @@ -186,6 +189,9 @@ def add(self, entry): 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 +202,9 @@ def add(self, entry): 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 From 3f1a4446c340f150d4f8ebb02e671aafd97a670a Mon Sep 17 00:00:00 2001 From: davidjumani Date: Thu, 10 Dec 2020 23:11:15 +0530 Subject: [PATCH 2/2] Fix pylint issues --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index c67bdd2e5a65..2c0deea4abe4 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -28,6 +28,7 @@ DHCP_OPTS = "/etc/dhcpopts.txt" CLOUD_CONF = "/etc/dnsmasq.d/cloud.conf" + class CsDhcp(CsDataBag): """ Manage dhcp entries """ @@ -189,9 +190,9 @@ def add(self, entry): 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'])) + 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'], @@ -202,9 +203,9 @@ def add(self, entry): 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'])) + 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