diff options
author | Jan Cholasta <jcholast@redhat.com> | 2016-06-20 08:52:35 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2016-06-28 13:30:49 +0200 |
commit | 9a21964877c4bb64599e75ca708ec83a72abeb51 (patch) | |
tree | a56a9353b3c998a121c9bdc767b58031082945f1 | |
parent | 22f26cfa8e06e08795a6ad611bb7c72f003e65c4 (diff) | |
download | freeipa-9a21964877c4bb64599e75ca708ec83a72abeb51.tar.gz freeipa-9a21964877c4bb64599e75ca708ec83a72abeb51.tar.xz freeipa-9a21964877c4bb64599e75ca708ec83a72abeb51.zip |
misc: generate `plugins` result directly in the command
Move the code that generated result of the `plugins` command from API to
the command itself.
https://fedorahosted.org/freeipa/ticket/4427
Reviewed-By: David Kupka <dkupka@redhat.com>
-rw-r--r-- | ipalib/plugable.py | 5 | ||||
-rw-r--r-- | ipaserver/plugins/misc.py | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 8284cca39..5a5d02fb0 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -671,7 +671,6 @@ class API(ReadOnly): self.__do_if_not_done('load_plugins') production_mode = self.is_production_mode() - plugin_info = {} for base in self.bases: name = base.__name__ @@ -679,9 +678,6 @@ class API(ReadOnly): for klass in six.itervalues(self.__plugins): if not any(issubclass(b, base) for b in klass.bases): continue - plugin_info.setdefault( - '%s.%s' % (klass.__module__, klass.name), - []).append(name) if not self.env.plugins_on_demand: self._get(klass.name) @@ -698,7 +694,6 @@ class API(ReadOnly): assert islocked(instance) self.__finalized = True - self.plugins = tuple((k, tuple(v)) for k, v in plugin_info.items()) if not production_mode: lock(self) diff --git a/ipaserver/plugins/misc.py b/ipaserver/plugins/misc.py index 0628bb19b..7618e23a9 100644 --- a/ipaserver/plugins/misc.py +++ b/ipaserver/plugins/misc.py @@ -133,6 +133,13 @@ class plugins(LocalOrRemote): ) def execute(self, **options): + result = {} + for namespace in self.api: + for plugin in self.api[namespace](): + cls = type(plugin) + key = '{}.{}'.format(cls.__module__, cls.__name__) + result.setdefault(key, []).append(namespace) + return dict( - result=dict(self.api.plugins), + result=result, ) |