[Freeipa-devel] [PATCH] Add plugin versioning and dependency checking

Pavel Zůna pzuna at redhat.com
Tue Mar 2 09:19:45 UTC 2010


Since there weren't any comments on my proposal about plugin versioning 
and dependencies, I decided to make a first implementation, that shows 
what I had in mind.

This patch adds two class variables to plugable.Plugin: VERSION and 
DEPENDENCIES. VERSION is supposed to be a tuple with 2 ints specifying 
the plugin major and minor version number. DEPENDENCIES is supposed to 
be a tuple of tuples. The inner tuples will contain the plugin class 
name (as a string) and a major version number.

The plugable.Registrar class has changed a bit. I decided to remove the 
'override' keyword argument. It wasn't used anywhere. Overriding is now 
automatic based on the plugin class VERSION. Higher version overrides 
lower. This way, we can have several versions of the same plugin living 
in IPA directory (not in API!) at the same time. It allows higher 
versions to easily build on top (extend) older ones.

There's also a new exception:
PluginMissingDependencyError: Plugin 'service' is missing dependency 
plugin 'host' (version 1)

Plugin dependencies are checked when all plugin have been loaded, that 
is when API is finalizing.

An example of what we can do with this approach:

Let's say a customer needs to extend users and groups by storing some 
additional computed information in the entries.

indentity_ex.py:

from ipalib.plugins.user import user, user_add
from ipalib.plugins.group import group, group_add

class user(user):
     VERSION = (2, 0)
     DEPENDENCIES = (('group', 2), )
     takes_params = user.takes_params + (
         # some new params here
     )

api.register(user)

class user_add(user_add):
     VERSION = (2, 0)
     def pre_callback( # I don't feel like writing all the args :)
          dn = super(user_add, self).pre_callback( # and again
          # do some new stuff here
          return dn

api.register(user_add)

# same analogous thing for groups comes here...


Pavel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-plugin-versioning-and-dependency-checking.patch
Type: application/mbox
Size: 4755 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20100302/7d7340e3/attachment.mbox>


More information about the Freeipa-devel mailing list