Comment 3 for bug 1513485

Revision history for this message
Matt Dirba (5qxm) wrote :

I ran into a broken dhcp.leases file in maas 1.9 as well.

# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import provisioningserver
>>> parse_leases_file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'parse_leases_file' is not defined
>>> from provisioningserver.dhcp.leases import parse_leases_file
>>> parse_leases_file()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "provisioningserver/dhcp/leases.py", line 98, in parse_leases_file
    return fstat(leases_file.fileno()).st_mtime, parse_leases(contents)
  File "provisioningserver/dhcp/leases_parser_fast.py", line 79, in parse_leases
    results.append((entry.host, entry.hardware.mac))
AttributeError: 'str' object has no attribute 'mac'
>>>

I was able to avoid the error by modifying /usr/lib/python2.7/dist-packages/provisioningserver/dhcp/leases_parser_fast.py as follows:
79c79,80
< if not has_expired(entry, now):
---
> if not has_expired(entry, now) and entry.hardware:
> # print('entry={}\nhardware{}\n'.format(entry.hardware, entry))

Unfortunately I did not save the dhcp.leases file. At the time of the failure I had servers failing to commission. Undoing the change now, I am unable to recreate the error.