[Freeipa-devel] [PATCH] Add plugin versioning and dependency checking
Rob Crittenden
rcritten at redhat.com
Tue Mar 2 15:08:33 UTC 2010
Pavel Zůna wrote:
> 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.
Sorry, I had looked at it and never responded. Seeing an implementation
does help though :-)
> 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.
So to override a plugin you need to have a higher version? What if you
want two separate plugins to extend a plugin, there can be only one? For
example, you have one extension that adds some Samba attributes to a
user and another that adds some Solaris-specific attributes. Not
everyone would want both of these but some might, I think this would
throw a DuplicateError.
rob
> 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
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Freeipa-devel mailing list
> Freeipa-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel
More information about the Freeipa-devel
mailing list