Merge "Adds missing log hints for level E/I/W"

This commit is contained in:
Jenkins 2014-11-21 21:02:15 +00:00 committed by Gerrit Code Review
commit b55aa76b62
23 changed files with 107 additions and 110 deletions

View File

@ -28,7 +28,7 @@ from keystone.common import dependency
from keystone.common import validation from keystone.common import validation
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.models import token_model from keystone.models import token_model
from keystone.openstack.common import log from keystone.openstack.common import log
@ -74,7 +74,7 @@ class Tenant(controller.V2Controller):
token_ref = token_model.KeystoneToken(token_id=context['token_id'], token_ref = token_model.KeystoneToken(token_id=context['token_id'],
token_data=token_data) token_data=token_data)
except exception.NotFound as e: except exception.NotFound as e:
LOG.warning(_('Authentication failed: %s'), e) LOG.warning(_LW('Authentication failed: %s'), e)
raise exception.Unauthorized(e) raise exception.Unauthorized(e)
tenant_refs = ( tenant_refs = (
@ -709,10 +709,10 @@ class RoleAssignmentV3(controller.V3Controller):
if 'role' in ref and 'id' in ref['role']: if 'role' in ref and 'id' in ref['role']:
role_id = ref['role']['id'] role_id = ref['role']['id']
LOG.warning( LOG.warning(
_('Group %(group)s not found for role-assignment - ' _LW('Group %(group)s not found for role-assignment - '
'%(target)s with Role: %(role)s'), { '%(target)s with Role: %(role)s'), {
'group': ref['group']['id'], 'target': target, 'group': ref['group']['id'], 'target': target,
'role': role_id}) 'role': role_id})
return members return members
def _build_user_assignment_equivalent_of_group( def _build_user_assignment_equivalent_of_group(

View File

@ -28,7 +28,7 @@ from keystone.common import wsgi
from keystone import config from keystone import config
from keystone.contrib import federation from keystone.contrib import federation
from keystone import exception from keystone import exception
from keystone.i18n import _, _LI from keystone.i18n import _, _LI, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
@ -438,25 +438,26 @@ class Auth(controller.V3Controller):
user_ref['id'], default_project_id): user_ref['id'], default_project_id):
auth_info.set_scope(project_id=default_project_id) auth_info.set_scope(project_id=default_project_id)
else: else:
msg = _("User %(user_id)s doesn't have access to" msg = _LW("User %(user_id)s doesn't have access to"
" default project %(project_id)s. The token will" " default project %(project_id)s. The token"
" be unscoped rather than scoped to the project.") " will be unscoped rather than scoped to the"
" project.")
LOG.warning(msg, LOG.warning(msg,
{'user_id': user_ref['id'], {'user_id': user_ref['id'],
'project_id': default_project_id}) 'project_id': default_project_id})
else: else:
msg = _("User %(user_id)s's default project %(project_id)s is" msg = _LW("User %(user_id)s's default project %(project_id)s"
" disabled. The token will be unscoped rather than" " is disabled. The token will be unscoped rather"
" scoped to the project.") " than scoped to the project.")
LOG.warning(msg, LOG.warning(msg,
{'user_id': user_ref['id'], {'user_id': user_ref['id'],
'project_id': default_project_id}) 'project_id': default_project_id})
except (exception.ProjectNotFound, exception.DomainNotFound): except (exception.ProjectNotFound, exception.DomainNotFound):
# default project or default project domain doesn't exist, # default project or default project domain doesn't exist,
# will issue unscoped token instead # will issue unscoped token instead
msg = _("User %(user_id)s's default project %(project_id)s not" msg = _LW("User %(user_id)s's default project %(project_id)s not"
" found. The token will be unscoped rather than" " found. The token will be unscoped rather than"
" scoped to the project.") " scoped to the project.")
LOG.warning(msg, {'user_id': user_ref['id'], LOG.warning(msg, {'user_id': user_ref['id'],
'project_id': default_project_id}) 'project_id': default_project_id})

View File

@ -53,7 +53,7 @@ def format_url(url, substitutions):
try: try:
result = url.replace('$(', '%(') % substitutions result = url.replace('$(', '%(') % substitutions
except AttributeError: except AttributeError:
LOG.error(_('Malformed endpoint - %(url)r is not a string'), LOG.error(_LE('Malformed endpoint - %(url)r is not a string'),
{"url": url}) {"url": url})
raise exception.MalformedEndpoint(endpoint=url) raise exception.MalformedEndpoint(endpoint=url)
except KeyError as e: except KeyError as e:

View File

@ -25,7 +25,7 @@ from keystone.common import sql
from keystone.common.sql import migration_helpers from keystone.common.sql import migration_helpers
from keystone.common import utils from keystone.common import utils
from keystone import config from keystone import config
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone import identity from keystone import identity
from keystone.openstack.common import log from keystone.openstack.common import log
from keystone import token from keystone import token
@ -141,9 +141,8 @@ class PKISetup(BaseCertificateSetup):
@classmethod @classmethod
def main(cls): def main(cls):
msg = _('keystone-manage pki_setup is not recommended for production ' LOG.warn(_LW('keystone-manage pki_setup is not recommended for '
'use.') 'production use.'))
LOG.warn(msg)
keystone_user_id, keystone_group_id = cls.get_user_group() keystone_user_id, keystone_group_id = cls.get_user_group()
conf_pki = openssl.ConfigurePKI(keystone_user_id, keystone_group_id, conf_pki = openssl.ConfigurePKI(keystone_user_id, keystone_group_id,
rebuild=CONF.command.rebuild) rebuild=CONF.command.rebuild)
@ -161,9 +160,8 @@ class SSLSetup(BaseCertificateSetup):
@classmethod @classmethod
def main(cls): def main(cls):
msg = _('keystone-manage ssl_setup is not recommended for production ' LOG.warn(_LW('keystone-manage ssl_setup is not recommended for '
'use.') 'production use.'))
LOG.warn(msg)
keystone_user_id, keystone_group_id = cls.get_user_group() keystone_user_id, keystone_group_id = cls.get_user_group()
conf_ssl = openssl.ConfigureSSL(keystone_user_id, keystone_group_id, conf_ssl = openssl.ConfigureSSL(keystone_user_id, keystone_group_id,
rebuild=CONF.command.rebuild) rebuild=CONF.command.rebuild)

View File

@ -17,7 +17,7 @@
# under the License. # under the License.
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.models import token_model from keystone.models import token_model
from keystone.openstack.common import log from keystone.openstack.common import log
@ -51,7 +51,7 @@ def token_to_auth_context(token):
try: try:
auth_context['user_id'] = token.user_id auth_context['user_id'] = token.user_id
except KeyError: except KeyError:
LOG.warning(_('RBAC: Invalid user data in token')) LOG.warning(_LW('RBAC: Invalid user data in token'))
raise exception.Unauthorized() raise exception.Unauthorized()
if token.project_scoped: if token.project_scoped:

View File

@ -22,7 +22,7 @@ from oslo.utils import timeutils
import six import six
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
@ -400,10 +400,10 @@ class MongoApi(object):
existing_value = index_data['expireAfterSeconds'] existing_value = index_data['expireAfterSeconds']
fld_present = 'doc_date' in index_data['key'][0] fld_present = 'doc_date' in index_data['key'][0]
if fld_present and existing_value > -1 and ttl_seconds < 1: if fld_present and existing_value > -1 and ttl_seconds < 1:
msg = _('TTL index already exists on db collection ' msg = _LW('TTL index already exists on db collection '
'<%(c_name)s>, remove index <%(indx_name)s> first' '<%(c_name)s>, remove index <%(indx_name)s> '
' to make updated mongo_ttl_seconds value to be ' 'first to make updated mongo_ttl_seconds value '
' effective') 'to be effective')
LOG.warn(msg, {'c_name': coll_name, LOG.warn(msg, {'c_name': coll_name,
'indx_name': indx_name}) 'indx_name': indx_name})

View File

@ -21,7 +21,7 @@ from oslo.utils import importutils
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LE
from keystone.openstack.common import log from keystone.openstack.common import log
@ -97,8 +97,8 @@ def build_cache_config():
try: try:
(argname, argvalue) = argument.split(':', 1) (argname, argvalue) = argument.split(':', 1)
except ValueError: except ValueError:
msg = _('Unable to build cache config-key. Expected format ' msg = _LE('Unable to build cache config-key. Expected format '
'"<argname>:<value>". Skipping unknown format: %s') '"<argname>:<value>". Skipping unknown format: %s')
LOG.error(msg, argument) LOG.error(msg, argument)
continue continue

View File

@ -22,7 +22,7 @@ from keystone.common import utils
from keystone.common import wsgi from keystone.common import wsgi
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.models import token_model from keystone.models import token_model
from keystone.openstack.common import log from keystone.openstack.common import log
@ -74,7 +74,7 @@ def _build_policy_check_credentials(self, action, context, kwargs):
# backing store. # backing store.
wsgi.validate_token_bind(context, token_ref) wsgi.validate_token_bind(context, token_ref)
except exception.TokenNotFound: except exception.TokenNotFound:
LOG.warning(_('RBAC: Invalid token')) LOG.warning(_LW('RBAC: Invalid token'))
raise exception.Unauthorized() raise exception.Unauthorized()
auth_context = authorization.token_to_auth_context(token_ref) auth_context = authorization.token_to_auth_context(token_ref)
@ -99,7 +99,7 @@ def protected(callback=None):
@functools.wraps(f) @functools.wraps(f)
def inner(self, context, *args, **kwargs): def inner(self, context, *args, **kwargs):
if 'is_admin' in context and context['is_admin']: if 'is_admin' in context and context['is_admin']:
LOG.warning(_('RBAC: Bypassing authorization')) LOG.warning(_LW('RBAC: Bypassing authorization'))
elif callback is not None: elif callback is not None:
prep_info = {'f_name': f.__name__, prep_info = {'f_name': f.__name__,
'input_attr': kwargs} 'input_attr': kwargs}
@ -196,7 +196,7 @@ def filterprotected(*filters):
LOG.debug('RBAC: Authorization granted') LOG.debug('RBAC: Authorization granted')
else: else:
LOG.warning(_('RBAC: Bypassing authorization')) LOG.warning(_LW('RBAC: Bypassing authorization'))
return f(self, context, filters, **kwargs) return f(self, context, filters, **kwargs)
return wrapper return wrapper
return _filterprotected return _filterprotected
@ -585,15 +585,15 @@ class V3Controller(wsgi.Application):
_('domain_id is required as part of entity')) _('domain_id is required as part of entity'))
except (exception.TokenNotFound, except (exception.TokenNotFound,
exception.UnsupportedTokenVersionException): exception.UnsupportedTokenVersionException):
LOG.warning(_('Invalid token found while getting domain ID ' LOG.warning(_LW('Invalid token found while getting domain ID '
'for list request')) 'for list request'))
raise exception.Unauthorized() raise exception.Unauthorized()
if token_ref.domain_scoped: if token_ref.domain_scoped:
return token_ref.domain_id return token_ref.domain_id
else: else:
LOG.warning( LOG.warning(
_('No domain information specified as part of list request')) _LW('No domain information specified as part of list request'))
raise exception.Unauthorized() raise exception.Unauthorized()
def _get_domain_id_from_token(self, context): def _get_domain_id_from_token(self, context):
@ -620,8 +620,8 @@ class V3Controller(wsgi.Application):
_('A domain-scoped token must be used')) _('A domain-scoped token must be used'))
except (exception.TokenNotFound, except (exception.TokenNotFound,
exception.UnsupportedTokenVersionException): exception.UnsupportedTokenVersionException):
LOG.warning(_('Invalid token found while getting domain ID ' LOG.warning(_LW('Invalid token found while getting domain ID '
'for list request')) 'for list request'))
raise exception.Unauthorized() raise exception.Unauthorized()
if token_ref.domain_scoped: if token_ref.domain_scoped:
@ -656,7 +656,7 @@ class V3Controller(wsgi.Application):
""" """
if 'is_admin' in context and context['is_admin']: if 'is_admin' in context and context['is_admin']:
LOG.warning(_('RBAC: Bypassing authorization')) LOG.warning(_LW('RBAC: Bypassing authorization'))
else: else:
action = 'identity:%s' % prep_info['f_name'] action = 'identity:%s' % prep_info['f_name']
# TODO(henry-nash) need to log the target attributes as well # TODO(henry-nash) need to log the target attributes as well

