summaryrefslogtreecommitdiff
path: root/openstackclient/common/clientmanager.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/common/clientmanager.py')
-rw-r--r--openstackclient/common/clientmanager.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index bcb81990..928ab6ee 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."""
@@ -109,24 +111,26 @@ class ClientManager(object):
return
- def get_endpoint_for_service_type(self, service_type):
+ def get_endpoint_for_service_type(self, service_type, region_name=None):
"""Return the endpoint URL for the service type."""
# See if we are using password flow auth, i.e. we have a
# service catalog to select endpoints from
if self._service_catalog:
endpoint = self._service_catalog.url_for(
- service_type=service_type)
+ service_type=service_type, region_name=region_name)
else:
# Hope we were given the correct URL.
endpoint = self._auth_url or self._url
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]
@@ -135,6 +139,7 @@ def get_extension_modules(group):
if init_func:
init_func('x')
+ # Add the plugin to the ClientManager
setattr(
ClientManager,
module.API_NAME,
@@ -143,3 +148,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',
+))