From 85b0d3e141e226ca6de71b48e2d37e66f317f362 Mon Sep 17 00:00:00 2001 From: vmud213 Date: Mon, 17 Sep 2018 17:48:35 +0530 Subject: [PATCH] Honors return value from BIOS interface cleansteps When a BIOS interface clean step is executed the return value is ignored. If it is asynchronous, the return value which is CLEANWAIT state is ignored and the cleanstep is marked as complete immediately. The current change honors the return value and moves the node to CLEANWAIT state accordingly. Change-Id: I3a3915116286326316ee9a55333c046f729c1a08 Story: #2003750 Task: #26438 --- ironic/drivers/base.py | 3 ++- ironic/tests/unit/drivers/test_base.py | 10 ++++++---- .../notes/async_bios_clean_step-7348efff3f6d02c1.yaml | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/async_bios_clean_step-7348efff3f6d02c1.yaml diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py index 1c6a376099..a712cc43f4 100644 --- a/ironic/drivers/base.py +++ b/ironic/drivers/base.py @@ -1039,8 +1039,9 @@ class BIOSInterface(BaseInterface): def wrapper(func): @six.wraps(func) def wrapped(task, *args, **kwargs): - func(task, *args, **kwargs) + result = func(task, *args, **kwargs) instance.cache_bios_settings(task) + return result return wrapped for n, method in inspect.getmembers(instance, inspect.ismethod): diff --git a/ironic/tests/unit/drivers/test_base.py b/ironic/tests/unit/drivers/test_base.py index d3f7367655..1233810254 100644 --- a/ironic/tests/unit/drivers/test_base.py +++ b/ironic/tests/unit/drivers/test_base.py @@ -550,10 +550,10 @@ class MyBIOSInterface(driver_base.BIOSInterface): pass def apply_configuration(self, task, settings): - pass + return "return_value_apply_configuration" def factory_reset(self, task): - pass + return "return_value_factory_reset" def cache_bios_settings(self, task): pass @@ -566,16 +566,18 @@ class TestBIOSInterface(base.TestCase): bios = MyBIOSInterface() task_mock = mock.MagicMock() - bios.apply_configuration(task_mock, "") + actual = bios.apply_configuration(task_mock, "") cache_bios_settings_mock.assert_called_once_with(bios, task_mock) + self.assertEqual(actual, "return_value_apply_configuration") @mock.patch.object(MyBIOSInterface, 'cache_bios_settings', autospec=True) def test_factory_reset_wrapper(self, cache_bios_settings_mock): bios = MyBIOSInterface() task_mock = mock.MagicMock() - bios.factory_reset(task_mock) + actual = bios.factory_reset(task_mock) cache_bios_settings_mock.assert_called_once_with(bios, task_mock) + self.assertEqual(actual, "return_value_factory_reset") class TestBootInterface(base.TestCase): diff --git a/releasenotes/notes/async_bios_clean_step-7348efff3f6d02c1.yaml b/releasenotes/notes/async_bios_clean_step-7348efff3f6d02c1.yaml new file mode 100644 index 0000000000..bbe4850012 --- /dev/null +++ b/releasenotes/notes/async_bios_clean_step-7348efff3f6d02c1.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes the bug in executing asynchronous BIOS interface clean step by + honoring the state returned by the BIOS interface clean step which + was ignored earlier.