Merge pull request #135 from gabrielhurley/keystone_client_url_for
Fixes #133 -- Keystone Client fetches correct service type and endpoint.
This commit is contained in:
commit
2b0d82c05c
novaclient
@ -46,7 +46,8 @@ class Client(object):
|
||||
# NOTE(ja): need endpoint from service catalog... no lazy auth
|
||||
client.authenticate()
|
||||
self.client = copy.copy(client)
|
||||
endpoint = client.service_catalog.url_for('identity', 'admin')
|
||||
endpoint = client.service_catalog.url_for(service_type='identity',
|
||||
endpoint_type='adminURL')
|
||||
self.client.management_url = endpoint
|
||||
|
||||
self.tenants = tenants.TenantManager(self)
|
||||
|
@ -28,19 +28,20 @@ class ServiceCatalog(object):
|
||||
def get_token(self):
|
||||
return self.catalog['access']['token']['id']
|
||||
|
||||
def url_for(self, attr=None, filter_value=None):
|
||||
def url_for(self, attr=None, filter_value=None,
|
||||
service_type='compute', endpoint_type='publicURL'):
|
||||
"""Fetch the public URL from the Compute service for
|
||||
a particular endpoint attribute. If none given, return
|
||||
the first. See tests for sample service catalog."""
|
||||
catalog = self.catalog['access']['serviceCatalog']
|
||||
|
||||
for service in catalog:
|
||||
if service['type'] != 'compute':
|
||||
if service['type'] != service_type:
|
||||
continue
|
||||
|
||||
endpoints = service['endpoints']
|
||||
for endpoint in endpoints:
|
||||
if not filter_value or endpoint[attr] == filter_value:
|
||||
return endpoint['publicURL']
|
||||
return endpoint[endpoint_type]
|
||||
|
||||
raise novaclient.exceptions.EndpointNotFound()
|
||||
|
Loading…
x
Reference in New Issue
Block a user