View File

@ -26,9 +26,7 @@ import eventlet
import eventlet.wsgi import eventlet.wsgi
import greenlet import greenlet
from keystone.i18n import _ from keystone.i18n import _LE, _LI
from keystone.i18n import _LE
from keystone.i18n import _LI
from keystone.openstack.common import log from keystone.openstack.common import log
@ -184,5 +182,5 @@ class Server(object):
# Wait until all servers have completed running # Wait until all servers have completed running
pass pass
except Exception: except Exception:
LOG.exception(_('Server error')) LOG.exception(_LE('Server error'))
raise raise

View File

@ -1650,8 +1650,8 @@ class BaseLdap(object):
not_deleted_nodes.append(node_dn) not_deleted_nodes.append(node_dn)
if not_deleted_nodes: if not_deleted_nodes:
LOG.warn(_("When deleting entries for %(search_base)s, could not" LOG.warn(_LW("When deleting entries for %(search_base)s, could not"
" delete nonexistent entries %(entries)s%(dots)s"), " delete nonexistent entries %(entries)s%(dots)s"),
{'search_base': search_base, {'search_base': search_base,
'entries': not_deleted_nodes[:3], 'entries': not_deleted_nodes[:3],
'dots': '...' if len(not_deleted_nodes) > 3 else ''}) 'dots': '...' if len(not_deleted_nodes) > 3 else ''})

