From 61a5a297058ce4478766b36d640f76684e31b9c8 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 24 Jan 2018 11:09:45 +0100 Subject: [PATCH] CLOUDSTACK-10252: Delete dnsmasq leases file on restart (#2427) Delete dnsmasq's leases file when dnsmasq is restarted to avoid it use old ip-mac-address-vm mapping leases. Signed-off-by: Rohit Yadav --- systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py index 7aac837cf1b..30fb38e016a 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py @@ -49,15 +49,21 @@ class CsDhcp(CsDataBag): self.add(self.dbag[item]) self.write_hosts() - if self.cloud.is_changed(): - self.delete_leases() - self.configure_server() - restart_dnsmasq = self.conf.commit() - self.cloud.commit() + restart_dnsmasq = False + + if self.conf.commit(): + restart_dnsmasq = True + + if self.cloud.commit(): + restart_dnsmasq = True + self.dhcp_opts.commit() + if restart_dnsmasq: + self.delete_leases() + if not self.cl.is_redundant() or self.cl.is_master(): if restart_dnsmasq: CsHelper.service("dnsmasq", "restart")