From e2506d11996a7a55ca90860b4345ea3bfa25c0fe Mon Sep 17 00:00:00 2001 From: weiweigu Date: Tue, 12 Jul 2016 16:33:39 +0800 Subject: [PATCH] Fix string interpolation to delayed to be handled by the logging code String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. See the oslo i18n guideline. * http://docs.openstack.org/developer/oslo.i18n/guidelines.html Change-Id: I410acf693d8b7b1677a7f5b1749d9c1a48aaf177 Closes-Bug: #1596829 --- os_brick/initiator/connector.py | 4 ++-- os_brick/tests/initiator/test_connector.py | 24 +++++++++++----------- os_brick/tests/initiator/test_linuxscsi.py | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/os_brick/initiator/connector.py b/os_brick/initiator/connector.py index 44f2ef1d7..b3ffd4e85 100644 --- a/os_brick/initiator/connector.py +++ b/os_brick/initiator/connector.py @@ -148,7 +148,7 @@ def get_connector_properties(root_helper, my_ip, multipath, enforce_multipath, if (utils.platform_matches(props['platform'], connector.platform) and utils.os_matches(props['os_type'], connector.os_type)): - LOG.debug("Fetching connector for %s" % connector.__name__) + LOG.debug("Fetching connector for %s", connector.__name__) props = utils.merge_dict(props, connector.get_connector_properties( root_helper, @@ -3063,7 +3063,7 @@ class DISCOConnector(BaseLinuxConnector): def _mount_disco_volume(self, path, volume_id): """Send request to mount volume on physical host.""" LOG.debug("Enter in mount disco volume %(port)s " - "and %(ip)s." % + "and %(ip)s.", {'port': self.server_port, 'ip': self.server_ip}) diff --git a/os_brick/tests/initiator/test_connector.py b/os_brick/tests/initiator/test_connector.py index 6aa5f765c..41f006f9f 100644 --- a/os_brick/tests/initiator/test_connector.py +++ b/os_brick/tests/initiator/test_connector.py @@ -2010,8 +2010,8 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f', self.fake_sdscli_file + ' -c querydev' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f'] - LOG.debug("self.cmds = %s." % self.cmds) - LOG.debug("expected = %s." % expected_commands) + LOG.debug("self.cmds = %s.", self.cmds) + LOG.debug("expected = %s.", expected_commands) self.assertEqual(expected_commands, self.cmds) @@ -2030,8 +2030,8 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): self.fake_sdscli_file + ' -c detach' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f'] - LOG.debug("self.cmds = %s." % self.cmds) - LOG.debug("expected = %s." % expected_commands) + LOG.debug("self.cmds = %s.", self.cmds) + LOG.debug("expected = %s.", expected_commands) self.assertEqual(expected_commands, self.cmds) @@ -2062,8 +2062,8 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): self.fake_sdscli_file + ' -c querydev' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f'] - LOG.debug("self.cmds = %s." % self.cmds) - LOG.debug("expected = %s." % expected_commands) + LOG.debug("self.cmds = %s.", self.cmds) + LOG.debug("expected = %s.", expected_commands) self.assertEqual(expected_commands, self.cmds) @@ -2082,8 +2082,8 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): self.connection_properties) expected_commands = [self.fake_sdscli_file + ' -c attach' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f'] - LOG.debug("self.cmds = %s." % self.cmds) - LOG.debug("expected = %s." % expected_commands) + LOG.debug("self.cmds = %s.", self.cmds) + LOG.debug("expected = %s.", expected_commands) self.assertEqual(expected_commands, self.cmds) def test_disconnect_volume_fail(self): @@ -2102,8 +2102,8 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): self.fake_sdscli_file + ' -c detach' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f'] - LOG.debug("self.cmds = %s." % self.cmds) - LOG.debug("expected = %s." % expected_commands) + LOG.debug("self.cmds = %s.", self.cmds) + LOG.debug("expected = %s.", expected_commands) self.assertEqual(expected_commands, self.cmds) @@ -2126,8 +2126,8 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): self.fake_sdscli_file + ' -c querydev' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f'] - LOG.debug("self.cmds = %s." % self.cmds) - LOG.debug("expected = %s." % expected_commands) + LOG.debug("self.cmds = %s.", self.cmds) + LOG.debug("expected = %s.", expected_commands) def test_extend_volume(self): self.assertRaises(NotImplementedError, diff --git a/os_brick/tests/initiator/test_linuxscsi.py b/os_brick/tests/initiator/test_linuxscsi.py index 0b45e18b0..295b05b90 100644 --- a/os_brick/tests/initiator/test_linuxscsi.py +++ b/os_brick/tests/initiator/test_linuxscsi.py @@ -477,7 +477,7 @@ loop0 0""" self.linuxscsi._execute = fake_execute info = self.linuxscsi.find_multipath_device('/dev/sdd') - LOG.error("Device info: %s" % info) + LOG.error("Device info: %s", info) self.assertEqual('36005076303ffc48e0000000000000101', info['id']) self.assertEqual('36005076303ffc48e0000000000000101', info['name'])