View File

@ -32,7 +32,7 @@ from six import moves
from keystone.common import config from keystone.common import config
from keystone.common import environment from keystone.common import environment
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LE, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
@ -101,8 +101,8 @@ def verify_length_and_trunc_password(password):
raise exception.PasswordVerificationError(size=max_length) raise exception.PasswordVerificationError(size=max_length)
else: else:
LOG.warning( LOG.warning(
_('Truncating user password to ' _LW('Truncating user password to '
'%d characters.'), max_length) '%d characters.'), max_length)
return password[:max_length] return password[:max_length]
else: else:
return password return password
@ -278,7 +278,7 @@ def setup_remote_pydev_debug():
stderrToServer=True) stderrToServer=True)
return True return True
except Exception: except Exception:
LOG.exception(_( LOG.exception(_LE(
'Error setting up the debug environment. Verify that the ' 'Error setting up the debug environment. Verify that the '
'option --debug-url has the format <host>:<port> and that a ' 'option --debug-url has the format <host>:<port> and that a '
'debugger processes is listening on that port.')) 'debugger processes is listening on that port.'))

View File

@ -16,7 +16,7 @@
from keystone.common import dependency from keystone.common import dependency
from keystone.common import manager from keystone.common import manager
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _LI
from keystone import notifications from keystone import notifications
from keystone.openstack.common import log from keystone.openstack.common import log
@ -61,18 +61,18 @@ class ExampleManager(manager.Manager):
def project_deleted_callback(self, service, resource_type, operation, def project_deleted_callback(self, service, resource_type, operation,
payload): payload):
# The code below is merely an example. # The code below is merely an example.
msg = _('Received the following notification: service %(service)s, ' msg = _LI('Received the following notification: service %(service)s, '
'resource_type: %(resource_type)s, operation %(operation)s ' 'resource_type: %(resource_type)s, operation %(operation)s '
'payload %(payload)s') 'payload %(payload)s')
LOG.info(msg, {'service': service, 'resource_type': resource_type, LOG.info(msg, {'service': service, 'resource_type': resource_type,
'operation': operation, 'payload': payload}) 'operation': operation, 'payload': payload})
def project_created_callback(self, service, resource_type, operation, def project_created_callback(self, service, resource_type, operation,
payload): payload):
# The code below is merely an example. # The code below is merely an example.
msg = _('Received the following notification: service %(service)s, ' msg = _LI('Received the following notification: service %(service)s, '
'resource_type: %(resource_type)s, operation %(operation)s ' 'resource_type: %(resource_type)s, operation %(operation)s '
'payload %(payload)s') 'payload %(payload)s')
LOG.info(msg, {'service': service, 'resource_type': resource_type, LOG.info(msg, {'service': service, 'resource_type': resource_type,
'operation': operation, 'payload': payload}) 'operation': operation, 'payload': payload})

