[kea-dev] Kea python hook?

Dave Cole davecole at nbnco.com.au
Sun Jan 21 23:23:09 UTC 2018

I did not know that code existed!

I just had a quick look and you have done some interesting
things (compared to my code).  I am not much of a C++ programmer
having last done it seriously back in 2000.

On big difference in approach is that the code you have created
will not work with current Kea if the Python code imports a
module with native code - unless you statically link your code
with Kea.  Kea loads hooks with RTLD_LOCAL which prevents symbols
in the hook being visible in subsequent dynamic linking.  The
hook I created here connects to a database and publishes to Kafka
- we need to load native modules.

I implemented my hook as a two stage load.  The Kea hook does
dlopen() on libpython, and then loads the kea native module and
bootstraps it via a Capsule.  Implementing the kea native module
outside of kea means I can implement tests for my hook in Python
outside of kea.

One thing that concerned me when first looking at Kea was that
there did not seem to be any sensible way I could build unit
tests for my hook.  Now I can use the full flexibility of Python
mocking and the unit test framework.

Another thing I am confused about in your code is that you do not
appear to do any exception handling.  If Python code calls Kea
and an exception is raised, then the Python interpreter will get
From: Francis Dupont <fdupont at isc.org>
Sent: Saturday, 20 January 2018 7:24:03 PM
To: David Hankins
Cc: Dave Cole; kea-dev at lists.isc.org
Subject: Re: [kea-dev] Kea python hook?

About Kea hooks written in Python there was my old proof of concept in
the fdxhook branch available on github so it is feasible even not clearly
easier than to work directly in C++.

About managing leases from hooks there are current developments for
the High Availability. I am not sure they will help you...
I leave details to my colleagues.


Francis Dupont <fdupont at isc.org>

More information about the kea-dev mailing list