From 2e6777d757031a5ea0e52ff0e49a6ca1f3b84316 Mon Sep 17 00:00:00 2001 From: ankit Date: Thu, 29 Oct 2020 05:35:03 +0000 Subject: [PATCH] Fixes issue of redfish firmware update Currently ilo5 based hardware does not support redfish based firmware update. This patch fixes the issue by making the change to to check whether sushy_task.messages is present. It was also not calling prepare_ramdisk() before rebooting the system to update the firmware which has been fixed in this patch. Change-Id: I9d70fed0de1829973748c06a1342d7a7af0f93d4 Story: #2008403 Task: #41339 --- ironic/drivers/modules/redfish/management.py | 4 +++- .../unit/drivers/modules/redfish/test_management.py | 10 +++++++++- ...redfish-firmware-update-issue-c6dfcd71a2f659a5.yaml | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fixes-ilo5-redfish-firmware-update-issue-c6dfcd71a2f659a5.yaml diff --git a/ironic/drivers/modules/redfish/management.py b/ironic/drivers/modules/redfish/management.py index 2762394333..c4ebd953cf 100644 --- a/ironic/drivers/modules/redfish/management.py +++ b/ironic/drivers/modules/redfish/management.py @@ -742,6 +742,8 @@ class RedfishManagement(base.ManagementInterface): skip_current_step=True, polling=True) + deploy_opts = deploy_utils.build_agent_options(task.node) + task.driver.boot.prepare_ramdisk(task, deploy_opts) manager_utils.node_power_action(task, states.REBOOT) return deploy_utils.get_async_step_return_state(task.node) @@ -999,7 +1001,7 @@ class RedfishManagement(base.ManagementInterface): # Only parse the messages if the BMC did not return parsed # messages messages = [] - if not sushy_task.messages[0].message: + if sushy_task.messages and not sushy_task.messages[0].message: sushy_task.parse_messages() messages = [m.message for m in sushy_task.messages] diff --git a/ironic/tests/unit/drivers/modules/redfish/test_management.py b/ironic/tests/unit/drivers/modules/redfish/test_management.py index 98f3b75f77..f9e74d964c 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_management.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_management.py @@ -27,6 +27,7 @@ from ironic.common import states from ironic.conductor import task_manager from ironic.conductor import utils as manager_utils from ironic.drivers.modules import deploy_utils +from ironic.drivers.modules.redfish import boot as redfish_boot from ironic.drivers.modules.redfish import management as redfish_mgmt from ironic.drivers.modules.redfish import utils as redfish_utils from ironic.tests.unit.db import base as db_base @@ -740,6 +741,10 @@ class RedfishManagementTestCase(db_base.DbTestCase): response = task.driver.management.detect_vendor(task) self.assertEqual("Fake GmbH", response) + @mock.patch.object(deploy_utils, 'build_agent_options', + spec_set=True, autospec=True) + @mock.patch.object(redfish_boot.RedfishVirtualMediaBoot, 'prepare_ramdisk', + spec_set=True, autospec=True) @mock.patch.object(manager_utils, 'node_power_action', autospec=True) @mock.patch.object(deploy_utils, 'get_async_step_return_state', autospec=True) @@ -748,7 +753,9 @@ class RedfishManagementTestCase(db_base.DbTestCase): def test_update_firmware(self, mock_get_update_service, mock_set_async_step_flags, mock_get_async_step_return_state, - mock_node_power_action): + mock_node_power_action, mock_prepare, + build_mock): + build_mock.return_value = {'a': 'b'} mock_task_monitor = mock.Mock() mock_task_monitor.task_monitor = '/task/123' mock_update_service = mock.Mock() @@ -1142,6 +1149,7 @@ class RedfishManagementTestCase(db_base.DbTestCase): mock_message = mock.Mock() mock_message.message = 'Firmware upgrade failed' messages = mock.PropertyMock(side_effect=[[mock_message_unparsed], + [mock_message], [mock_message]]) type(mock_sushy_task).messages = messages mock_task_monitor = mock.Mock() diff --git a/releasenotes/notes/fixes-ilo5-redfish-firmware-update-issue-c6dfcd71a2f659a5.yaml b/releasenotes/notes/fixes-ilo5-redfish-firmware-update-issue-c6dfcd71a2f659a5.yaml new file mode 100644 index 0000000000..bb114c2bc2 --- /dev/null +++ b/releasenotes/notes/fixes-ilo5-redfish-firmware-update-issue-c6dfcd71a2f659a5.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fixes redfish firmware update for ilo5 based hardware by + making necessary changes to check whether sushy_task.messages + is present, since in case of iLo task data does not contain + messages attribute. Also it was not calling prepare_ramdisk() + before rebooting the system to update the firmware which has + been fixed in this patch.