From 833e47f5a76938e3b55555bf290919858011a896 Mon Sep 17 00:00:00 2001 From: TommyLike Date: Thu, 14 Jun 2018 10:28:09 +0800 Subject: [PATCH] Remove 'message' from format argument from exception This patch removes 'message' from format argument of 'UnableToExecuteHyperScaleCmd' exception. We should not use 'message' as a format argument and the reason is described here [1]. From a long time view we need remove them from exceptions rather than remove it when initialized. [1]: https://review.openstack.org/#/c/572674/ Change-Id: I9eb27adcd7880029a133c3657bbae67a0bc21a74 --- cinder/exception.py | 2 +- .../unit/volume/drivers/test_vrtshyperscale.py | 6 +++--- cinder/volume/drivers/veritas/utils.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cinder/exception.py b/cinder/exception.py index 7ef745aa9e5..b54dc39b2dc 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -1334,7 +1334,7 @@ class InvalidAttachment(Invalid): # Veritas driver class UnableToExecuteHyperScaleCmd(VolumeDriverException): - message = _("Failed HyperScale command for '%(message)s'") + message = _("Failed HyperScale command for '%(command)s'") class UnableToProcessHyperScaleCmdOutput(VolumeDriverException): diff --git a/cinder/tests/unit/volume/drivers/test_vrtshyperscale.py b/cinder/tests/unit/volume/drivers/test_vrtshyperscale.py index 1ed917b60ec..c5ac1eef19d 100644 --- a/cinder/tests/unit/volume/drivers/test_vrtshyperscale.py +++ b/cinder/tests/unit/volume/drivers/test_vrtshyperscale.py @@ -341,7 +341,7 @@ class VRTSHyperScaleDriverTestCase(test.TestCase): vol_a = _stub_volume() vol_b = _stub_volume() mock_mdp.side_effect = exception.UnableToExecuteHyperScaleCmd( - cmd_out='mock error') + command='mock error') self.assertRaises(exception.UnableToExecuteHyperScaleCmd, self.driver.create_cloned_volume, vol_b, vol_a) @@ -411,7 +411,7 @@ class VRTSHyperScaleDriverTestCase(test.TestCase): """Test case create volume from snapshot thorws exception.""" fake_volume, fake_snapshot = _stub_volume(), _stub_snapshot() mock_mdp.side_effect = exception.UnableToExecuteHyperScaleCmd( - cmd_out='mock error') + command='mock error') self.assertRaises(exception.UnableToExecuteHyperScaleCmd, self.driver.create_volume_from_snapshot, fake_volume, fake_snapshot) @@ -485,7 +485,7 @@ class VRTSHyperScaleDriverTestCase(test.TestCase): mock_es_obj = {'payload': {'update': False}} mock_es.return_value = mock_es_obj mock_mcp.side_effect = exception.UnableToExecuteHyperScaleCmd( - cmd_out='mock error') + command='mock error') fake_snapshot = _stub_snapshot() self.assertRaises(exception.UnableToExecuteHyperScaleCmd, self.driver.create_snapshot, fake_snapshot) diff --git a/cinder/volume/drivers/veritas/utils.py b/cinder/volume/drivers/veritas/utils.py index c54cbefa770..73d48ba9e9f 100644 --- a/cinder/volume/drivers/veritas/utils.py +++ b/cinder/volume/drivers/veritas/utils.py @@ -73,7 +73,7 @@ def get_hyperscale_version(): exception.UnableToProcessHyperScaleCmdOutput): LOG.error("Exception in running the command for version", exc_info=True) - raise exception.UnableToExecuteHyperScaleCmd(message="version") + raise exception.UnableToExecuteHyperScaleCmd(command="version") return version @@ -99,7 +99,7 @@ def get_datanode_id(): LOG.error("Error %s in getting datanode hypervisor id", cmd_err) raise exception.UnableToExecuteHyperScaleCmd( - message=cmdarg_json) + command=cmdarg_json) except exception.UnableToExecuteHyperScaleCmd: with excutils.save_and_reraise_exception(): LOG.debug("Unable to execute get_datanode_id", exc_info=True) @@ -134,7 +134,7 @@ def episodic_snap(meta): LOG.error("Error %s in processing episodic_snap", cmd_err) raise exception.UnableToExecuteHyperScaleCmd( - message=cmdarg_json) + command=cmdarg_json) except exception.UnableToExecuteHyperScaleCmd: with excutils.save_and_reraise_exception(): LOG.debug("Unable to execute episodic_snap", exc_info=True) @@ -172,7 +172,7 @@ def get_image_path(image_id, op_type='image'): LOG.error("Error %s in processing get_image_path", cmd_err) raise exception.UnableToExecuteHyperScaleCmd( - message=cmdarg_json) + command=cmdarg_json) except exception.UnableToExecuteHyperScaleCmd: with excutils.save_and_reraise_exception(): LOG.debug("Unable to execute get_image_path", exc_info=True) @@ -206,7 +206,7 @@ def update_image(image_path, volume_id, hs_img_id): LOG.error("Error %s in execution of update_image", cmd_err) raise exception.UnableToExecuteHyperScaleCmd( - message=cmdarg_json) + command=cmdarg_json) except exception.UnableToExecuteHyperScaleCmd: with excutils.save_and_reraise_exception(): LOG.debug("Unable to execute update_image", exc_info=True) @@ -232,12 +232,12 @@ def hsexecute(cmdarg_json): LOG.error("Exception in running the command for %s", cmdarg_json, exc_info=True) - raise exception.UnableToExecuteHyperScaleCmd(message=cmdarg_json) + raise exception.UnableToExecuteHyperScaleCmd(command=cmdarg_json) except Exception: LOG.error("Internal exception in cmd for %s", cmdarg_json, exc_info=True) - raise exception.UnableToExecuteHyperScaleCmd(message=cmdarg_json) + raise exception.UnableToExecuteHyperScaleCmd(command=cmdarg_json) return (cmd_out, cmd_err)