[openstack-dev] [Nova] adding hooks

Russell Bryant rbryant at redhat.com
Tue Nov 20 15:40:58 UTC 2012


Greetings,

There is currently a patch in the review queue for nova that adds hooks.

https://review.openstack.org/#/c/16336/

I like the concept, but I think it could benefit from some design
discussion.  That's difficult on gerrit and much better suited for the
mailing list, so here we are.

My biggest design comment on this has been that I think it needs to
support loading custom modules that register hooks.  I also would like
to minimize how much of this we have to expose to the configuration.
Here's the general functionality I have in mind:

   I want to hook into nova at the defined 'foo' hook point.  I write a
   hook module and drop it into the predefined directory
   /path/to/nova/modules/.  Nova should automatically import everything
   in this custom module directory and the hooks get registered.

   The registration mechanism could either be the modules calling an API
   to register their hooks at load time, or nova could scan the module
   for hooks and register them automatically.  Whichever is more
   Pythonic is fine with me.

The only configuration option I see that would be needed here is the
ability to customize with directory (or directories) are used for
loading custom modules.

There are some related efforts going on here that need to be considered,
as well:

1) nova/loadables.py

This is used in the patch right now.  Some comments on this approach:

 - It means nova scans the module and automatically registers hook
   classes that are of the right type.  I think that makes sense, but
   is that the most Pythonic approach for this kind of thing?

 - This will need to be extended if we want to support a directory of
   user provided modules that have hooks in them.  I think that's
   pretty important for the primary hook use case.

2) nova/openstack/common/pluginmanager.py

I haven't looked into this lately, but at a high level, there seems to
be some overlap here.  I'd like to see this analyzed for how it could
apply to hooks.  If it doesn't fit, that's fine, I just want to make
sure it's considered and the results documented.

Thanks,

-- 
Russell Bryant



More information about the OpenStack-dev mailing list