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
This commit is contained in:
ankit 2020-10-29 05:35:03 +00:00
parent 4a7d50ce56
commit 2e6777d757
3 changed files with 21 additions and 2 deletions

View File

@ -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]

View File

@ -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()

View File

@ -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.