Fixes error handling if efibootmgr is not present in ramdisk

Change-Id: I8edff252e72cb91282f8984cd6935f39cd744cfe
Story: 2007324
Task: 38842
This commit is contained in:
mvpnitesh 2020-02-21 05:24:05 -06:00
parent add4d03349
commit 823a7cd9db
3 changed files with 22 additions and 1 deletions

View File

@ -520,7 +520,7 @@ class ImageExtension(base.BaseAgentExtension):
has_efibootmgr = True
try:
utils.execute('efibootmgr', '--version')
except errors.CommandExecutionError:
except FileNotFoundError:
LOG.warning("efibootmgr is not available in the ramdisk")
has_efibootmgr = False

View File

@ -293,6 +293,21 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
prep_boot_part_uuid=self.fake_prep_boot_part_uuid)
mock_iscsi_clean.assert_called_once_with(self.fake_dev)
@mock.patch.object(os.path, 'exists', lambda *_: False)
@mock.patch.object(iscsi, 'clean_up', autospec=True)
def test_install_bootloader_failure(self, mock_iscsi_clean, mock_execute,
mock_dispatch):
mock_dispatch.side_effect = [
self.fake_dev, hardware.BootInfo(current_boot_mode='uefi')
]
mock_execute.side_effect = FileNotFoundError
self.assertRaises(FileNotFoundError,
self.agent_extension.install_bootloader,
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None)
expected = [mock.call('efibootmgr', '--version')]
mock_execute.assert_has_calls(expected)
@mock.patch.object(image, '_is_bootloader_loaded', lambda *_: False)
@mock.patch.object(hardware, 'is_md_device', autospec=True)
@mock.patch.object(hardware, 'md_get_raid_devices', autospec=True)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes error handling if efibootmgr is not present in ramdisk.
See `story <https://storyboard.openstack.org/#!/story/2007324>`_
for more details.