diff --git a/ironic/common/disk_partitioner.py b/ironic/common/disk_partitioner.py index 7703d17a6a..d2e1d8e6e4 100644 --- a/ironic/common/disk_partitioner.py +++ b/ironic/common/disk_partitioner.py @@ -19,6 +19,7 @@ from oslo.config import cfg from ironic.common import exception from ironic.common.i18n import _ +from ironic.common.i18n import _LW from ironic.common import utils from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall @@ -129,8 +130,8 @@ class DiskPartitioner(object): pids_match = re.search(self._fuser_pids_re, out) pids[0] = pids_match.group() except processutils.ProcessExecutionError as exc: - LOG.warning(_('Failed to check the device %(device)s with fuser: ' - ' %(err)s') % {'device': self._device, 'err': exc}) + LOG.warning(_LW('Failed to check the device %(device)s with fuser:' + ' %(err)s'), {'device': self._device, 'err': exc}) def commit(self): """Write to the disk.""" @@ -194,9 +195,9 @@ def list_partitions(device): for line in lines: match = _PARTED_PRINT_RE.match(line) if match is None: - LOG.warn(_("Partition information from parted for device " - "%(device)s does not match " - "expected format: %(line)s"), + LOG.warn(_LW("Partition information from parted for device " + "%(device)s does not match " + "expected format: %(line)s"), dict(device=device, line=line)) continue # Cast int fields to ints (some are floats and we round them down) diff --git a/ironic/common/driver_factory.py b/ironic/common/driver_factory.py index d93a5cedc1..ac1ae9319d 100644 --- a/ironic/common/driver_factory.py +++ b/ironic/common/driver_factory.py @@ -16,7 +16,7 @@ from oslo.config import cfg from ironic.common import exception -from ironic.common.i18n import _ +from ironic.common.i18n import _LI from ironic.openstack.common import lockutils from ironic.openstack.common import log from stevedore import dispatch @@ -118,7 +118,7 @@ class DriverFactory(object): _check_func, invoke_on_load=True, on_load_failure_callback=_catch_driver_not_found) - LOG.info(_("Loaded the following drivers: %s"), + LOG.info(_LI("Loaded the following drivers: %s"), cls._extension_manager.names()) @property diff --git a/ironic/common/exception.py b/ironic/common/exception.py index cf7fd4e6b7..337ea76ca1 100644 --- a/ironic/common/exception.py +++ b/ironic/common/exception.py @@ -26,6 +26,7 @@ from oslo.config import cfg import six from ironic.common.i18n import _ +from ironic.common.i18n import _LE from ironic.openstack.common import log as logging @@ -75,7 +76,7 @@ class IronicException(Exception): except Exception as e: # kwargs doesn't match a variable in the message # log the issue and the kwargs - LOG.exception(_('Exception in string format operation')) + LOG.exception(_LE('Exception in string format operation')) for name, value in kwargs.iteritems(): LOG.error("%s: %s" % (name, value)) diff --git a/ironic/common/glance_service/base_image_service.py b/ironic/common/glance_service/base_image_service.py index 447cba34e7..4c30035b7f 100644 --- a/ironic/common/glance_service/base_image_service.py +++ b/ironic/common/glance_service/base_image_service.py @@ -28,7 +28,7 @@ import six.moves.urllib.parse as urlparse from ironic.common import exception from ironic.common.glance_service import service_utils -from ironic.common.i18n import _ +from ironic.common.i18n import _LE from oslo.config import cfg @@ -125,9 +125,9 @@ class BaseImageService(object): host = self.glance_host port = self.glance_port extra = "retrying" - error_msg = _("Error contacting glance server " - "'%(host)s:%(port)s' for '%(method)s', " - "%(extra)s.") + error_msg = _LE("Error contacting glance server " + "'%(host)s:%(port)s' for '%(method)s', " + "%(extra)s.") if attempt == num_attempts: extra = 'done trying' LOG.exception(error_msg, {'host': host, diff --git a/ironic/common/images.py b/ironic/common/images.py index cf71f4b889..15597a1618 100644 --- a/ironic/common/images.py +++ b/ironic/common/images.py @@ -26,8 +26,8 @@ import jinja2 from oslo.config import cfg from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE from ironic.common import image_service as service from ironic.common import paths from ironic.common import utils @@ -38,8 +38,6 @@ from ironic.openstack.common import processutils LOG = logging.getLogger(__name__) -_LE = i18n._LE - image_opts = [ cfg.BoolOpt('force_raw_images', default=True, diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index a2b8ea7f61..4adf57e79b 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -21,16 +21,13 @@ from oslo.config import cfg from ironic.common import dhcp_factory from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LW from ironic.common import utils from ironic.drivers import utils as driver_utils from ironic.openstack.common import fileutils from ironic.openstack.common import log as logging -_LW = i18n._LW -_LE = i18n._LE - CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/ironic/common/service.py b/ironic/common/service.py index 078092c684..1d7722ee9e 100644 --- a/ironic/common/service.py +++ b/ironic/common/service.py @@ -23,11 +23,11 @@ from oslo import messaging from oslo.utils import importutils from ironic.common import config -from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LI from ironic.common import rpc from ironic.objects import base as objects_base from ironic.openstack.common import context -from ironic.openstack.common.gettextutils import _LI from ironic.openstack.common import log from ironic.openstack.common import service @@ -85,13 +85,13 @@ class RPCService(service.Service): self.rpcserver.stop() self.rpcserver.wait() except Exception as e: - LOG.exception(_('Service error occurred when stopping the ' - 'RPC server. Error: %s'), e) + LOG.exception(_LE('Service error occurred when stopping the ' + 'RPC server. Error: %s'), e) try: self.manager.del_host() except Exception as e: - LOG.exception(_('Service error occurred when cleaning up ' - 'the RPC manager. Error: %s'), e) + LOG.exception(_LE('Service error occurred when cleaning up ' + 'the RPC manager. Error: %s'), e) LOG.info(_LI('Stopped RPC server for service %(service)s on host ' '%(host)s.'), {'service': self.topic, 'host': self.host}) diff --git a/ironic/common/utils.py b/ironic/common/utils.py index 713ad67831..6fd7d822f6 100644 --- a/ironic/common/utils.py +++ b/ironic/common/utils.py @@ -35,6 +35,8 @@ import six from ironic.common import exception from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LW from ironic.openstack.common import log as logging from ironic.openstack.common import processutils @@ -409,7 +411,7 @@ def tempdir(**kwargs): try: shutil.rmtree(tmpdir) except OSError as e: - LOG.error(_('Could not remove tmpdir: %s'), str(e)) + LOG.error(_LE('Could not remove tmpdir: %s'), e) def mkfs(fs, path, label=None): @@ -444,8 +446,8 @@ def unlink_without_raise(path): if e.errno == errno.ENOENT: return else: - LOG.warn(_("Failed to unlink %(path)s, error: %(e)s") % - {'path': path, 'e': e}) + LOG.warn(_LW("Failed to unlink %(path)s, error: %(e)s"), + {'path': path, 'e': e}) def rmtree_without_raise(path): @@ -453,7 +455,7 @@ def rmtree_without_raise(path): if os.path.isdir(path): shutil.rmtree(path) except OSError as e: - LOG.warn(_("Failed to remove dir %(path)s, error: %(e)s") % + LOG.warn(_LW("Failed to remove dir %(path)s, error: %(e)s"), {'path': path, 'e': e}) @@ -469,9 +471,9 @@ def create_link_without_raise(source, link): if e.errno == errno.EEXIST: return else: - LOG.warn(_("Failed to create symlink from %(source)s to %(link)s" - ", error: %(e)s") % - {'source': source, 'link': link, 'e': e}) + LOG.warn(_LW("Failed to create symlink from %(source)s to %(link)s" + ", error: %(e)s"), + {'source': source, 'link': link, 'e': e}) def safe_rstrip(value, chars=None): @@ -483,8 +485,8 @@ def safe_rstrip(value, chars=None): """ if not isinstance(value, six.string_types): - LOG.warn(_("Failed to remove trailing character. Returning original " - "object. Supplied object is not a string: %s,") % value) + LOG.warn(_LW("Failed to remove trailing character. Returning original " + "object. Supplied object is not a string: %s,"), value) return value return value.rstrip(chars) or value diff --git a/tox.ini b/tox.ini index 04f732f0d3..51b69cb00b 100644 --- a/tox.ini +++ b/tox.ini @@ -48,4 +48,4 @@ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,t [hacking] import_exceptions = ironic.openstack.common.gettextutils._, ironic.openstack.common.gettextutils._LI, ironic.openstack.common.gettextutils._LW,ironic.openstack.common.gettextutils._LE, - ironic.openstack.common.gettextutils._LC, testtools.matchers, ironic.common.i18n._ + ironic.openstack.common.gettextutils._LC, testtools.matchers, ironic.common.i18n