I18n safe exceptions
I have noticed that a few exceptions weren't I18n safe meaning they were not being translated if they were raised. In this patch I go through and fix them. Change-Id: If91880db70e6886ddbcbd65f655fc0ac78d92fa1 Closes-Bug: #1511416
This commit is contained in:
@@ -75,13 +75,14 @@ class Ec2ControllerCommon(object):
|
||||
signature):
|
||||
return True
|
||||
raise exception.Unauthorized(
|
||||
message='Invalid EC2 signature.')
|
||||
message=_('Invalid EC2 signature.'))
|
||||
else:
|
||||
raise exception.Unauthorized(
|
||||
message='EC2 signature not supplied.')
|
||||
message=_('EC2 signature not supplied.'))
|
||||
# Raise the exception when credentials.get('signature') is None
|
||||
else:
|
||||
raise exception.Unauthorized(message='EC2 signature not supplied.')
|
||||
raise exception.Unauthorized(
|
||||
message=_('EC2 signature not supplied.'))
|
||||
|
||||
@abc.abstractmethod
|
||||
def authenticate(self, context, credentials=None, ec2Credentials=None):
|
||||
@@ -119,7 +120,8 @@ class Ec2ControllerCommon(object):
|
||||
credentials = ec2credentials
|
||||
|
||||
if 'access' not in credentials:
|
||||
raise exception.Unauthorized(message='EC2 signature not supplied.')
|
||||
raise exception.Unauthorized(
|
||||
message=_('EC2 signature not supplied.'))
|
||||
|
||||
creds_ref = self._get_credentials(credentials['access'])
|
||||
self.check_signature(creds_ref, credentials)
|
||||
@@ -152,7 +154,8 @@ class Ec2ControllerCommon(object):
|
||||
|
||||
roles = metadata_ref.get('roles', [])
|
||||
if not roles:
|
||||
raise exception.Unauthorized(message='User not valid for tenant.')
|
||||
raise exception.Unauthorized(
|
||||
message=_('User not valid for tenant.'))
|
||||
roles_ref = [self.role_api.get_role(role_id) for role_id in roles]
|
||||
|
||||
catalog_ref = self.catalog_api.get_catalog(
|
||||
@@ -255,7 +258,8 @@ class Ec2ControllerCommon(object):
|
||||
ec2_credential_id = utils.hash_access_key(credential_id)
|
||||
creds = self.credential_api.get_credential(ec2_credential_id)
|
||||
if not creds:
|
||||
raise exception.Unauthorized(message='EC2 access key not found.')
|
||||
raise exception.Unauthorized(
|
||||
message=_('EC2 access key not found.'))
|
||||
return self._convert_v3_to_ec2_credential(creds)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user