Gerard,
I went and looked a bit at this, as I was hoping to just simply change it to use 'util.load_file' rather than 'open' directly.
Then, I found a few things:
* ubuntu's "dhclient leases" directory is /var/lib/dhcp, not /var/lib/dhclient. So this would appear broken on Ubuntu (I just looked at my desktop running 12.10).
* I have 65 files in that directory matching *.lease or *.leases, some of them:
$ ( cd /var/lib/dhcp && ls -altr *.lease *.leases ) > /tmp/out
995 Oct 24 2011 dhclient-134bd9a3-e41f-4d54-bd8c-4ea6ad41d0dd-eth0.lease
995 Oct 25 2011 dhclient-f2ec2e51-12fc-4b69-a2f7-be079e4c23fa-eth0.lease
549 Oct 30 2011 dhclient-80e3dc75-8306-4e89-96c7-edac04cde415-eth0.lease
0 Oct 30 2011 dhclient-154048a8-3379-47da-8527-6c9d68ec2526-wlan0.lease
0 Oct 30 2011 dhclient.leases
1016 Oct 31 2011 dhclient-9b714964-4a60-449c-a1d3-eec7bc5d35bf-eth0.lease
<snip>
789 Dec 3 08:56 dhclient-9798af6e-1c1b-40ea-9a0e-1c25b7621fd6-eth0.lease
789 Dec 5 13:11 dhclient-394c8646-57d5-48cf-8263-4866aa99f153-eth0.lease
1519 Dec 8 23:59 dhclient-d166b4ac-9cf3-4f46-8571-b7f5b12f14b4-wlan0.lease
output was trimmed for brevity
So, my directory would end up with a None result although there were 12 matches (len(addresses) == 12)
Could we make the following changes:
* support searching /var/lib/dhcp, ordered by write time, and take the last match.
* if None is found fall back to the incorrect 'route' solution we had before.
* make searching directories configurable and make it default to include both
/var/lib/dhcp and /var/lib/dhclient.
I'm sorry I didn't take a deeper look before, but I'm pretty sure Ubuntu is broken if we ship this.
Gerard,
I went and looked a bit at this, as I was hoping to just simply change it to use 'util.load_file' rather than 'open' directly.
Then, I found a few things:
* ubuntu's "dhclient leases" directory is /var/lib/dhcp, not /var/lib/dhclient. So this would appear broken on Ubuntu (I just looked at my desktop running 12.10).
* I have 65 files in that directory matching *.lease or *.leases, some of them:
$ ( cd /var/lib/dhcp && ls -altr *.lease *.leases ) > /tmp/out 134bd9a3- e41f-4d54- bd8c-4ea6ad41d0 dd-eth0. lease f2ec2e51- 12fc-4b69- a2f7-be079e4c23 fa-eth0. lease 80e3dc75- 8306-4e89- 96c7-edac04cde4 15-eth0. lease 154048a8- 3379-47da- 8527-6c9d68ec25 26-wlan0. lease 9b714964- 4a60-449c- a1d3-eec7bc5d35 bf-eth0. lease 9798af6e- 1c1b-40ea- 9a0e-1c25b7621f d6-eth0. lease 394c8646- 57d5-48cf- 8263-4866aa99f1 53-eth0. lease d166b4ac- 9cf3-4f46- 8571-b7f5b12f14 b4-wlan0. lease
995 Oct 24 2011 dhclient-
995 Oct 25 2011 dhclient-
549 Oct 30 2011 dhclient-
0 Oct 30 2011 dhclient-
0 Oct 30 2011 dhclient.leases
1016 Oct 31 2011 dhclient-
<snip>
789 Dec 3 08:56 dhclient-
789 Dec 5 13:11 dhclient-
1519 Dec 8 23:59 dhclient-
output was trimmed for brevity
So, my directory would end up with a None result although there were 12 matches (len(addresses) == 12)
Could we make the following changes:
* support searching /var/lib/dhcp, ordered by write time, and take the last match.
* if None is found fall back to the incorrect 'route' solution we had before.
* make searching directories configurable and make it default to include both
/var/lib/dhcp and /var/lib/dhclient.
I'm sorry I didn't take a deeper look before, but I'm pretty sure Ubuntu is broken if we ship this.