From 93af0ffd4eb107d40026293080a48953daf02690 Mon Sep 17 00:00:00 2001 From: Tom Cocozzello Date: Thu, 29 Oct 2015 10:02:06 -0500 Subject: [PATCH] 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 --- keystone/contrib/ec2/controllers.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/keystone/contrib/ec2/controllers.py b/keystone/contrib/ec2/controllers.py index 78172ec9b2..69bfe6e5c0 100644 --- a/keystone/contrib/ec2/controllers.py +++ b/keystone/contrib/ec2/controllers.py @@ -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)