Merge "Remove log translations"

This commit is contained in:
Jenkins 2017-05-25 14:41:16 +00:00 committed by Gerrit Code Review
commit 140af4ae7b
8 changed files with 57 additions and 74 deletions

View File

@ -26,7 +26,7 @@ from ec2api.api import ec2utils
from ec2api.api import validator
from ec2api.db import api as db_api
from ec2api import exception
from ec2api.i18n import _, _LI, _LW
from ec2api.i18n import _
ec2_opts = [
@ -92,7 +92,7 @@ class OnCrashCleaner(object):
formatted_args += ', '
formatted_args += kwargs_string
LOG.warning(
_LW('Error cleaning up %(name)s(%(args)s)') %
'Error cleaning up %(name)s(%(args)s)' %
{'name': name, 'args': formatted_args},
exc_info=True)
pass
@ -308,7 +308,7 @@ class UniversalDescriber(object):
item = ec2utils.auto_create_db_item(self.context, self.KIND,
self.get_id(os_item))
LOG.info(
_LI('Item %(item)s was updated to %(os_item)s.') %
'Item %(item)s was updated to %(os_item)s.',
{'item': str(item), 'os_item': str(os_item)})
return item
@ -319,7 +319,7 @@ class UniversalDescriber(object):
return os_item['name']
def delete_obsolete_item(self, item):
LOG.info(_LI('Deleting obsolete item %(item)s') % {'item': str(item)})
LOG.info('Deleting obsolete item %(item)s', {'item': str(item)})
db_api.delete_item(self.context, item['id'])
def is_filtering_value_found(self, filter_value, value):

View File

@ -26,7 +26,7 @@ import six
from ec2api import clients
from ec2api.db import api as db_api
from ec2api import exception
from ec2api.i18n import _, _LE
from ec2api.i18n import _
LOG = logging.getLogger(__name__)
@ -461,16 +461,15 @@ def get_os_public_network(context):
if len(os_networks) != 1:
if CONF.external_network:
if len(os_networks) == 0:
msg = _LE("No external network with name '%s' is found")
msg = "No external network with name '%s' is found"
else:
msg = _LE("More than one external network with name '%s' "
"is found")
msg = "More than one external network with name '%s' is found"
LOG.error(msg, CONF.external_network)
else:
if len(os_networks) == 0:
msg = _LE('No external network is found')
msg = 'No external network is found'
else:
msg = _LE('More than one external network is found')
msg = 'More than one external network is found'
LOG.error(msg)
raise exception.Unsupported(_('Feature is restricted by OS admin'))
return os_networks[0]

View File

@ -37,7 +37,7 @@ from ec2api.api import instance as instance_api
from ec2api import clients
from ec2api.db import api as db_api
from ec2api import exception
from ec2api.i18n import _, _LE, _LI, _LW
from ec2api.i18n import _
LOG = logging.getLogger(__name__)
@ -156,20 +156,19 @@ def create_image(context, instance_id, name=None, description=None,
image['os_id'] = os_image_id
db_api.update_item(context, image)
except Exception:
LOG.exception(_LE('Failed to complete image %s creation'),
image.id)
LOG.exception('Failed to complete image %s creation', image.id)
try:
image['state'] = 'failed'
db_api.update_item(context, image)
except Exception:
LOG.warning(_LW("Couldn't set 'failed' state for db image %s"),
LOG.warning("Couldn't set 'failed' state for db image %s",
image.id, exc_info=True)
try:
os_instance.start()
except Exception:
LOG.warning(_LW('Failed to start instance %(i_id)s after '
'completed creation of image %(image_id)s'),
LOG.warning('Failed to start instance %(i_id)s after '
'completed creation of image %(image_id)s',
{'i_id': instance['id'],
'image_id': image['id']},
exc_info=True)
@ -858,8 +857,8 @@ def _s3_create(context, metadata):
shutil.copyfileobj(part, combined)
except Exception:
LOG.exception(_LE('Failed to download %(image_location)s '
'to %(image_path)s'), log_vars)
LOG.exception('Failed to download %(image_location)s '
'to %(image_path)s', log_vars)
_update_image_state('failed_download')
return
@ -869,8 +868,8 @@ def _s3_create(context, metadata):
_s3_decrypt_image(context, enc_filename, encrypted_key,
encrypted_iv, dec_filename)
except Exception:
LOG.exception(_LE('Failed to decrypt %(image_location)s '
'to %(image_path)s'), log_vars)
LOG.exception('Failed to decrypt %(image_location)s '
'to %(image_path)s', log_vars)
_update_image_state('failed_decrypt')
return
@ -878,8 +877,8 @@ def _s3_create(context, metadata):
try:
unz_filename = _s3_untarzip_image(image_path, dec_filename)
except Exception:
LOG.exception(_LE('Failed to untar %(image_location)s '
'to %(image_path)s'), log_vars)
LOG.exception('Failed to untar %(image_location)s '
'to %(image_path)s', log_vars)
_update_image_state('failed_untar')
return
@ -888,8 +887,8 @@ def _s3_create(context, metadata):
with open(unz_filename) as image_file:
glance.images.upload(image.id, image_file)
except Exception:
LOG.exception(_LE('Failed to upload %(image_location)s '
'to %(image_path)s'), log_vars)
LOG.exception('Failed to upload %(image_location)s '
'to %(image_path)s', log_vars)
_update_image_state('failed_upload')
return
@ -897,10 +896,9 @@ def _s3_create(context, metadata):
shutil.rmtree(image_path)
except glance_exception.HTTPNotFound:
LOG.info(_LI('Image %swas deleted underneath us'), image.id)
LOG.info('Image %swas deleted underneath us', image.id)
except Exception:
LOG.exception(_LE('Failed to complete image %s creation'),
image.id)
LOG.exception('Failed to complete image %s creation', image.id)
eventlet.spawn_n(delayed_create)

View File

@ -33,7 +33,7 @@ from ec2api import clients
from ec2api import context as ec2_context
from ec2api.db import api as db_api
from ec2api import exception
from ec2api.i18n import _, _LE
from ec2api.i18n import _
LOG = logging.getLogger(__name__)
@ -94,12 +94,11 @@ def run_instances(context, image_id, min_count, max_count,
'value': [client_token]}])
if reservations['reservationSet']:
if len(reservations['reservationSet']) > 1:
LOG.error(_LE('describe_instances has returned %s '
'reservations, but 1 is expected.') %
LOG.error('describe_instances has returned %s '
'reservations, but 1 is expected.',
len(reservations['reservationSet']))
LOG.error(_LE('Requested instances client token: %s') %
client_token)
LOG.error(_LE('Result: %s') % reservations)
LOG.error('Requested instances client token: %s', client_token)
LOG.error('Result: %s', reservations)
return reservations['reservationSet'][0]
os_image, os_kernel_id, os_ramdisk_id = _parse_image_parameters(
@ -173,10 +172,10 @@ def run_instances(context, image_id, min_count, max_count,
ec2_reservations = describe_instances(context, instance_ids)
reservation_count = len(ec2_reservations['reservationSet'])
if reservation_count != 1:
LOG.error(_LE('describe_instances has returned %s reservations, '
'but 1 is expected.') % reservation_count)
LOG.error(_LE('Requested instances IDs: %s') % instance_ids)
LOG.error(_LE('Result: %s') % ec2_reservations)
LOG.error('describe_instances has returned %s reservations, '
'but 1 is expected.', reservation_count)
LOG.error('Requested instances IDs: %s', instance_ids)
LOG.error('Result: %s', ec2_reservations)
return (ec2_reservations['reservationSet'][0]
if reservation_count else None)

View File

@ -25,7 +25,7 @@ from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from ec2api.i18n import _, _LI, _LW
from ec2api.i18n import _
logger = logging.getLogger(__name__)
@ -151,32 +151,31 @@ def _get_nova_api_version(context):
current = client.versions.get_current()
if not current:
logger.warning(
_LW('Could not check Nova API version because no version '
'was found in Nova version list for url %(url)s of service '
'type "%(service_type)s". '
'Use v%(required_api_version)s Nova API.'),
'Could not check Nova API version because no version '
'was found in Nova version list for url %(url)s of service '
'type "%(service_type)s". '
'Use v%(required_api_version)s Nova API.',
{'url': client.client.get_endpoint(),
'service_type': CONF.nova_service_type,
'required_api_version': REQUIRED_NOVA_API_MICROVERSION})
return REQUIRED_NOVA_API_MICROVERSION
if current.id != REQUIRED_NOVA_API_VERSION_ID:
logger.warning(
_LW('Specified "%s" Nova service type does not support v2.1 API. '
'A lot of useful EC2 compliant instance properties '
'will be unavailable.'),
CONF.nova_service_type)
'Specified "%s" Nova service type does not support v2.1 API. '
'A lot of useful EC2 compliant instance properties '
'will be unavailable.', CONF.nova_service_type)
return LEGACY_NOVA_API_VERSION
if (nova_api_versions.APIVersion(current.version) < required):
logger.warning(
_LW('Nova support v%(nova_api_version)s, '
'but v%(required_api_version)s is required. '
'A lot of useful EC2 compliant instance properties '
'will be unavailable.'),
'Nova support v%(nova_api_version)s, '
'but v%(required_api_version)s is required. '
'A lot of useful EC2 compliant instance properties '
'will be unavailable.',
{'nova_api_version': current.version,
'required_api_version': REQUIRED_NOVA_API_MICROVERSION})
return current.version
logger.info(_LI('Provided Nova API version is v%(nova_api_version)s, '
'used one is v%(required_api_version)s'),
logger.info('Provided Nova API version is v%(nova_api_version)s, '
'used one is v%(required_api_version)s',
{'nova_api_version': current.version,
'required_api_version': (
REQUIRED_NOVA_API_MICROVERSION)})

View File

@ -22,7 +22,6 @@ import six
from ec2api import clients
from ec2api import exception
from ec2api.i18n import _LW
CONF = cfg.CONF
@ -65,7 +64,7 @@ class RequestContext(context.RequestContext):
kwargs.pop('user_identity', None)
self.session = kwargs.pop('session', None)
if kwargs:
LOG.warning(_LW('Arguments dropped when creating context: %s') %
LOG.warning('Arguments dropped when creating context: %s',
str(kwargs))
self.user_id = user_id

View File

@ -27,16 +27,6 @@ _translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
def translate(value, user_locale):
return oslo_i18n.translate(value, user_locale)

View File

@ -25,7 +25,7 @@ import webob
from ec2api import context as ec2_context
from ec2api import exception
from ec2api.i18n import _, _LE, _LW
from ec2api.i18n import _
from ec2api.metadata import api
from ec2api import utils
from ec2api import wsgi
@ -97,7 +97,7 @@ class MetadataRequestHandler(wsgi.Application):
except exception.EC2MetadataNotFound:
return webob.exc.HTTPNotFound()
except Exception:
LOG.exception(_LE("Unexpected error."))
LOG.exception("Unexpected error.")
msg = _('An unknown error has occurred. '
'Please try your request again.')
return webob.exc.HTTPInternalServerError(
@ -133,10 +133,10 @@ class MetadataRequestHandler(wsgi.Application):
req.response.body = content
return req.response
elif resp.status == 403:
LOG.warning(_LW(
LOG.warning(
'The remote metadata server responded with Forbidden. This '
'response usually occurs when shared secrets do not match.'
))
)
return webob.exc.HTTPForbidden()
elif resp.status == 400:
return webob.exc.HTTPBadRequest()
@ -234,12 +234,11 @@ class MetadataRequestHandler(wsgi.Application):
if not (signature and
utils.constant_time_compare(expected_signature, signature)):
LOG.warning(_LW(
'X-Instance-ID-Signature: %(signature)s does '
'not match the expected value: '
'%(expected_signature)s for id: '
'%(requester_id)s. Request From: '
'%(requester_ip)s'),
LOG.warning('X-Instance-ID-Signature: %(signature)s does '
'not match the expected value: '
'%(expected_signature)s for id: '
'%(requester_id)s. Request From: '
'%(requester_ip)s',
{'signature': signature,
'expected_signature': expected_signature,
'requester_id': requester_id,