Logging not using oslo.i18n guidelines
Part of multi-patch set for easier chunks. There have been quite a few instances found where the i18n guidelines are not being followed. I believe this has helped lead to some of the confusion around how to correctly do this. Other developers see this code and assume it is an example of the correct usage. This patch attempts to clean up most of those violations in the existing codebase to hopefully help avoid some of that confusion in reviews. Some issues address: * Correct log translation markers for different log levels * Passing format values as arguments to call, not preformatting * Not forcing translation via six.text_type and others Guidelines can be found here: http://docs.openstack.org/developer/oslo.i18n/guidelines.html Hacking checks will not be able to identify all violations of the guidelines, but it could be useful for catching obvious ones such as LOG.info("No markers!"). Change-Id: I38f52c6408b47ccb59ec2064b360f7d4427d6830 Partial-bug: 1433216
This commit is contained in:
@@ -25,6 +25,7 @@ from eventlet import pools
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import paramiko
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
from cinder.i18n import _, _LI
|
||||
@@ -80,12 +81,12 @@ class SSHPool(pools.Pool):
|
||||
if 'hosts_key_file' in kwargs.keys():
|
||||
self.hosts_key_file = kwargs.pop('hosts_key_file')
|
||||
LOG.info(_LI("Secondary ssh hosts key file %(kwargs)s will be "
|
||||
"loaded along with %(conf)s from /etc/cinder.conf.") %
|
||||
"loaded along with %(conf)s from /etc/cinder.conf."),
|
||||
{'kwargs': self.hosts_key_file,
|
||||
'conf': CONF.ssh_hosts_key_file})
|
||||
|
||||
LOG.debug("Setting strict_ssh_host_key_policy to '%(policy)s' "
|
||||
"using ssh_hosts_key_file '%(key_file)s'." %
|
||||
"using ssh_hosts_key_file '%(key_file)s'.",
|
||||
{'policy': CONF.strict_ssh_host_key_policy,
|
||||
'key_file': CONF.ssh_hosts_key_file})
|
||||
|
||||
@@ -148,7 +149,7 @@ class SSHPool(pools.Pool):
|
||||
transport.set_keepalive(self.conn_timeout)
|
||||
return ssh
|
||||
except Exception as e:
|
||||
msg = _("Error connecting via ssh: %s") % e
|
||||
msg = _("Error connecting via ssh: %s") % six.text_type(e)
|
||||
LOG.error(msg)
|
||||
raise paramiko.SSHException(msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user