View File

@ -20,7 +20,7 @@ import six
from keystone.common import config from keystone.common import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
@ -255,7 +255,7 @@ class RuleProcessor(object):
if 'user' in identity_value: if 'user' in identity_value:
# if a mapping outputs more than one user name, log it # if a mapping outputs more than one user name, log it
if user_name is not None: if user_name is not None:
LOG.warning(_('Ignoring user name %s'), LOG.warning(_LW('Ignoring user name %s'),
identity_value['user']['name']) identity_value['user']['name'])
else: else:
user_name = identity_value['user']['name'] user_name = identity_value['user']['name']

View File

@ -16,7 +16,7 @@ from oslo.utils import encodeutils
import six import six
from keystone.common import config from keystone.common import config
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
@ -46,7 +46,7 @@ class Error(Exception):
if _FATAL_EXCEPTION_FORMAT_ERRORS: if _FATAL_EXCEPTION_FORMAT_ERRORS:
raise raise
else: else:
LOG.warning(_('missing exception kwargs (programmer error)')) LOG.warning(_LW('missing exception kwargs (programmer error)'))
message = self.message_format message = self.message_format
super(Error, self).__init__(message) super(Error, self).__init__(message)

View File

@ -18,7 +18,7 @@ from keystone.common import controller
from keystone.common import dependency from keystone.common import dependency
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
@ -134,8 +134,8 @@ class User(controller.V2Controller):
# old tenant. This could occur if roles aren't found # old tenant. This could occur if roles aren't found
# or if the project is invalid or if there are no roles # or if the project is invalid or if there are no roles
# for the user on that project. # for the user on that project.
msg = _('Unable to remove user %(user)s from ' msg = _LW('Unable to remove user %(user)s from '
'%(tenant)s.') '%(tenant)s.')
LOG.warning(msg, {'user': user_id, LOG.warning(msg, {'user': user_id,
'tenant': old_user_ref['tenantId']}) 'tenant': old_user_ref['tenantId']})
@ -153,7 +153,7 @@ class User(controller.V2Controller):
# that the project is invalid or roles are some how # that the project is invalid or roles are some how
# incorrect. This shouldn't prevent the return of the # incorrect. This shouldn't prevent the return of the
# new ref. # new ref.
msg = _('Unable to add user %(user)s to %(tenant)s.') msg = _LW('Unable to add user %(user)s to %(tenant)s.')
LOG.warning(msg, {'user': user_id, LOG.warning(msg, {'user': user_id,
'tenant': user_ref['tenantId']}) 'tenant': user_ref['tenantId']})

