summaryrefslogtreecommitdiff
path: root/openstackclient/api/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/api/api.py')
-rw-r--r--openstackclient/api/api.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/openstackclient/api/api.py b/openstackclient/api/api.py
index 0b00ff50..04d88f31 100644
--- a/openstackclient/api/api.py
+++ b/openstackclient/api/api.py
@@ -19,6 +19,8 @@ from keystoneauth1 import exceptions as ks_exceptions
from keystoneauth1 import session as ks_session
from osc_lib import exceptions
+from openstackclient.i18n import _
+
class KeystoneSession(object):
"""Wrapper for the Keystone Session
@@ -254,9 +256,11 @@ class BaseAPI(KeystoneSession):
if len(data) == 1:
return data[0]
if len(data) > 1:
- msg = "Multiple %s exist with %s='%s'"
+ msg = _("Multiple %(resource)s exist with %(attr)s='%(value)s'")
raise exceptions.CommandError(
- msg % (resource, attr, value),
+ msg % {'resource': resource,
+ 'attr': attr,
+ 'value': value}
)
# Search by id
@@ -264,8 +268,12 @@ class BaseAPI(KeystoneSession):
data = getlist(kwargs)
if len(data) == 1:
return data[0]
- msg = "No %s with a %s or ID of '%s' found"
- raise exceptions.CommandError(msg % (resource, attr, value))
+ msg = _("No %(resource)s with a %(attr)s or ID of '%(value)s' found")
+ raise exceptions.CommandError(
+ msg % {'resource': resource,
+ 'attr': attr,
+ 'value': value}
+ )
def find_bulk(
self,
@@ -313,10 +321,10 @@ class BaseAPI(KeystoneSession):
bulk_list = self.find_bulk(path, **kwargs)
num_bulk = len(bulk_list)
if num_bulk == 0:
- msg = "none found"
+ msg = _("none found")
raise exceptions.NotFound(msg)
elif num_bulk > 1:
- msg = "many found"
+ msg = _("many found")
raise RuntimeError(msg)
return bulk_list[0]
@@ -343,7 +351,7 @@ class BaseAPI(KeystoneSession):
try:
ret = self.find_one("/%s/detail" % (path), **kwargs)
except ks_exceptions.NotFound:
- msg = "%s not found" % value
+ msg = _("%s not found") % value
raise exceptions.NotFound(msg)
return ret