MartijnBraam / python-isc-dhcp-leases

Small python module for reading /var/lib/dhcp/dhcpd.leases from isc-dhcp-server
MIT License
123 stars 47 forks source link

Handle Lease functionalities when 'starts' is missing #25

Closed jay-g-mehta closed 6 years ago

jay-g-mehta commented 6 years ago

The existing code base expected each lease entry will have 'starts' property and the code fails at: https://github.com/MartijnBraam/python-isc-dhcp-leases/blob/master/isc_dhcp_leases/iscdhcpleases.py#L212 self.start = parse_time(properties['starts'])

But lease entry could be without 'starts', like in below 3 examples: lease 10.37.178.69 { tstp 5 2018/03/30 18:24:01; tsfp 5 2018/03/30 18:24:01; atsfp 5 2018/03/30 18:24:01; cltt 5 2018/03/30 17:54:01; binding state free; hardware ethernet 8c:dc:d4:b2:ea:fc; set vendorclass = "PXEClient:Arch:00000:UNDI:002001"; set ClientIP = "10.37.178.69"; set ClientMac = "8c:dc:d4:b2:ea:fc"; set Vendorid = "PXEClient"; } lease 10.37.178.68 { tstp 4 2018/03/29 22:08:05; tsfp 4 2018/03/29 22:08:05; atsfp 4 2018/03/29 22:08:05; cltt 4 2018/03/29 21:38:05; binding state free; hardware ethernet 8c:dc:d4:b2:d0:a8; set vendorclass = "d-i"; } lease 10.37.178.67 { tstp 4 2018/03/29 20:22:16; tsfp 4 2018/03/29 20:22:16; atsfp 4 2018/03/29 20:22:16; binding state free; hardware ethernet 8c:dc:d4:b2:d0:a8; }

This patch fixes the assumption.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4c34e6a163d4cce952f5a8463eb3532b57f0125b on jay-g-mehta:master into dc513ea124565d77a7a5bde742ec0a8ffb877fd4 on MartijnBraam:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4c34e6a163d4cce952f5a8463eb3532b57f0125b on jay-g-mehta:master into dc513ea124565d77a7a5bde742ec0a8ffb877fd4 on MartijnBraam:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4c34e6a163d4cce952f5a8463eb3532b57f0125b on jay-g-mehta:master into dc513ea124565d77a7a5bde742ec0a8ffb877fd4 on MartijnBraam:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4c34e6a163d4cce952f5a8463eb3532b57f0125b on jay-g-mehta:master into dc513ea124565d77a7a5bde742ec0a8ffb877fd4 on MartijnBraam:master.

MartijnBraam commented 6 years ago

Looks like a good improvment!

jay-g-mehta commented 6 years ago

thanks, that helps. Could you please roll out next release 0.9.1 with these changes on pypi?

MartijnBraam commented 6 years ago

0.9.1 has been released