View File

@ -29,7 +29,7 @@ from keystone.common import driver_hints
from keystone.common import manager from keystone.common import manager
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LW
from keystone.identity.mapping_backends import mapping from keystone.identity.mapping_backends import mapping
from keystone import notifications from keystone import notifications
from keystone.openstack.common import log from keystone.openstack.common import log
@ -115,7 +115,7 @@ class DomainConfigs(dict):
domain_ref = assignment_api.get_domain_by_name(domain_name) domain_ref = assignment_api.get_domain_by_name(domain_name)
except exception.DomainNotFound: except exception.DomainNotFound:
LOG.warning( LOG.warning(
_('Invalid domain name (%s) found in config file name'), _LW('Invalid domain name (%s) found in config file name'),
domain_name) domain_name)
return return
@ -141,7 +141,7 @@ class DomainConfigs(dict):
conf_dir = CONF.identity.domain_config_dir conf_dir = CONF.identity.domain_config_dir
if not os.path.exists(conf_dir): if not os.path.exists(conf_dir):
LOG.warning(_('Unable to locate domain config directory: %s'), LOG.warning(_LW('Unable to locate domain config directory: %s'),
conf_dir) conf_dir)
return return

View File

@ -22,7 +22,7 @@ from keystone.common import serializer
from keystone.common import utils from keystone.common import utils
from keystone.common import wsgi from keystone.common import wsgi
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _LW
from keystone.models import token_model from keystone.models import token_model
from keystone.openstack.common import log from keystone.openstack.common import log
from keystone.openstack.common import versionutils from keystone.openstack.common import versionutils
@ -262,7 +262,7 @@ class AuthContextMiddleware(wsgi.Middleware):
wsgi.validate_token_bind(context, token_ref) wsgi.validate_token_bind(context, token_ref)
return authorization.token_to_auth_context(token_ref) return authorization.token_to_auth_context(token_ref)
except exception.TokenNotFound: except exception.TokenNotFound:
LOG.warning(_('RBAC: Invalid token')) LOG.warning(_LW('RBAC: Invalid token'))
raise exception.Unauthorized() raise exception.Unauthorized()
def process_request(self, request): def process_request(self, request):
@ -272,7 +272,7 @@ class AuthContextMiddleware(wsgi.Middleware):
return return
if authorization.AUTH_CONTEXT_ENV in request.environ: if authorization.AUTH_CONTEXT_ENV in request.environ:
msg = _('Auth context already exists in the request environment') msg = _LW('Auth context already exists in the request environment')
LOG.warning(msg) LOG.warning(msg)
return return

