Merge "trivial: Remove remaining '_LE' instances"

This commit is contained in:
Zuul 2020-05-20 11:08:10 +00:00 committed by Gerrit Code Review
commit e84190c6c1
11 changed files with 48 additions and 52 deletions

View File

@ -20,7 +20,7 @@ import webob
import nova.conf import nova.conf
from nova import exception from nova import exception
from nova.i18n import _, _LE from nova.i18n import _
CONF = nova.conf.CONF CONF = nova.conf.CONF
@ -256,5 +256,5 @@ class Loader(object):
{'name': name, 'path': self.config_path}) {'name': name, 'path': self.config_path})
return deploy.loadapp("config:%s" % self.config_path, name=name) return deploy.loadapp("config:%s" % self.config_path, name=name)
except LookupError: 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) raise exception.PasteAppNotFound(name=name, path=self.config_path)

View File

@ -28,7 +28,7 @@ import six
import webob.exc import webob.exc
from webob import util as woutil from webob import util as woutil
from nova.i18n import _, _LE from nova.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -49,7 +49,7 @@ class ConvertedException(webob.exc.WSGIHTTPException):
try: try:
self.title = woutil.status_reasons[self.code] self.title = woutil.status_reasons[self.code]
except KeyError: 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) LOG.error(msg, code)
self.title = woutil.status_generic_reasons[self.code // 100] self.title = woutil.status_generic_reasons[self.code // 100]
self.explanation = explanation self.explanation = explanation
@ -95,7 +95,7 @@ class NovaException(Exception):
def _log_exception(self): def _log_exception(self):
# kwargs doesn't match a variable in the message # kwargs doesn't match a variable in the message
# log the issue and the kwargs # 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(): for name, value in self.kwargs.items():
LOG.error("%s: %s" % (name, value)) # noqa LOG.error("%s: %s" % (name, value)) # noqa

View File

@ -50,7 +50,7 @@ import functools
from oslo_log import log as logging from oslo_log import log as logging
import stevedore import stevedore
from nova.i18n import _, _LE, _LW from nova.i18n import _, _LW
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
NS = 'nova.hooks' NS = 'nova.hooks'
@ -81,6 +81,7 @@ class HookManager(stevedore.hook.HookManager):
"Only 'pre' and 'post' type allowed") "Only 'pre' and 'post' type allowed")
raise ValueError(msg) raise ValueError(msg)
# TODO(stephenfin): Kill this
for e in self.extensions: for e in self.extensions:
obj = e.obj obj = e.obj
hook_method = getattr(obj, method_type, None) hook_method = getattr(obj, method_type, None)
@ -95,14 +96,15 @@ class HookManager(stevedore.hook.HookManager):
else: else:
hook_method(*args, **kwargs) hook_method(*args, **kwargs)
except FatalHookException: except FatalHookException:
msg = _LE("Fatal Exception running %(name)s " msg = (
"%(type)s-hook: %(obj)s") "Fatal Exception running %(name)s %(type)s-hook: "
"%(obj)s"
)
LOG.exception(msg, {'name': name, 'type': method_type, LOG.exception(msg, {'name': name, 'type': method_type,
'obj': obj}) 'obj': obj})
raise raise
except Exception: except Exception:
msg = _LE("Exception running %(name)s " msg = "Exception running %(name)s %(type)s-hook: %(obj)s"
"%(type)s-hook: %(obj)s")
LOG.exception(msg, {'name': name, 'type': method_type, LOG.exception(msg, {'name': name, 'type': method_type,
'obj': obj}) 'obj': obj})

View File

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

View File

