diff options
| author | Jamie Lennox <jamielennox@redhat.com> | 2015-02-17 16:19:19 +1100 |
|---|---|---|
| committer | Jamie Lennox <jamielennox@redhat.com> | 2015-04-15 11:36:15 +1000 |
| commit | f5e2aab08b9ce71067fade4af576062e5fdb7032 (patch) | |
| tree | 957b9e8ee45eb7ec4ab71b0402c5b3408715702f /keystoneclient/auth/base.py | |
| parent | 96c038004fbd42b391926038ffd7429a7de12500 (diff) | |
| download | python-keystoneclient-f5e2aab08b9ce71067fade4af576062e5fdb7032.tar.gz | |
Provide a means to get all installed plugins
Particular for use in writing error messages and help text it can be
useful to get a list of all the plugins that are installed on the
system. Provide a version that returns the classes as well so that you
don't have to reload the modules if the user is picking one.
Closes-Bug: #1423711
Change-Id: I021249eac8156c2d3ccbbacb7503184b6eb6e784
Diffstat (limited to 'keystoneclient/auth/base.py')
| -rw-r--r-- | keystoneclient/auth/base.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/keystoneclient/auth/base.py b/keystoneclient/auth/base.py index b63d4c7..bfaea61 100644 --- a/keystoneclient/auth/base.py +++ b/keystoneclient/auth/base.py @@ -27,6 +27,34 @@ PLUGIN_NAMESPACE = 'keystoneclient.auth.plugin' IDENTITY_AUTH_HEADER_NAME = 'X-Auth-Token' +def get_available_plugin_names(): + """Get the names of all the plugins that are available on the system. + + This is particularly useful for help and error text to prompt a user for + example what plugins they may specify. + + :returns: A list of names. + :rtype: frozenset + """ + mgr = stevedore.ExtensionManager(namespace=PLUGIN_NAMESPACE, + invoke_on_load=False) + return frozenset(mgr.names()) + + +def get_available_plugin_classes(): + """Retrieve all the plugin classes available on the system. + + :returns: A dict with plugin entrypoint name as the key and the plugin + class as the value. + :rtype: dict + """ + mgr = stevedore.ExtensionManager(namespace=PLUGIN_NAMESPACE, + propagate_map_exceptions=True, + invoke_on_load=False) + + return dict(mgr.map(lambda ext: (ext.entry_point.name, ext.plugin))) + + def get_plugin_class(name): """Retrieve a plugin class by its entrypoint name. |
