Skip to content

Commit

Permalink
Merge "trivial: Remove remaining '_LE' instances"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed May 20, 2020
2 parents d54c549 + eee57f2 commit e84190c
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 52 deletions.
4 changes: 2 additions & 2 deletions nova/api/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import nova.conf
from nova import exception
from nova.i18n import _, _LE
from nova.i18n import _


CONF = nova.conf.CONF
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions nova/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions nova/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -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})

Expand Down
2 changes: 0 additions & 2 deletions nova/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions nova/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


from nova import exception
from nova.i18n import _LE, _LW
from nova.i18n import _LW
from nova import policies


Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions nova/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions nova/servicegroup/drivers/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions nova/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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 ('', '')


Expand Down Expand Up @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions nova/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})


Expand Down
38 changes: 18 additions & 20 deletions nova/volume/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions nova/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e84190c

Please sign in to comment.