cleanup openstack-common.conf and sync updated files

Periodic update of latest code from oslo-incubator.

Change-Id: I9f7fccaa9bd3f20d111c7e406d91e588e974a14d
This commit is contained in:
Davanum Srinivas
2015-06-07 10:12:03 -04:00
parent 296c8c2a73
commit b0b202bda2
2 changed files with 32 additions and 11 deletions

View File

@@ -402,7 +402,7 @@ class CrudManager(BaseManager):
'name': self.resource_class.__name__, 'name': self.resource_class.__name__,
'args': kwargs 'args': kwargs
} }
raise exceptions.NotFound(404, msg) raise exceptions.NotFound(msg)
elif num > 1: elif num > 1:
raise exceptions.NoUniqueMatch raise exceptions.NoUniqueMatch
else: else:

View File

@@ -20,6 +20,19 @@
Exception definitions. Exception definitions.
""" """
########################################################################
#
# THIS MODULE IS DEPRECATED
#
# Please refer to
# https://etherpad.openstack.org/p/kilo-oslo-library-proposals for
# the discussion leading to this deprecation.
#
# We recommend checking out the python-openstacksdk project
# (https://launchpad.net/python-openstacksdk) instead.
#
########################################################################
import inspect import inspect
import sys import sys
@@ -54,11 +67,16 @@ class AuthorizationFailure(ClientException):
pass pass
class ConnectionRefused(ClientException): class ConnectionError(ClientException):
"""Cannot connect to API service.""" """Cannot connect to API service."""
pass pass
class ConnectionRefused(ConnectionError):
"""Connection refused while trying to connect to API service."""
pass
class AuthPluginOptionsMissing(AuthorizationFailure): class AuthPluginOptionsMissing(AuthorizationFailure):
"""Auth plugin misses some options.""" """Auth plugin misses some options."""
def __init__(self, opt_names): def __init__(self, opt_names):
@@ -72,7 +90,7 @@ class AuthSystemNotFound(AuthorizationFailure):
"""User has specified an AuthSystem that is not installed.""" """User has specified an AuthSystem that is not installed."""
def __init__(self, auth_system): def __init__(self, auth_system):
super(AuthSystemNotFound, self).__init__( super(AuthSystemNotFound, self).__init__(
_("AuthSystemNotFound: %s") % repr(auth_system)) _("AuthSystemNotFound: %r") % auth_system)
self.auth_system = auth_system self.auth_system = auth_system
@@ -95,7 +113,7 @@ class AmbiguousEndpoints(EndpointException):
"""Found more than one matching endpoint in Service Catalog.""" """Found more than one matching endpoint in Service Catalog."""
def __init__(self, endpoints=None): def __init__(self, endpoints=None):
super(AmbiguousEndpoints, self).__init__( super(AmbiguousEndpoints, self).__init__(
_("AmbiguousEndpoints: %s") % repr(endpoints)) _("AmbiguousEndpoints: %r") % endpoints)
self.endpoints = endpoints self.endpoints = endpoints
@@ -115,9 +133,9 @@ class HttpError(ClientException):
self.response = response self.response = response
self.url = url self.url = url
self.method = method self.method = method
formatted_string = _("%s (HTTP %s)") % (self.message, self.http_status) formatted_string = "%s (HTTP %s)" % (self.message, self.http_status)
if request_id: if request_id:
formatted_string += _(" (Request-ID: %s)") % request_id formatted_string += " (Request-ID: %s)" % request_id
super(HttpError, self).__init__(formatted_string) super(HttpError, self).__init__(formatted_string)
@@ -439,12 +457,15 @@ def from_response(response, method, url):
except ValueError: except ValueError:
pass pass
else: else:
if isinstance(body, dict) and isinstance(body.get("error"), dict): if isinstance(body, dict):
error = body["error"] error = body.get(list(body)[0])
kwargs["message"] = error.get("message") if isinstance(error, dict):
kwargs["details"] = error.get("details") kwargs["message"] = (error.get("message") or
error.get("faultstring"))
kwargs["details"] = (error.get("details") or
six.text_type(body))
elif content_type.startswith("text/"): elif content_type.startswith("text/"):
kwargs["details"] = response.text kwargs["details"] = getattr(response, 'text', '')
try: try:
cls = _code_map[response.status_code] cls = _code_map[response.status_code]