Sync from latest oslo-incubator
_i18n.py: * typo - probably old update.py script apiclient/base.py: * 18bf5ca Fix usage of NotFound exception in apiclient.base apiclient/client.py: * 002999b Curl statements to include globoff for IPv6 URLs apiclient/utils.py: * a908d66 Remove uuidutils apiclient/exceptions.py: * 03e6272 Add ConnectionError exception * 5985b35 Prefer delayed %r formatting over explicit repr use * fd8dc0c Handle different format of api exception Change-Id: Ia8d4d40089cc5577e86c84cd3b20b18ee9259414
This commit is contained in:
committed by
Davanum Srinivas (dims)
parent
7f58e6f7db
commit
80d8f1a056
@@ -40,6 +40,6 @@ try:
|
||||
_LC = _translators.log_critical
|
||||
except ImportError:
|
||||
# NOTE(dims): Support for cases where a project wants to use
|
||||
# code from magnumclient-incubator, but is not ready to be internationalized
|
||||
# code from oslo-incubator, but is not ready to be internationalized
|
||||
# (like tempest)
|
||||
_ = _LI = _LW = _LE = _LC = lambda x: x
|
||||
|
||||
@@ -402,7 +402,7 @@ class CrudManager(BaseManager):
|
||||
'name': self.resource_class.__name__,
|
||||
'args': kwargs
|
||||
}
|
||||
raise exceptions.NotFound(404, msg)
|
||||
raise exceptions.NotFound(msg)
|
||||
elif num > 1:
|
||||
raise exceptions.NoUniqueMatch
|
||||
else:
|
||||
|
||||
@@ -118,7 +118,7 @@ class HTTPClient(object):
|
||||
return
|
||||
|
||||
string_parts = [
|
||||
"curl -i",
|
||||
"curl -g -i",
|
||||
"-X '%s'" % method,
|
||||
"'%s'" % url,
|
||||
]
|
||||
|
||||
@@ -67,11 +67,16 @@ class AuthorizationFailure(ClientException):
|
||||
pass
|
||||
|
||||
|
||||
class ConnectionRefused(ClientException):
|
||||
class ConnectionError(ClientException):
|
||||
"""Cannot connect to API service."""
|
||||
pass
|
||||
|
||||
|
||||
class ConnectionRefused(ConnectionError):
|
||||
"""Connection refused while trying to connect to API service."""
|
||||
pass
|
||||
|
||||
|
||||
class AuthPluginOptionsMissing(AuthorizationFailure):
|
||||
"""Auth plugin misses some options."""
|
||||
def __init__(self, opt_names):
|
||||
@@ -85,7 +90,7 @@ class AuthSystemNotFound(AuthorizationFailure):
|
||||
"""User has specified an AuthSystem that is not installed."""
|
||||
def __init__(self, auth_system):
|
||||
super(AuthSystemNotFound, self).__init__(
|
||||
_("AuthSystemNotFound: %s") % repr(auth_system))
|
||||
_("AuthSystemNotFound: %r") % auth_system)
|
||||
self.auth_system = auth_system
|
||||
|
||||
|
||||
@@ -108,7 +113,7 @@ class AmbiguousEndpoints(EndpointException):
|
||||
"""Found more than one matching endpoint in Service Catalog."""
|
||||
def __init__(self, endpoints=None):
|
||||
super(AmbiguousEndpoints, self).__init__(
|
||||
_("AmbiguousEndpoints: %s") % repr(endpoints))
|
||||
_("AmbiguousEndpoints: %r") % endpoints)
|
||||
self.endpoints = endpoints
|
||||
|
||||
|
||||
@@ -452,12 +457,15 @@ def from_response(response, method, url):
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
if isinstance(body, dict) and isinstance(body.get("error"), dict):
|
||||
error = body["error"]
|
||||
kwargs["message"] = error.get("message")
|
||||
kwargs["details"] = error.get("details")
|
||||
if isinstance(body, dict):
|
||||
error = body.get(list(body)[0])
|
||||
if isinstance(error, dict):
|
||||
kwargs["message"] = (error.get("message") or
|
||||
error.get("faultstring"))
|
||||
kwargs["details"] = (error.get("details") or
|
||||
six.text_type(body))
|
||||
elif content_type.startswith("text/"):
|
||||
kwargs["details"] = response.text
|
||||
kwargs["details"] = getattr(response, 'text', '')
|
||||
|
||||
try:
|
||||
cls = _code_map[response.status_code]
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
########################################################################
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnumclient.openstack.common._i18n import _
|
||||
from magnumclient.openstack.common.apiclient import exceptions
|
||||
from magnumclient.openstack.common import uuidutils
|
||||
|
||||
|
||||
def find_resource(manager, name_or_id, **find_args):
|
||||
|
||||
Reference in New Issue
Block a user