@ -24,7 +24,7 @@ from oslo_utils import excutils
from nova import exception from nova import exception
from nova.i18n import _LE, _LW from nova.i18n import _LW
from nova import policies 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) do_raise=do_raise, exc=exc, action=action)
except policy.PolicyNotRegistered: except policy.PolicyNotRegistered:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_LE('Policy not registered')) LOG.exception('Policy not registered')
except policy.InvalidScope: except policy.InvalidScope:
LOG.debug('Policy check for %(action)s failed with scope check ' LOG.debug('Policy check for %(action)s failed with scope check '
'%(credentials)s', '%(credentials)s',

View File

@ -34,7 +34,7 @@ import nova.conf
from nova import context from nova import context
from nova import debugger from nova import debugger
from nova import exception from nova import exception
from nova.i18n import _, _LE, _LI, _LW from nova.i18n import _, _LI, _LW
from nova import objects from nova import objects
from nova.objects import base as objects_base from nova.objects import base as objects_base
from nova.objects import service as service_obj from nova.objects import service as service_obj
@ -295,7 +295,7 @@ class Service(service.Service):
try: try:
self.manager.cleanup_host() self.manager.cleanup_host()
except Exception: except Exception:
LOG.exception(_LE('Service error occurred during cleanup_host')) LOG.exception('Service error occurred during cleanup_host')
pass pass
super(Service, self).stop() super(Service, self).stop()
@ -312,7 +312,7 @@ class Service(service.Service):
with utils.tempdir(): with utils.tempdir():
pass pass
except Exception as e: except Exception as e:
LOG.error(_LE('Temporary directory is invalid: %s'), e) LOG.error('Temporary directory is invalid: %s', e)
sys.exit(1) sys.exit(1)
def reset(self): def reset(self):

View File

@ -20,7 +20,7 @@ import six
import nova.conf import nova.conf
from nova import exception 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 import api
from nova.servicegroup.drivers import base from nova.servicegroup.drivers import base
@ -119,7 +119,6 @@ class DbDriver(base.Driver):
# exceptions here, but otherwise it would become possible for # exceptions here, but otherwise it would become possible for
# the state reporting thread to stop abruptly, and thus leave # the state reporting thread to stop abruptly, and thus leave
# the service unusable until it's restarted. # the service unusable until it's restarted.
LOG.exception( LOG.exception('Unexpected error while reporting service status')
_LE('Unexpected error while reporting service status'))
# trigger the recovery log message, if this error goes away # trigger the recovery log message, if this error goes away
service.model_disconnected = True service.model_disconnected = True

View File

@ -53,7 +53,7 @@ from six.moves import range
from nova import block_device from nova import block_device
import nova.conf import nova.conf
from nova import exception from nova import exception
from nova.i18n import _, _LE, _LW from nova.i18n import _, _LW
from nova import safe_utils from nova import safe_utils
profiler = importutils.try_import('osprofiler.profiler') profiler = importutils.try_import('osprofiler.profiler')
@ -299,7 +299,7 @@ def parse_server_string(server_str):
return (address, port) return (address, port)
except (ValueError, netaddr.AddrFormatError): except (ValueError, netaddr.AddrFormatError):
LOG.error(_LE('Invalid server_string: %s'), server_str) LOG.error('Invalid server_string: %s', server_str)
return ('', '') return ('', '')
@ -495,7 +495,7 @@ def tempdir(**kwargs):
try: try:
shutil.rmtree(tmpdir) shutil.rmtree(tmpdir)
except OSError as e: except OSError as e:
LOG.error(_LE('Could not remove tmpdir: %s'), e) LOG.error('Could not remove tmpdir: %s', e)
class UndoManager(object): class UndoManager(object):

View File

@ -14,8 +14,6 @@
import pbr.version import pbr.version
from nova.i18n import _LE
NOVA_VENDOR = "OpenStack Foundation" NOVA_VENDOR = "OpenStack Foundation"
NOVA_PRODUCT = "OpenStack Nova" NOVA_PRODUCT = "OpenStack Nova"
NOVA_PACKAGE = None # OS distro package version suffix NOVA_PACKAGE = None # OS distro package version suffix
@ -59,7 +57,7 @@ def _load_config():
NOVA_PACKAGE = cfg.get("Nova", "package") NOVA_PACKAGE = cfg.get("Nova", "package")
except Exception as ex: except Exception as ex:
LOG = logging.getLogger(__name__) 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}) {'cfgfile': cfgfile, 'ex': ex})

View File

@ -42,7 +42,6 @@ from nova import availability_zones as az
import nova.conf import nova.conf
from nova import exception from nova import exception
from nova.i18n import _ from nova.i18n import _
from nova.i18n import _LE
from nova.i18n import _LW from nova.i18n import _LW
from nova import service_auth from nova import service_auth
@ -610,28 +609,27 @@ class API(object):
return connection_info return connection_info
except cinder_exception.ClientException as ex: except cinder_exception.ClientException as ex:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE('Initialize connection failed for volume ' LOG.error(
'%(vol)s on host %(host)s. Error: %(msg)s ' 'Initialize connection failed for volume %(vol)s on host '
'Code: %(code)s. Attempting to terminate ' '%(host)s. Error: %(msg)s Code: %(code)s. '
'connection.'), 'Attempting to terminate connection.',
{'vol': volume_id, {'vol': volume_id,
'host': connector.get('host'), 'host': connector.get('host'),
'msg': six.text_type(ex), 'msg': six.text_type(ex),
'code': ex.code}) 'code': ex.code})
try: try:
self.terminate_connection(context, volume_id, connector) self.terminate_connection(context, volume_id, connector)
except Exception as exc: except Exception as exc:
LOG.error(_LE('Connection between volume %(vol)s and host ' LOG.error(
'%(host)s might have succeeded, but attempt ' 'Connection between volume %(vol)s and host %(host)s '
'to terminate connection has failed. ' 'might have succeeded, but attempt to terminate '
'Validate the connection and determine if ' 'connection has failed. Validate the connection and '
'manual cleanup is needed. Error: %(msg)s ' 'determine if manual cleanup is needed. '
'Code: %(code)s.'), 'Error: %(msg)s Code: %(code)s.',
{'vol': volume_id, {'vol': volume_id,
'host': connector.get('host'), 'host': connector.get('host'),
'msg': six.text_type(exc), 'msg': six.text_type(exc),
'code': ( 'code': exc.code if hasattr(exc, 'code') else None})
exc.code if hasattr(exc, 'code') else None)})
@translate_volume_exception @translate_volume_exception
@retrying.retry(stop_max_attempt_number=5, @retrying.retry(stop_max_attempt_number=5,

View File

@ -30,7 +30,7 @@ from oslo_utils import excutils
import nova.conf import nova.conf
from nova import exception from nova import exception
from nova.i18n import _, _LE, _LI from nova.i18n import _, _LI
from nova import utils from nova import utils
CONF = nova.conf.CONF CONF = nova.conf.CONF
@ -92,7 +92,7 @@ class Server(service.ServiceBase):
try: try:
self._socket = eventlet.listen(bind_addr, family, backlog=backlog) self._socket = eventlet.listen(bind_addr, family, backlog=backlog)
except EnvironmentError: 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}) {'host': host, 'port': port})
raise raise
@ -161,10 +161,11 @@ class Server(service.ServiceBase):
**ssl_kwargs) **ssl_kwargs)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE("Failed to start %(name)s on %(host)s" LOG.error(
":%(port)s with SSL support"), "Failed to start %(name)s on %(host)s:%(port)s with "
{'name': self.name, 'host': self.host, "SSL support",
'port': self.port}) {'name': self.name, 'host': self.host,
'port': self.port})
wsgi_kwargs = { wsgi_kwargs = {
'func': eventlet.wsgi.server, 'func': eventlet.wsgi.server,