Merge "Don't log an exception for an expected empty catalog."

This commit is contained in:
Jenkins
2012-10-24 05:02:06 +00:00
committed by Gerrit Code Review
3 changed files with 12 additions and 5 deletions

View File

@@ -24,6 +24,11 @@ class EndpointNotFound(Exception):
pass pass
class EmptyCatalog(Exception):
""" The service catalog is empty. """
pass
class ClientException(Exception): class ClientException(Exception):
""" """
The base exception class for all exceptions this library raises. The base exception class for all exceptions this library raises.

View File

@@ -61,6 +61,9 @@ class ServiceCatalog(object):
""" """
catalog = self.catalog.get('serviceCatalog', []) catalog = self.catalog.get('serviceCatalog', [])
if not catalog:
raise exceptions.EmptyCatalog('The service catalog is empty.')
for service in catalog: for service in catalog:
if service['type'] != service_type: if service['type'] != service_type:
continue continue

View File

@@ -122,8 +122,6 @@ class Client(client.HTTPClient):
sc = self.service_catalog.get_token() sc = self.service_catalog.get_token()
self.auth_token = sc['id'] self.auth_token = sc['id']
# Save these since we have them and they'll be useful later # Save these since we have them and they'll be useful later
# NOTE(termie): these used to be in the token and then were removed
# ... why?
self.auth_tenant_id = sc.get('tenant_id') self.auth_tenant_id = sc.get('tenant_id')
self.auth_user_id = sc.get('user_id') self.auth_user_id = sc.get('user_id')
except KeyError: except KeyError:
@@ -136,6 +134,7 @@ class Client(client.HTTPClient):
self.management_url = self.service_catalog.url_for( self.management_url = self.service_catalog.url_for(
attr='region', filter_value=self.region_name, attr='region', filter_value=self.region_name,
endpoint_type='adminURL') endpoint_type='adminURL')
except: except exceptions.EmptyCatalog:
# Unscoped tokens don't return a service catalog # Unscoped tokens don't return a service catalog;
_logger.exception("unable to retrieve service catalog with token") # allow those to pass while any other errors bubble up.
pass