Fix string interpolations in logging calls
String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. * https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages The check rule for string format method will be added in openstack/hacking. TrivialFix Change-Id: I6ec56ec35bcb33d6627a47b66c4f7fc2c6f22658
This commit is contained in:
@@ -234,10 +234,10 @@ def verify_deprecated_policy(old_policy, new_policy, default_rule, context):
|
||||
current_rule = None
|
||||
|
||||
if current_rule != default_rule:
|
||||
LOG.warning("Start using the new action '{0}'. The existing "
|
||||
"action '{1}' is being deprecated and will be "
|
||||
"removed in future release.".format(new_policy,
|
||||
old_policy))
|
||||
LOG.warning("Start using the new action '%(new_policy)s'. "
|
||||
"The existing action '%(old_policy)s' is being deprecated "
|
||||
"and will be removed in future release.",
|
||||
{'new_policy': new_policy, 'old_policy': old_policy})
|
||||
context.can(old_policy)
|
||||
return True
|
||||
else:
|
||||
|
@@ -563,10 +563,11 @@ class FlavorManagerPolicyEnforcementV21(test.TestCase):
|
||||
self.assertEqual(
|
||||
"Policy doesn't allow %s to be performed." % default_flavor_policy,
|
||||
exc.format_message())
|
||||
mock_warning.assert_called_with("Start using the new "
|
||||
"action '{0}'. The existing action '{1}' is being deprecated and "
|
||||
"will be removed in future release.".format(create_flavor_policy,
|
||||
default_flavor_policy))
|
||||
mock_warning.assert_called_with("Start using the new action "
|
||||
"'%(new_policy)s'. The existing action '%(old_policy)s' is being "
|
||||
"deprecated and will be removed in future release.",
|
||||
{'new_policy': create_flavor_policy,
|
||||
'old_policy': default_flavor_policy})
|
||||
|
||||
@mock.patch.object(policy.LOG, 'warning')
|
||||
def test_delete_policy_rbac_inherit_default(self, mock_warning):
|
||||
@@ -597,9 +598,10 @@ class FlavorManagerPolicyEnforcementV21(test.TestCase):
|
||||
}
|
||||
self.flavor = self.controller._create(self.adm_req, body=body)
|
||||
mock_warning.assert_called_once_with("Start using the new "
|
||||
"action '{0}'. The existing action '{1}' is being deprecated and "
|
||||
"will be removed in future release.".format(create_flavor_policy,
|
||||
default_flavor_policy))
|
||||
"action '%(new_policy)s'. The existing action '%(old_policy)s' "
|
||||
"is being deprecated and will be removed in future release.",
|
||||
{'new_policy': create_flavor_policy,
|
||||
'old_policy': default_flavor_policy})
|
||||
# check for success as admin
|
||||
flavor = self.flavor
|
||||
self.controller._delete(self.adm_req, flavor['flavor']['id'])
|
||||
@@ -614,9 +616,10 @@ class FlavorManagerPolicyEnforcementV21(test.TestCase):
|
||||
"Policy doesn't allow %s to be performed." % default_flavor_policy,
|
||||
exc.format_message())
|
||||
mock_warning.assert_called_with("Start using the new "
|
||||
"action '{0}'. The existing action '{1}' is being deprecated and "
|
||||
"will be removed in future release.".format(delete_flavor_policy,
|
||||
default_flavor_policy))
|
||||
"action '%(new_policy)s'. The existing action '%(old_policy)s' "
|
||||
"is being deprecated and will be removed in future release.",
|
||||
{'new_policy': delete_flavor_policy,
|
||||
'old_policy': default_flavor_policy})
|
||||
|
||||
def test_create_policy_rbac_no_change_to_default_action_rule(self):
|
||||
"""Test to verify the correct action is being enforced. When the
|
||||
|
@@ -193,9 +193,9 @@ class PolicyTestCase(test.NoDBTestCase):
|
||||
old_policy, new_policy, default_rule, self.context)
|
||||
|
||||
mock_warning.assert_called_once_with("Start using the new "
|
||||
"action '{0}'. The existing action '{1}' is being deprecated and "
|
||||
"will be removed in future release.".format(new_policy,
|
||||
old_policy))
|
||||
"action '%(new_policy)s'. The existing action '%(old_policy)s' "
|
||||
"is being deprecated and will be removed in future release.",
|
||||
{'new_policy': new_policy, 'old_policy': old_policy})
|
||||
self.assertTrue(using_old_action)
|
||||
|
||||
def test_verify_deprecated_policy_using_new_action(self):
|
||||
|
@@ -210,10 +210,9 @@ class RBDDriver(object):
|
||||
return False
|
||||
|
||||
if image_meta.get('disk_format') != 'raw':
|
||||
reason = ("rbd image clone requires image format to be "
|
||||
"'raw' but image {0} is '{1}'").format(
|
||||
url, image_meta.get('disk_format'))
|
||||
LOG.debug(reason)
|
||||
LOG.debug("rbd image clone requires image format to be "
|
||||
"'raw' but image %s is '%s'",
|
||||
url, image_meta.get('disk_format'))
|
||||
return False
|
||||
|
||||
# check that we can read the image
|
||||
|
Reference in New Issue
Block a user