View File

@ -28,7 +28,7 @@ from pycadf import credential
from pycadf import eventfactory from pycadf import eventfactory
from pycadf import resource from pycadf import resource
from keystone.i18n import _ from keystone.i18n import _, _LE
from keystone.openstack.common import log from keystone.openstack.common import log
@ -220,7 +220,7 @@ def _get_notifier():
transport = messaging.get_transport(CONF) transport = messaging.get_transport(CONF)
_notifier = messaging.Notifier(transport, "identity.%s" % host) _notifier = messaging.Notifier(transport, "identity.%s" % host)
except Exception: except Exception:
LOG.exception(_("Failed to construct notifier")) LOG.exception(_LE("Failed to construct notifier"))
_notifier = False _notifier = False
return _notifier return _notifier
@ -264,7 +264,7 @@ def _send_notification(operation, resource_type, resource_id, public=True):
try: try:
notifier.info(context, event_type, payload) notifier.info(context, event_type, payload)
except Exception: except Exception:
LOG.exception(_( LOG.exception(_LE(
'Failed to send %(res_id)s %(event_type)s notification'), 'Failed to send %(res_id)s %(event_type)s notification'),
{'res_id': resource_id, 'event_type': event_type}) {'res_id': resource_id, 'event_type': event_type})
@ -452,7 +452,7 @@ def _send_audit_notification(action, initiator, outcome, **kwargs):
except Exception: except Exception:
# diaper defense: any exception that occurs while emitting the # diaper defense: any exception that occurs while emitting the
# notification should not interfere with the API request # notification should not interfere with the API request
LOG.exception(_( LOG.exception(_LE(
'Failed to send %(action)s %(event_type)s notification'), 'Failed to send %(action)s %(event_type)s notification'),
{'action': action, 'event_type': event_type}) {'action': action, 'event_type': event_type})

View File

