From bce7f11785bc7c98c05ebf8658bd4de597ed3c05 Mon Sep 17 00:00:00 2001 From: Kaifeng Wang Date: Wed, 18 Oct 2017 16:04:42 +0800 Subject: Implements baremetal inspect abort This patch implements the feature of baremetal inspect abort. For a node in inspect wait state, an abort request initiates the process of introspection abort. Adds transision from ``inspect wait`` to ``inspect failed`` with event ``abort`` to the state machine. Adds an ``abort`` interface to ``InspectInterface``, which raises UnsupportedDriverExtension by default. Implements the ``abort`` interface for ironic inspector inspect interface. API microversion is bumped for backwards compatibility. Closes-Bug: #10602 Story: #1703089 Task: #10602 Change-Id: I02a39ed08c7c64b36c6ef05678f0af6d8324c5e2 --- ironic/tests/unit/drivers/modules/test_inspector.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'ironic/tests/unit/drivers/modules/test_inspector.py') diff --git a/ironic/tests/unit/drivers/modules/test_inspector.py b/ironic/tests/unit/drivers/modules/test_inspector.py index 17d1f301f..4b9fdf0e3 100644 --- a/ironic/tests/unit/drivers/modules/test_inspector.py +++ b/ironic/tests/unit/drivers/modules/test_inspector.py @@ -66,7 +66,7 @@ class GetClientTestCase(db_base.DbTestCase): super(GetClientTestCase, self).setUp() # NOTE(pas-ha) force-reset global inspector session object inspector._INSPECTOR_SESSION = None - self.api_version = (1, 0) + self.api_version = (1, 3) self.context = context.RequestContext(global_request_id='global') def test__get_client(self, mock_init, mock_session, mock_auth, @@ -216,3 +216,17 @@ class CheckStatusTestCase(BaseTestCase): mock_get.assert_called_once_with(self.node.uuid) self.task.process_event.assert_called_once_with('fail') self.assertIn('boom', self.node.last_error) + + +@mock.patch('ironic.drivers.modules.inspector._get_client', autospec=True) +class InspectHardwareAbortTestCase(BaseTestCase): + def test_abort_ok(self, mock_client): + mock_abort = mock_client.return_value.abort + self.driver.inspect.abort(self.task) + mock_abort.assert_called_once_with(self.node.uuid) + + def test_abort_error(self, mock_client): + mock_abort = mock_client.return_value.abort + mock_abort.side_effect = RuntimeError('boom') + self.assertRaises(RuntimeError, self.driver.inspect.abort, self.task) + mock_abort.assert_called_once_with(self.node.uuid) -- cgit v1.2.1