Skip to content

Commit

Permalink
Hook up region_name argument
Browse files Browse the repository at this point in the history
Connect the --os-region-name option passed through the CLI
to the call to service_catalog.url_for.

Fixes bug 1080739.

Change-Id: I2d19d62a999a82a91de3883db12bbc24e900de25
  • Loading branch information
bcwaldon committed Nov 19, 2012
1 parent 046d34c commit 3003ed8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions glanceclient/shell.py
Expand Up @@ -311,9 +311,16 @@ def _get_ksclient(self, **kwargs):

def _get_endpoint(self, client, **kwargs):
"""Get an endpoint using the provided keystone client."""
endpoint = client.service_catalog.url_for(
service_type=kwargs.get('service_type') or 'image',
endpoint_type=kwargs.get('endpoint_type') or 'publicURL')
endpoint_kwargs = {
'service_type': kwargs.get('service_type') or 'image',
'endpoint_type': kwargs.get('endpoint_type') or 'publicURL',
}

if kwargs.get('region_name'):
endpoint_kwargs['attr'] = 'region'
endpoint_kwargs['filter_value'] = kwargs.get('region_name')

endpoint = client.service_catalog.url_for(**endpoint_kwargs)
return self._strip_version(endpoint)

def _get_image_url(self, args):
Expand Down Expand Up @@ -389,7 +396,8 @@ def main(self, argv):
'auth_url': args.os_auth_url,
'service_type': args.os_service_type,
'endpoint_type': args.os_endpoint_type,
'insecure': args.insecure
'insecure': args.insecure,
'region_name': args.os_region_name,
}
_ksclient = self._get_ksclient(**kwargs)
token = args.os_auth_token or _ksclient.auth_token
Expand Down

0 comments on commit 3003ed8

Please sign in to comment.