summaryrefslogtreecommitdiff
path: root/keystoneclient/auth/base.py
diff options
context:
space:
mode:
authorJamie Lennox <jamielennox@redhat.com>2015-02-17 16:19:19 +1100
committerJamie Lennox <jamielennox@redhat.com>2015-04-15 11:36:15 +1000
commitf5e2aab08b9ce71067fade4af576062e5fdb7032 (patch)
tree957b9e8ee45eb7ec4ab71b0402c5b3408715702f /keystoneclient/auth/base.py
parent96c038004fbd42b391926038ffd7429a7de12500 (diff)
downloadpython-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.py28
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.