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.
I ran into a broken dhcp.leases file in maas 1.9 as well.
# python ver.dhcp. leases import parse_leases_file rver/dhcp/ leases. py", line 98, in parse_leases_file file.fileno( )).st_mtime, parse_leases( contents) rver/dhcp/ leases_ parser_ fast.py" , line 79, in parse_leases append( (entry. host, entry.hardware. mac))
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 provisioningser
>>> parse_leases_file()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "provisioningse
return fstat(leases_
File "provisioningse
results.
AttributeError: 'str' object has no attribute 'mac'
>>>
I was able to avoid the error by modifying /usr/lib/ python2. 7/dist- packages/ provisioningser ver/dhcp/ leases_ parser_ fast.py as follows: entry={ }\nhardware{ }\n'.format( entry.hardware, entry))
79c79,80
< if not has_expired(entry, now):
---
> if not has_expired(entry, now) and entry.hardware:
> # print('
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.