From eee57f2380518131338dbff3d63803e15b68e7fa Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 18 May 2020 16:51:14 +0100 Subject: [PATCH] trivial: Remove remaining '_LE' instances We've been slowly removing these as we go. Remove the final few '_LE' occurrences now. Change-Id: I75ebd2e95a0c77585d7b4329ca01e4bacc1dd7c4 Signed-off-by: Stephen Finucane --- nova/api/wsgi.py | 4 ++-- nova/exception.py | 6 +++--- nova/hooks.py | 12 ++++++----- nova/i18n.py | 2 -- nova/policy.py | 4 ++-- nova/service.py | 6 +++--- nova/servicegroup/drivers/db.py | 5 ++--- nova/utils.py | 6 +++--- nova/version.py | 4 +--- nova/volume/cinder.py | 38 ++++++++++++++++----------------- nova/wsgi.py | 13 +++++------ 11 files changed, 48 insertions(+), 52 deletions(-) diff --git a/nova/api/wsgi.py b/nova/api/wsgi.py index 4a74bb6a986..ea67c612309 100644 --- a/nova/api/wsgi.py +++ b/nova/api/wsgi.py @@ -20,7 +20,7 @@ import nova.conf from nova import exception -from nova.i18n import _, _LE +from nova.i18n import _ CONF = nova.conf.CONF @@ -256,5 +256,5 @@ def load_app(self, name): {'name': name, 'path': self.config_path}) return deploy.loadapp("config:%s" % self.config_path, name=name) except LookupError: - LOG.exception(_LE("Couldn't lookup app: %s"), name) + LOG.exception("Couldn't lookup app: %s", name) raise exception.PasteAppNotFound(name=name, path=self.config_path) diff --git a/nova/exception.py b/nova/exception.py index aa1dacd3cbe..7cb2cd564f9 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -28,7 +28,7 @@ import webob.exc from webob import util as woutil -from nova.i18n import _, _LE +from nova.i18n import _ LOG = logging.getLogger(__name__) @@ -49,7 +49,7 @@ def __init__(self, code, title="", explanation=""): try: self.title = woutil.status_reasons[self.code] except KeyError: - msg = _LE("Improper or unknown HTTP status code used: %d") + msg = "Improper or unknown HTTP status code used: %d" LOG.error(msg, code) self.title = woutil.status_generic_reasons[self.code // 100] self.explanation = explanation @@ -95,7 +95,7 @@ def __init__(self, message=None, **kwargs): def _log_exception(self): # kwargs doesn't match a variable in the message # log the issue and the kwargs - LOG.exception(_LE('Exception in string format operation')) + LOG.exception('Exception in string format operation') for name, value in self.kwargs.items(): LOG.error("%s: %s" % (name, value)) # noqa diff --git a/nova/hooks.py b/nova/hooks.py index bb85f38ee99..4323a3fea0e 100644 --- a/nova/hooks.py +++ b/nova/hooks.py @@ -50,7 +50,7 @@ from oslo_log import log as logging import stevedore -from nova.i18n import _, _LE, _LW +from nova.i18n import _, _LW LOG = logging.getLogger(__name__) NS = 'nova.hooks' @@ -81,6 +81,7 @@ def _run(self, name, method_type, args, kwargs, func=None): "Only 'pre' and 'post' type allowed") raise ValueError(msg) + # TODO(stephenfin): Kill this for e in self.extensions: obj = e.obj hook_method = getattr(obj, method_type, None) @@ -95,14 +96,15 @@ def _run(self, name, method_type, args, kwargs, func=None): else: hook_method(*args, **kwargs) except FatalHookException: - msg = _LE("Fatal Exception running %(name)s " - "%(type)s-hook: %(obj)s") + msg = ( + "Fatal Exception running %(name)s %(type)s-hook: " + "%(obj)s" + ) LOG.exception(msg, {'name': name, 'type': method_type, 'obj': obj}) raise except Exception: - msg = _LE("Exception running %(name)s " - "%(type)s-hook: %(obj)s") + msg = "Exception running %(name)s %(type)s-hook: %(obj)s" LOG.exception(msg, {'name': name, 'type': method_type, 'obj': obj}) diff --git a/nova/i18n.py b/nova/i18n.py index a738adaa75f..9607616d26c 100644 --- a/nova/i18n.py +++ b/nova/i18n.py @@ -34,8 +34,6 @@ # the level. _LI = _translators.log_info _LW = _translators.log_warning -_LE = _translators.log_error -_LC = _translators.log_critical def translate(value, user_locale): diff --git a/nova/policy.py b/nova/policy.py index 613df504635..05d35e6204f 100644 --- a/nova/policy.py +++ b/nova/policy.py @@ -24,7 +24,7 @@ from nova import exception -from nova.i18n import _LE, _LW +from nova.i18n import _LW from nova import policies @@ -178,7 +178,7 @@ def authorize(context, action, target=None, do_raise=True, exc=None): do_raise=do_raise, exc=exc, action=action) except policy.PolicyNotRegistered: with excutils.save_and_reraise_exception(): - LOG.exception(_LE('Policy not registered')) + LOG.exception('Policy not registered') except policy.InvalidScope: LOG.debug('Policy check for %(action)s failed with scope check ' '%(credentials)s', diff --git a/nova/service.py b/nova/service.py index 16703a94500..9bb4d694370 100644 --- a/nova/service.py +++ b/nova/service.py @@ -34,7 +34,7 @@ from nova import context from nova import debugger from nova import exception -from nova.i18n import _, _LE, _LI, _LW +from nova.i18n import _, _LI, _LW from nova import objects from nova.objects import base as objects_base from nova.objects import service as service_obj @@ -295,7 +295,7 @@ def stop(self): try: self.manager.cleanup_host() except Exception: - LOG.exception(_LE('Service error occurred during cleanup_host')) + LOG.exception('Service error occurred during cleanup_host') pass super(Service, self).stop() @@ -312,7 +312,7 @@ def basic_config_check(self): with utils.tempdir(): pass except Exception as e: - LOG.error(_LE('Temporary directory is invalid: %s'), e) + LOG.error('Temporary directory is invalid: %s', e) sys.exit(1) def reset(self): diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py index 9b134ffebb1..de462d5c927 100644 --- a/nova/servicegroup/drivers/db.py +++ b/nova/servicegroup/drivers/db.py @@ -20,7 +20,7 @@ import nova.conf from nova import exception -from nova.i18n import _, _LI, _LW, _LE +from nova.i18n import _, _LI, _LW from nova.servicegroup import api from nova.servicegroup.drivers import base @@ -119,7 +119,6 @@ def _report_state(self, service): # exceptions here, but otherwise it would become possible for # the state reporting thread to stop abruptly, and thus leave # the service unusable until it's restarted. - LOG.exception( - _LE('Unexpected error while reporting service status')) + LOG.exception('Unexpected error while reporting service status') # trigger the recovery log message, if this error goes away service.model_disconnected = True diff --git a/nova/utils.py b/nova/utils.py index 87217abfa16..20692d43d64 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -53,7 +53,7 @@ from nova import block_device import nova.conf from nova import exception -from nova.i18n import _, _LE, _LW +from nova.i18n import _, _LW from nova import safe_utils profiler = importutils.try_import('osprofiler.profiler') @@ -299,7 +299,7 @@ def parse_server_string(server_str): return (address, port) except (ValueError, netaddr.AddrFormatError): - LOG.error(_LE('Invalid server_string: %s'), server_str) + LOG.error('Invalid server_string: %s', server_str) return ('', '') @@ -495,7 +495,7 @@ def tempdir(**kwargs): try: shutil.rmtree(tmpdir) except OSError as e: - LOG.error(_LE('Could not remove tmpdir: %s'), e) + LOG.error('Could not remove tmpdir: %s', e) class UndoManager(object): diff --git a/nova/version.py b/nova/version.py index f6780435bd2..a5b34f90cea 100644 --- a/nova/version.py +++ b/nova/version.py @@ -14,8 +14,6 @@ import pbr.version -from nova.i18n import _LE - NOVA_VENDOR = "OpenStack Foundation" NOVA_PRODUCT = "OpenStack Nova" NOVA_PACKAGE = None # OS distro package version suffix @@ -59,7 +57,7 @@ def _load_config(): NOVA_PACKAGE = cfg.get("Nova", "package") except Exception as ex: LOG = logging.getLogger(__name__) - LOG.error(_LE("Failed to load %(cfgfile)s: %(ex)s"), + LOG.error("Failed to load %(cfgfile)s: %(ex)s", {'cfgfile': cfgfile, 'ex': ex}) diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 2c6c936f0d6..3c384e35eee 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -42,7 +42,6 @@ import nova.conf from nova import exception from nova.i18n import _ -from nova.i18n import _LE from nova.i18n import _LW from nova import service_auth @@ -610,28 +609,27 @@ def initialize_connection(self, context, volume_id, connector): return connection_info except cinder_exception.ClientException as ex: with excutils.save_and_reraise_exception(): - LOG.error(_LE('Initialize connection failed for volume ' - '%(vol)s on host %(host)s. Error: %(msg)s ' - 'Code: %(code)s. Attempting to terminate ' - 'connection.'), - {'vol': volume_id, - 'host': connector.get('host'), - 'msg': six.text_type(ex), - 'code': ex.code}) + LOG.error( + 'Initialize connection failed for volume %(vol)s on host ' + '%(host)s. Error: %(msg)s Code: %(code)s. ' + 'Attempting to terminate connection.', + {'vol': volume_id, + 'host': connector.get('host'), + 'msg': six.text_type(ex), + 'code': ex.code}) try: self.terminate_connection(context, volume_id, connector) except Exception as exc: - LOG.error(_LE('Connection between volume %(vol)s and host ' - '%(host)s might have succeeded, but attempt ' - 'to terminate connection has failed. ' - 'Validate the connection and determine if ' - 'manual cleanup is needed. Error: %(msg)s ' - 'Code: %(code)s.'), - {'vol': volume_id, - 'host': connector.get('host'), - 'msg': six.text_type(exc), - 'code': ( - exc.code if hasattr(exc, 'code') else None)}) + LOG.error( + 'Connection between volume %(vol)s and host %(host)s ' + 'might have succeeded, but attempt to terminate ' + 'connection has failed. Validate the connection and ' + 'determine if manual cleanup is needed. ' + 'Error: %(msg)s Code: %(code)s.', + {'vol': volume_id, + 'host': connector.get('host'), + 'msg': six.text_type(exc), + 'code': exc.code if hasattr(exc, 'code') else None}) @translate_volume_exception @retrying.retry(stop_max_attempt_number=5, diff --git a/nova/wsgi.py b/nova/wsgi.py index e9fb7500320..05437b09f01 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -30,7 +30,7 @@ import nova.conf from nova import exception -from nova.i18n import _, _LE, _LI +from nova.i18n import _, _LI from nova import utils CONF = nova.conf.CONF @@ -92,7 +92,7 @@ def __init__(self, name, app, host='0.0.0.0', port=0, pool_size=None, try: self._socket = eventlet.listen(bind_addr, family, backlog=backlog) except EnvironmentError: - LOG.error(_LE("Could not bind to %(host)s:%(port)s"), + LOG.error("Could not bind to %(host)s:%(port)s", {'host': host, 'port': port}) raise @@ -161,10 +161,11 @@ def start(self): **ssl_kwargs) except Exception: with excutils.save_and_reraise_exception(): - LOG.error(_LE("Failed to start %(name)s on %(host)s" - ":%(port)s with SSL support"), - {'name': self.name, 'host': self.host, - 'port': self.port}) + LOG.error( + "Failed to start %(name)s on %(host)s:%(port)s with " + "SSL support", + {'name': self.name, 'host': self.host, + 'port': self.port}) wsgi_kwargs = { 'func': eventlet.wsgi.server,