diff --git a/ironic_python_agent/extensions/base.py b/ironic_python_agent/extensions/base.py index 03b839450..17bad14bd 100644 --- a/ironic_python_agent/extensions/base.py +++ b/ironic_python_agent/extensions/base.py @@ -235,10 +235,7 @@ class ExecuteCommandMixin(object): except Exception as e: # Other errors are considered command execution errors, and are # recorded as an - result = SyncCommandResult(command_name, - kwargs, - False, - six.text_type(e)) + result = SyncCommandResult(command_name, kwargs, False, e) self.command_results[result.id] = result return result diff --git a/ironic_python_agent/tests/extensions/base.py b/ironic_python_agent/tests/extensions/base.py index b033314cb..c2f0b22d0 100644 --- a/ironic_python_agent/tests/extensions/base.py +++ b/ironic_python_agent/tests/extensions/base.py @@ -105,16 +105,16 @@ class TestExecuteCommandMixin(test_base.BaseTestCase): 'fake.sleep', sleep_info={"time": 1}) def test_execute_command_other_exception(self): - msg = 'foo bar baz' fake_ext = self.agent.ext_mgr['fake'].obj fake_ext.execute = mock.Mock() - fake_ext.execute.side_effect = Exception(msg) + exc = errors.CommandExecutionError('foo bar baz') + fake_ext.execute.side_effect = exc result = self.agent.execute_command( 'fake.sleep', sleep_info={"time": 1} ) - self.assertEqual(result.command_status, - base.AgentCommandStatus.FAILED) - self.assertEqual(result.command_error, {'error': msg}) + self.assertEqual(base.AgentCommandStatus.FAILED, + result.command_status) + self.assertEqual(exc, result.command_error) class TestExtensionDecorators(test_base.BaseTestCase):