Dhcp_host_domain_ng.py: Add_lease, hostname check failed

The annoyance I’ve got is excessive Add_lease, hostname check failed messages for devices that have no hostname. For every dd.update_dhcp(sys_op, hostname, ipv4) call from main, it prints the hostname check failed message for every device with no hostname.

This seems to be caused by DHCPv4._load_hints() (being called from DHCPv4.__init__()) reading the leases file and calling _add_lease(hostname, ipv4) for every line. It looks like this is required as sometimes the script is called to refresh all the leases from the file, but surely it shouldn’t be adding all the leases from the file every time it is called to just add/update one?

EDIT:
I’ve resolved the excess logging by adding a check in _load_hints():

if hostname != "*":
    self._add_lease(hostname, ipv4)

It does seem like a bug though to update all the leases from the file when the script is called to update one from the env.

1 Like