From d6e0a03a937841ee509c37003762fd92c9b762ef Mon Sep 17 00:00:00 2001 From: Bhuvan Arumugam Date: Sat, 23 Jun 2012 22:27:11 -0700 Subject: [PATCH] Support --os-endpoint-type in glanceclient. Bug: 993993 * glanceclient/shellp.py OpenStackImagesShell.get_base_parser(): Parse --os-endpoint-type argument. Default to one defined in os.environ. OpenStackImagesShell._authenticate(): Define endpoint type based on command line argument. Use 'publicURL', if it's not specified in command line and also not defined in os.environ. OpenStackImagesShell.main(): Pass this value to authenticate. Change-Id: I0c0cde5212198eec2a7d75fb2a7cad1cde048c7c --- glanceclient/shell.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/glanceclient/shell.py b/glanceclient/shell.py index 8afee00..7c41464 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -97,6 +97,10 @@ class OpenStackImagesShell(object): default=utils.env('OS_SERVICE_TYPE'), help='Defaults to env[OS_SERVICE_TYPE]') + parser.add_argument('--os-endpoint-type', + default=utils.env('OS_ENDPOINT_TYPE'), + help='Defaults to env[OS_ENDPOINT_TYPE]') + return parser def get_subcommand_parser(self, version): @@ -164,9 +168,10 @@ class OpenStackImagesShell(object): tenant_name=kwargs.get('tenant_name'), auth_url=kwargs.get('auth_url')) service_type = kwargs.get('service_type') or 'image' + endpoint_type = kwargs.get('endpoint_type') or 'publicURL' endpoint = _ksclient.service_catalog.url_for( service_type=service_type, - endpoint_type='publicURL') + endpoint_type=endpoint_type) endpoint = self._strip_version(endpoint) return (endpoint, _ksclient.auth_token) @@ -226,7 +231,8 @@ class OpenStackImagesShell(object): 'tenant_id': args.os_tenant_id, 'tenant_name': args.os_tenant_name, 'auth_url': args.os_auth_url, - 'service_type': args.os_service_type + 'service_type': args.os_service_type, + 'endpoint_type': args.os_endpoint_type } endpoint, token = self._authenticate(**kwargs)