diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index 8ddeca14096..29da738785c 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -94,8 +94,8 @@ class DhcpAgent(manager.Manager): # If 'resync_throttle' is configured more than 'resync_interval' by # mistake, raise exception and log with message. if self.conf.resync_throttle > self.conf.resync_interval: - msg = _("DHCP agent must have resync_throttle <= resync_interval") - LOG.exception(msg) + LOG.exception("DHCP agent must have resync_throttle <= " + "resync_interval") raise exceptions.InvalidConfigurationOption( opt_name='resync_throttle', opt_value=self.conf.resync_throttle) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 7eecf8c343d..10222eb6a90 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -35,7 +35,6 @@ from oslo_utils import fileutils from oslo_utils import netutils from oslo_utils import uuidutils -from neutron._i18n import _ from neutron.agent.common import utils as agent_common_utils from neutron.agent.linux import external_process from neutron.agent.linux import ip_lib @@ -304,17 +303,13 @@ class DhcpLocalProcess(DhcpBase, metaclass=abc.ABCMeta): def _get_value_from_conf_file(self, kind, converter=None): """A helper function to read a value from one of the state files.""" file_name = self.get_conf_file_name(kind) - msg = _('Error while reading %s') - try: with open(file_name, 'r') as f: - try: - return converter(f.read()) if converter else f.read() - except ValueError: - msg = _('Unable to convert value in %s') + return converter(f.read()) if converter else f.read() + except ValueError: + msg = "Unable to convert value in %s" except IOError: - msg = _('Unable to access %s') - + msg = "Unable to access %s" LOG.debug(msg, file_name) return None diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index cc6f889dad8..8bb67444550 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -1024,8 +1024,8 @@ def _arping(ns_name, iface_name, address, count, log_exception): [address], mac=None, namespace=ns_name) - msg = _("Failed sending gratuitous ARP to %(addr)s on " - "%(iface)s in namespace %(ns)s: %(err)s") + msg = ("Failed sending gratuitous ARP to %(addr)s on " + "%(iface)s in namespace %(ns)s: %(err)s") logger_method = LOG.exception if not (log_exception and (first or exists)): logger_method = LOG.info diff --git a/neutron/agent/linux/utils.py b/neutron/agent/linux/utils.py index db836b3150d..b3a44a9fbf6 100644 --- a/neutron/agent/linux/utils.py +++ b/neutron/agent/linux/utils.py @@ -128,23 +128,22 @@ def execute(cmd, process_input=None, addl_env=None, extra_ok_codes = extra_ok_codes or [] if returncode and returncode not in extra_ok_codes: - msg = _("Exit code: %(returncode)d; " - "Cmd: %(cmd)s; " - "Stdin: %(stdin)s; " - "Stdout: %(stdout)s; " - "Stderr: %(stderr)s") % { + msg = ("Exit code: %(returncode)d; " + "Cmd: %(cmd)s; " + "Stdin: %(stdin)s; " + "Stdout: %(stdout)s; " + "Stderr: %(stderr)s" % { 'returncode': returncode, 'cmd': cmd, 'stdin': process_input or '', 'stdout': _stdout, - 'stderr': _stderr} + 'stderr': _stderr}) if log_fail_as_error: LOG.error(msg) if check_exit_code: - raise exceptions.ProcessExecutionError(msg, + raise exceptions.ProcessExecutionError(_(msg), returncode=returncode) - finally: # NOTE(termie): this appears to be necessary to let the subprocess # call clean something up in between calls, without diff --git a/neutron/agent/windows/utils.py b/neutron/agent/windows/utils.py index 8f16d63f869..0658e3155b3 100644 --- a/neutron/agent/windows/utils.py +++ b/neutron/agent/windows/utils.py @@ -114,13 +114,13 @@ def execute(cmd, process_input=None, addl_env=None, _stdout = helpers.safe_decode_utf8(_stdout) _stderr = helpers.safe_decode_utf8(_stderr) - m = _("\nCommand: %(cmd)s\nExit code: %(code)s\nStdin: %(stdin)s\n" - "Stdout: %(stdout)s\nStderr: %(stderr)s") % \ - {'cmd': cmd, - 'code': obj.returncode, - 'stdin': process_input or '', - 'stdout': _stdout, - 'stderr': _stderr} + m = ("\nCommand: %(cmd)s\nExit code: %(code)s\nStdin: %(stdin)s\n" + "Stdout: %(stdout)s\nStderr: %(stderr)s" % + {'cmd': cmd, + 'code': obj.returncode, + 'stdin': process_input or '', + 'stdout': _stdout, + 'stderr': _stderr}) extra_ok_codes = extra_ok_codes or [] if obj.returncode and obj.returncode in extra_ok_codes: @@ -133,8 +133,7 @@ def execute(cmd, process_input=None, addl_env=None, LOG.debug(log_msg) if obj.returncode and check_exit_code: - raise exceptions.ProcessExecutionError(m, returncode=obj.returncode) - + raise exceptions.ProcessExecutionError(_(m), returncode=obj.returncode) return (_stdout, _stderr) if return_stderr else _stdout diff --git a/neutron/privileged/agent/linux/netlink_lib.py b/neutron/privileged/agent/linux/netlink_lib.py index c9afbcc4918..f330f925a7a 100644 --- a/neutron/privileged/agent/linux/netlink_lib.py +++ b/neutron/privileged/agent/linux/netlink_lib.py @@ -43,7 +43,6 @@ from neutron_lib import constants from neutron_lib import exceptions from oslo_log import log as logging -from neutron._i18n import _ from neutron import privileged from neutron.privileged.agent.linux import netlink_constants as nl_constants @@ -192,8 +191,7 @@ class ConntrackManager(object): self._set_attributes(conntrack, entry) self._query(nl_constants.NFCT_Q_DESTROY, conntrack) except Exception as e: - msg = _("Failed to delete conntrack entries %s") % e - LOG.critical(msg) + LOG.critical("Failed to delete conntrack entries %s", e) raise exceptions.CTZoneExhaustedError() finally: nfct.nfct_destroy(conntrack) @@ -234,8 +232,7 @@ class ConntrackManager(object): nl_constants.NFNL_SUBSYS_CTNETLINK, nl_constants.CONNTRACK) if not self.conntrack_handler: - msg = _("Failed to open new conntrack handler") - LOG.critical(msg) + LOG.critical("Failed to open new conntrack handler") raise exceptions.CTZoneExhaustedError() return self