diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-05-22 22:53:02 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-05-22 22:53:02 +0000 |
commit | 4776495adfadbf5240a9e0f169990ce139af9549 (patch) | |
tree | c02f40a4bfac02b0a60d8a7daad23028416662f5 /keystoneclient/auth | |
parent | d3b1f637e282398b7962e658d304a6e306075b26 (diff) | |
parent | f5e2aab08b9ce71067fade4af576062e5fdb7032 (diff) | |
download | python-keystoneclient-4776495adfadbf5240a9e0f169990ce139af9549.tar.gz |
Merge "Provide a means to get all installed plugins"
Diffstat (limited to 'keystoneclient/auth')
-rw-r--r-- | keystoneclient/auth/__init__.py | 2 | ||||
-rw-r--r-- | keystoneclient/auth/base.py | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/keystoneclient/auth/__init__.py b/keystoneclient/auth/__init__.py index 463bcef..3b761c2 100644 --- a/keystoneclient/auth/__init__.py +++ b/keystoneclient/auth/__init__.py @@ -20,6 +20,8 @@ __all__ = [ # auth.base 'AUTH_INTERFACE', 'BaseAuthPlugin', + 'get_available_plugin_names', + 'get_available_plugin_classes', 'get_plugin_class', 'IDENTITY_AUTH_HEADER_NAME', 'PLUGIN_NAMESPACE', diff --git a/keystoneclient/auth/base.py b/keystoneclient/auth/base.py index 91cf86a..4d8b840 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. |