nvazquez commented on a change in pull request #3351: [WIP: DO NOT MERGE] Have 
persistent DHCP leases file on VRs and cleanup /etc/hosts on VM deletion
URL: https://github.com/apache/cloudstack/pull/3351#discussion_r289235734
 
 

 ##########
 File path: systemvm/debian/opt/cloud/bin/cs/CsDhcp.py
 ##########
 @@ -114,8 +114,23 @@ def configure_server(self):
             idx += 1
 
     def delete_leases(self):
+        macs_dhcphosts = []
         try:
-            open(LEASES, 'w').close()
+            logging.info("Attempting to delete entries from dnsmasq.leases 
file for VMs which are not on dhcphosts file")
+            for host in open(DHCP_HOSTS):
+                macs_dhcphosts.append(host.split(',')[0])
+
+            removed = 0
+            for leaseline in open(LEASES):
+                lease = leaseline.split(' ')
+                mac = lease[1]
+                ip = lease[2]
+                if mac not in macs_dhcphosts:
+                    cmd = "dhcp_release %s %s" % (ip, mac)
 
 Review comment:
   Thanks I'll fix this

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to