[Kea-users] keama-leases.py fails with abandoned leases

Darren Ankney darren.ankney at gmail.com
Thu Feb 6 13:39:01 UTC 2025


Hi John,

The latest version of this file should be here:
https://gitlab.isc.org/isc-projects/keama/-/blob/master/leases/keama-leases.py

You can create an account on https://gitlab.isc.org/users/sign_up but
I think you can't use an @gmail.com address (or other public free
email provider address) to do so (due to spam).

Once you've been able to create an account, it should be no problem
for you to open an issue here:
https://gitlab.isc.org/isc-projects/keama/-/issues where you can
attach your patch in whatever way you see fit.  I don't think you'll
be able to actually create a merge request though.

Thank you,
Darren Ankney

On Mon, Feb 3, 2025 at 10:57 PM John Lind <steinhelten at gmail.com> wrote:
>
> I managed to pull the script from the GIT repository.  It doesn't seem to be versioned, but I believe it is the latest and it says:
>
> # dhcp2kea by marmo
> # 6-12-2022 (dhcpd4), 14-12-2022 (dhcpd6), 15-12-2022 (dhcp2kea.php)
> # 23-12-2022 ("addr key=value" option)
>
> It seems to work great on my "leases" file, EXCEPT for the entries that are abandoned, e.g.
> lease 192.168.1.43 {
>         starts 0 2023/12/17 00:15:52 UTC;
>         ends 2 2024/01/16 00:15:52 UTC;
>
>         abandoned;
> }
>
> Then it says,
>
> root at remo:/home/john/xfer # python3 keama-leases.py dhcpd.leases
> Traceback (most recent call last):
>   File "/home/john/xfer/keama-leases.py", line 329, in <module>
>     print(leases,file=f)  # writing
>     ^^^^^^^^^^^^^^^^^^^^
>   File "/home/john/xfer/keama-leases.py", line 105, in __str__
>     , v["hardware ethernet"] # hwaddr
>       ~^^^^^^^^^^^^^^^^^^^^^
> KeyError: 'hardware ethernet'
>
> This is not a show stopper for me, because I can just edit out those half-dozen or so entries and then it seems to work fine (though I haven't tried importing the .csv file into a mem file - not that far yet - or maybe this IS the format of the mem file?) but since this is a perfectly legitimate entry from isc-dhcpd, I'm wondering if a fix might not be in order?  I'm guessing that it should be fairly simple to test for the existence of that key and skip the entry, but I'm not a python person (perl rules!) so I don't feel fully confident in trying to fix this.  If I' the best available candidate, I'm willing to take a run at it.
>
> Actually, I did just take a swing at it.  It was easy.
>
> root at remo:/home/john/xfer # diff keama-leases.py keama-leases-fix.py
> 96a97,98
> >             if "hardware ethernet" not in v:
> >                 continue
>
> Can someone help me commit this to git?
>
> --
> John Lind
> steinhelten at gmail.com
>
> --
> ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.
>
> To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
>
> Kea-users mailing list
> Kea-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/kea-users


More information about the Kea-users mailing list