plugable: support plugin versioning

Allow multiple incompatible versions of a plugin using the same name. The
current plugins are assumed to be version '1'.

The unique identifier of plugins was changed from plugin name to plugin
name and version. By default, the highest version available at build time
is used. If the plugin is an unknown remote plugin, version of '1' is used
by default.

https://fedorahosted.org/freeipa/ticket/4427

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Jan Cholasta
2016-06-21 12:07:21 +02:00
parent 79d1f58335
commit 4284d4fb4d
11 changed files with 1056 additions and 448 deletions

View File

@@ -1258,6 +1258,8 @@ class Object(HasParam):
namespace = self.api[name]
assert type(namespace) is APINameSpace
for plugin in namespace(): # Equivalent to dict.itervalues()
if plugin is not namespace[plugin.name]:
continue
if plugin.obj_name == self.name:
yield plugin
@@ -1328,10 +1330,16 @@ class Attribute(Plugin):
In practice the `Attribute` class is not used directly, but rather is
only the base class for the `Method` class. Also see the `Object` class.
"""
obj_version = '1'
@property
def obj_name(self):
return self.name.partition('_')[0]
@property
def obj_full_name(self):
return self.obj.full_name
@property
def attr_name(self):
prefix = '{}_'.format(self.obj_name)
@@ -1340,7 +1348,7 @@ class Attribute(Plugin):
@property
def obj(self):
return self.api.Object[self.obj_name]
return self.api.Object[self.obj_name, self.obj_version]
class Method(Attribute, Command):