Merge "Increase readability of 'find()' method and small improvements"
This commit is contained in:
@@ -421,22 +421,22 @@ class CrudManager(Manager):
|
||||
url = self.build_url(dict_args_in_out=kwargs)
|
||||
|
||||
query = self._build_query(kwargs)
|
||||
rl = self._list(
|
||||
'%(url)s%(query)s' % {
|
||||
'url': url,
|
||||
'query': query,
|
||||
},
|
||||
url_query = '%(url)s%(query)s' % {
|
||||
'url': url,
|
||||
'query': query
|
||||
}
|
||||
elements = self._list(
|
||||
url_query,
|
||||
self.collection_key)
|
||||
num = len(rl)
|
||||
|
||||
if num == 0:
|
||||
if not elements:
|
||||
msg = _("No %(name)s matching %(kwargs)s.") % {
|
||||
'name': self.resource_class.__name__, 'kwargs': kwargs}
|
||||
raise ksa_exceptions.NotFound(404, msg)
|
||||
elif num > 1:
|
||||
elif len(elements) > 1:
|
||||
raise ksc_exceptions.NoUniqueMatch
|
||||
else:
|
||||
return rl[0]
|
||||
return elements[0]
|
||||
|
||||
|
||||
class Resource(object):
|
||||
|
@@ -327,7 +327,7 @@ class ServiceCatalogV2(ServiceCatalog):
|
||||
|
||||
def _normalize_endpoint_type(self, endpoint_type):
|
||||
if endpoint_type and 'URL' not in endpoint_type:
|
||||
endpoint_type = endpoint_type + 'URL'
|
||||
endpoint_type += 'URL'
|
||||
|
||||
return endpoint_type
|
||||
|
||||
|
@@ -230,6 +230,7 @@ class Session(object):
|
||||
|
||||
logger.debug(' '.join(string_parts))
|
||||
|
||||
# NOTE(artmr): parameter 'original_ip' value is never used
|
||||
@positional(enforcement=positional.WARN)
|
||||
def request(self, url, method, json=None, original_ip=None,
|
||||
user_agent=None, redirect=None, authenticated=None,
|
||||
|
@@ -51,7 +51,7 @@ class EndpointManager(base.CrudManager):
|
||||
def _validate_interface(self, interface):
|
||||
if interface is not None and interface not in VALID_INTERFACES:
|
||||
msg = _('"interface" must be one of: %s')
|
||||
msg = msg % ', '.join(VALID_INTERFACES)
|
||||
msg %= ', '.join(VALID_INTERFACES)
|
||||
raise exceptions.ValidationError(msg)
|
||||
|
||||
@positional(1, enforcement=positional.WARN)
|
||||
|
Reference in New Issue
Block a user