diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-10-17 20:13:55 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-10-17 20:13:55 +0000 |
| commit | b40fa49809e8a7d2393429ff140f29b51925999e (patch) | |
| tree | 350abf768cff4e658d3c88e4cc295d9be6ac9dea /openstackclient/common/clientmanager.py | |
| parent | fa9cdef8740dffec347c8e9b1e75af7aae78c623 (diff) | |
| parent | 897418edca52d9856ef7381a5822fce3bcf8a804 (diff) | |
| download | python-openstackclient-b40fa49809e8a7d2393429ff140f29b51925999e.tar.gz | |
Merge "Move plugin stuff to clientmanager"
Diffstat (limited to 'openstackclient/common/clientmanager.py')
| -rw-r--r-- | openstackclient/common/clientmanager.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index 387721a4..dc0791df 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -29,6 +29,8 @@ from openstackclient.identity import client as identity_client LOG = logging.getLogger(__name__) +PLUGIN_MODULES = [] + class ClientCache(object): """Descriptor class for caching created client handles.""" @@ -123,11 +125,13 @@ class ClientManager(object): return endpoint -def get_extension_modules(group): - """Add extension clients""" +# Plugin Support + +def get_plugin_modules(group): + """Find plugin entry points""" mod_list = [] for ep in pkg_resources.iter_entry_points(group): - LOG.debug('found extension %r', ep.name) + LOG.debug('Found plugin %r', ep.name) __import__(ep.module_name) module = sys.modules[ep.module_name] @@ -136,6 +140,7 @@ def get_extension_modules(group): if init_func: init_func('x') + # Add the plugin to the ClientManager setattr( ClientManager, module.API_NAME, @@ -144,3 +149,22 @@ def get_extension_modules(group): ), ) return mod_list + + +def build_plugin_option_parser(parser): + """Add plugin options to the parser""" + + # Loop through extensions to get parser additions + for mod in PLUGIN_MODULES: + parser = mod.build_option_parser(parser) + return parser + + +# Get list of base plugin modules +PLUGIN_MODULES = get_plugin_modules( + 'openstack.cli.base', +) +# Append list of external plugin modules +PLUGIN_MODULES.extend(get_plugin_modules( + 'openstack.cli.extension', +)) |