@ -49,7 +49,7 @@ from keystone.common import utils as common_utils
from keystone import config from keystone import config
from keystone import controllers from keystone import controllers
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _LW
from keystone import notifications from keystone import notifications
from keystone.openstack.common import log from keystone.openstack.common import log
from keystone import service from keystone import service
@ -143,7 +143,7 @@ def checkout_vendor(repo, rev):
with open(modcheck, 'w') as fd: with open(modcheck, 'w') as fd:
fd.write('1') fd.write('1')
except environment.subprocess.CalledProcessError: except environment.subprocess.CalledProcessError:
LOG.warning(_('Failed to checkout %s'), repo) LOG.warning(_LW('Failed to checkout %s'), repo)
os.chdir(working_dir) os.chdir(working_dir)
return revdir return revdir

View File

@ -22,7 +22,7 @@ import six
from keystone.common import kvs from keystone.common import kvs
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LE, _LW
from keystone.openstack.common import log from keystone.openstack.common import log
from keystone import token from keystone import token
from keystone.token import provider from keystone.token import provider
@ -54,12 +54,12 @@ class Token(token.persistence.Driver):
if self.__class__ == Token: if self.__class__ == Token:
# NOTE(morganfainberg): Only warn if the base KVS implementation # NOTE(morganfainberg): Only warn if the base KVS implementation
# is instantiated. # is instantiated.
LOG.warn(_('It is recommended to only use the base ' LOG.warn(_LW('It is recommended to only use the base '
'key-value-store implementation for the token driver ' 'key-value-store implementation for the token driver '
'for testing purposes. Please use ' 'for testing purposes. Please use '
'keystone.token.persistence.backends.memcache.Token ' 'keystone.token.persistence.backends.memcache.Token '
'or keystone.token.persistence.backends.sql.Token ' 'or keystone.token.persistence.backends.sql.Token '
'instead.')) 'instead.'))
def _prefix_token_id(self, token_id): def _prefix_token_id(self, token_id):
return 'token-%s' % token_id.encode('utf-8') return 'token-%s' % token_id.encode('utf-8')
@ -203,8 +203,8 @@ class Token(token.persistence.Driver):
expires = timeutils.normalize_time(expires) expires = timeutils.normalize_time(expires)
if expires < current_time: if expires < current_time:
LOG.warning(_('Token `%s` is expired, not adding to the ' LOG.warning(_LW('Token `%s` is expired, not adding to the '
'revocation list.'), data['id']) 'revocation list.'), data['id'])
return return
revoked_token_data['expires'] = timeutils.isotime(expires, revoked_token_data['expires'] = timeutils.isotime(expires,
@ -223,10 +223,10 @@ class Token(token.persistence.Driver):
# be recoverable. Keystone cannot control external applications # be recoverable. Keystone cannot control external applications
# from changing a key in some backends, however, it is possible to # from changing a key in some backends, however, it is possible to
# gracefully handle and notify of this event. # gracefully handle and notify of this event.
LOG.error(_('Reinitializing revocation list due to error ' LOG.error(_LE('Reinitializing revocation list due to error '
'in loading revocation list from backend. ' 'in loading revocation list from backend. '
'Expected `list` type got `%(type)s`. Old ' 'Expected `list` type got `%(type)s`. Old '
'revocation list data: %(list)r'), 'revocation list data: %(list)r'),
{'type': type(token_list), 'list': token_list}) {'type': type(token_list), 'list': token_list})
token_list = [] token_list = []
@ -237,8 +237,8 @@ class Token(token.persistence.Driver):
expires_at = timeutils.normalize_time( expires_at = timeutils.normalize_time(
timeutils.parse_isotime(token_data['expires'])) timeutils.parse_isotime(token_data['expires']))
except ValueError: except ValueError:
LOG.warning(_('Removing `%s` from revocation list due to ' LOG.warning(_LW('Removing `%s` from revocation list due to '
'invalid expires data in revocation list.'), 'invalid expires data in revocation list.'),
token_data.get('id', 'INVALID_TOKEN_DATA')) token_data.get('id', 'INVALID_TOKEN_DATA'))
continue continue
if expires_at > current_time: if expires_at > current_time:

View File

@ -29,7 +29,7 @@ from keystone.common import dependency
from keystone.common import manager from keystone.common import manager
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LE, _LW
from keystone.models import token_model from keystone.models import token_model
from keystone import notifications from keystone import notifications
from keystone.openstack.common import log from keystone.openstack.common import log
@ -131,9 +131,9 @@ class Manager(manager.Manager):
""" """
if CONF.signing.token_format: if CONF.signing.token_format:
LOG.warn(_('[signing] token_format is deprecated. ' LOG.warn(_LW('[signing] token_format is deprecated. '
'Please change to setting the [token] provider ' 'Please change to setting the [token] provider '
'configuration value instead')) 'configuration value instead'))
try: try:
mapped = _FORMAT_TO_PROVIDER[CONF.signing.token_format] mapped = _FORMAT_TO_PROVIDER[CONF.signing.token_format]
@ -349,8 +349,8 @@ class Manager(manager.Manager):
expiry = timeutils.normalize_time( expiry = timeutils.normalize_time(
timeutils.parse_isotime(expires_at)) timeutils.parse_isotime(expires_at))
except Exception: except Exception:
LOG.exception(_('Unexpected error or malformed token determining ' LOG.exception(_LE('Unexpected error or malformed token '
'token expiry: %s'), token) 'determining token expiry: %s'), token)
raise exception.TokenNotFound(_('Failed to validate token')) raise exception.TokenNotFound(_('Failed to validate token'))
if current_time < expiry: if current_time < expiry:

View File

@ -21,7 +21,7 @@ from keystone.common import dependency
from keystone import config from keystone import config
from keystone.contrib import federation from keystone.contrib import federation
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LE
from keystone.openstack.common import log from keystone.openstack.common import log
from keystone import token from keystone import token
from keystone.token import provider from keystone.token import provider
@ -341,10 +341,10 @@ class V3TokenDataHelper(object):
elif isinstance(audit_info, list): elif isinstance(audit_info, list):
token_data['audit_ids'] = audit_info token_data['audit_ids'] = audit_info
else: else:
msg = _('Invalid audit info data type: %(data)s (%(type)s)') msg = (_('Invalid audit info data type: %(data)s (%(type)s)') %
msg_subst = {'data': audit_info, 'type': type(audit_info)} {'data': audit_info, 'type': type(audit_info)})
LOG.error(msg, msg_subst) LOG.error(msg)
raise exception.UnexpectedError(msg % msg_subst) raise exception.UnexpectedError(msg)
def get_token_data(self, user_id, method_names, extras, def get_token_data(self, user_id, method_names, extras,
domain_id=None, project_id=None, expires=None, domain_id=None, project_id=None, expires=None,
@ -577,7 +577,7 @@ class BaseProvider(provider.Provider):
token_ref, roles_ref, catalog_ref, trust_ref) token_ref, roles_ref, catalog_ref, trust_ref)
return token_data return token_data
except exception.ValidationError as e: except exception.ValidationError as e:
LOG.exception(_('Failed to validate token')) LOG.exception(_LE('Failed to validate token'))
raise exception.TokenNotFound(e) raise exception.TokenNotFound(e)
def validate_v3_token(self, token_ref): def validate_v3_token(self, token_ref):

View File

@ -21,7 +21,7 @@ from keystone.common import environment
from keystone.common import utils from keystone.common import utils
from keystone import config from keystone import config
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _, _LE
from keystone.openstack.common import log from keystone.openstack.common import log
from keystone.token.providers import common from keystone.token.providers import common
@ -44,6 +44,6 @@ class Provider(common.BaseProvider):
CONF.signing.keyfile)) CONF.signing.keyfile))
return token_id return token_id
except environment.subprocess.CalledProcessError: except environment.subprocess.CalledProcessError:
LOG.exception(_('Unable to sign token')) LOG.exception(_LE('Unable to sign token'))
raise exception.UnexpectedError(_( raise exception.UnexpectedError(_(
'Unable to sign token.')) 'Unable to sign token.'))