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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2020-05-18 16:51:14 +01:00
parent b8fe7fac84
commit eee57f2380
11 changed files with 48 additions and 52 deletions

View File

@ -20,7 +20,7 @@ import webob
import nova.conf
from nova import exception
from nova.i18n import _, _LE
from nova.i18n import _
CONF = nova.conf.CONF
@ -256,5 +256,5 @@ class Loader(object):
{'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)

View File

@ -28,7 +28,7 @@ import six
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 @@ class ConvertedException(webob.exc.WSGIHTTPException):
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 @@ class NovaException(Exception):
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

View File

@ -50,7 +50,7 @@ import functools
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 @@ class HookManager(stevedore.hook.HookManager):
"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 @@ class HookManager(stevedore.hook.HookManager):
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})

View File

@ -34,8 +34,6 @@ _ = _translators.primary
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
def translate(value, user_locale):

View File

@ -24,7 +24,7 @@ from oslo_utils import excutils
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',

View File

@ -34,7 +34,7 @@ import nova.conf
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 @@ class Service(service.Service):
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 @@ class Service(service.Service):
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):

View File

@ -20,7 +20,7 @@ import six
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 @@ class DbDriver(base.Driver):
# 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

View File

@ -53,7 +53,7 @@ from six.moves import range
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):

View File

@ -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})

View File

@ -42,7 +42,6 @@ from nova import availability_zones as az
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 @@ class API(object):
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,

View File

@ -30,7 +30,7 @@ from oslo_utils import excutils
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 @@ class Server(service.ServiceBase):
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 @@ class Server(service.ServiceBase):
**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,