Fix compatibility with disk_utils.find_efi_partition

This function returns the complete block device record, not just number.
Fixes regression in 89bc73aa01.

Also fix the incorrect job in the gate queue, which prevented us from
catching this issue on merging.

Change-Id: I4cbc359ceabfc193ce18fed14a1952359460e7d9
This commit is contained in:
Dmitry Tantsur 2021-11-19 14:48:38 +01:00
parent de385cb291
commit abe38a6a5f
5 changed files with 16 additions and 13 deletions

View File

@ -50,6 +50,9 @@ def manage_uefi(device, efi_system_part_uuid=None):
local_path = tempfile.mkdtemp() local_path = tempfile.mkdtemp()
# Trust the contents on the disk in the event of a whole disk image. # Trust the contents on the disk in the event of a whole disk image.
efi_partition = disk_utils.find_efi_partition(device) efi_partition = disk_utils.find_efi_partition(device)
if efi_partition:
efi_partition = efi_partition['number']
if not efi_partition and efi_system_part_uuid: if not efi_partition and efi_system_part_uuid:
# _get_partition returns <device>+<partition> and we only need the # _get_partition returns <device>+<partition> and we only need the
# partition number # partition number
@ -100,7 +103,7 @@ def manage_uefi(device, efi_system_part_uuid=None):
return False return False
except processutils.ProcessExecutionError as e: except processutils.ProcessExecutionError as e:
error_msg = ('Could not verify uefi on device %(dev)s' error_msg = ('Could not verify uefi on device %(dev)s, '
'failed with %(err)s.' % {'dev': device, 'err': e}) 'failed with %(err)s.' % {'dev': device, 'err': e})
LOG.error(error_msg) LOG.error(error_msg)
raise errors.CommandExecutionError(error_msg) raise errors.CommandExecutionError(error_msg)

View File

@ -139,7 +139,7 @@ def _prepare_boot_partitions_for_softraid(device, holders, efi_part,
# let grub handle the magic. # let grub handle the magic.
efi_part = disk_utils.find_efi_partition(device) efi_part = disk_utils.find_efi_partition(device)
if efi_part: if efi_part:
efi_part = '{}p{}'.format(device, efi_part) efi_part = '{}p{}'.format(device, efi_part['number'])
LOG.info("Creating EFI partitions on software RAID holder disks") LOG.info("Creating EFI partitions on software RAID holder disks")
# We know that we kept this space when configuring raid,see # We know that we kept this space when configuring raid,see

View File

@ -225,7 +225,7 @@ class TestImageExtension(base.IronicAgentTest):
] ]
mock_partition.side_effect = [self.fake_dev, self.fake_efi_system_part] mock_partition.side_effect = [self.fake_dev, self.fake_efi_system_part]
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_execute.side_effect = iter([('', ''), ('', ''), mock_execute.side_effect = iter([('', ''), ('', ''),
('', ''), ('', ''), ('', ''), ('', ''),
@ -272,7 +272,7 @@ class TestImageExtension(base.IronicAgentTest):
self.fake_dev, hardware.BootInfo(current_boot_mode='uefi') self.fake_dev, hardware.BootInfo(current_boot_mode='uefi')
] ]
mock_partition.return_value = self.fake_dev mock_partition.return_value = self.fake_dev
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']
mock_execute.side_effect = iter([('', ''), ('', ''), mock_execute.side_effect = iter([('', ''), ('', ''),
('', ''), ('', ''), ('', ''), ('', ''),
@ -319,7 +319,7 @@ class TestImageExtension(base.IronicAgentTest):
self.fake_dev, hardware.BootInfo(current_boot_mode='uefi') self.fake_dev, hardware.BootInfo(current_boot_mode='uefi')
] ]
mock_partition.return_value = self.fake_dev mock_partition.return_value = self.fake_dev
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']
stdout_msg = """ stdout_msg = """
BootCurrent: 0001 BootCurrent: 0001
@ -376,7 +376,7 @@ Boot0002 VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51)
self.fake_dev, hardware.BootInfo(current_boot_mode='uefi') self.fake_dev, hardware.BootInfo(current_boot_mode='uefi')
] ]
mock_partition.return_value = self.fake_dev mock_partition.return_value = self.fake_dev
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']
# NOTE(TheJulia): This test string was derived from a lenovo SR650 # NOTE(TheJulia): This test string was derived from a lenovo SR650
# which does do some weird things with additional entries. # which does do some weird things with additional entries.
@ -438,7 +438,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dev, hardware.BootInfo(current_boot_mode='uefi') self.fake_dev, hardware.BootInfo(current_boot_mode='uefi')
] ]
mock_partition.return_value = self.fake_dev mock_partition.return_value = self.fake_dev
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI', mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI',
'WINDOWS/system32/winload.efi'] 'WINDOWS/system32/winload.efi']
@ -1656,7 +1656,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
@mock.patch.object(disk_utils, 'find_efi_partition', autospec=True) @mock.patch.object(disk_utils, 'find_efi_partition', autospec=True)
def test__prepare_boot_partitions_for_softraid_uefi_gpt( def test__prepare_boot_partitions_for_softraid_uefi_gpt(
self, mock_efi_part, mock_execute, mock_dispatch): self, mock_efi_part, mock_execute, mock_dispatch):
mock_efi_part.return_value = '12' mock_efi_part.return_value = {'number': '12'}
mock_execute.side_effect = [ mock_execute.side_effect = [
('451', None), # sgdisk -F ('451', None), # sgdisk -F
(None, None), # sgdisk create part (None, None), # sgdisk create part

View File

@ -162,7 +162,7 @@ class TestManageUefi(base.IronicAgentTest):
@mock.patch.object(os, 'makedirs', autospec=True) @mock.patch.object(os, 'makedirs', autospec=True)
def test_ok(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part, def test_ok(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part,
mock_get_part_uuid, mock_execute, mock_rescan): mock_get_part_uuid, mock_execute, mock_rescan):
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_get_part_uuid.return_value = self.fake_dev mock_get_part_uuid.return_value = self.fake_dev
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']
@ -196,7 +196,7 @@ class TestManageUefi(base.IronicAgentTest):
@mock.patch.object(os, 'makedirs', autospec=True) @mock.patch.object(os, 'makedirs', autospec=True)
def test_found_csv(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part, def test_found_csv(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part,
mock_get_part_uuid, mock_execute, mock_rescan): mock_get_part_uuid, mock_execute, mock_rescan):
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_get_part_uuid.return_value = self.fake_dev mock_get_part_uuid.return_value = self.fake_dev
mock_efi_bl.return_value = ['EFI/vendor/BOOTX64.CSV'] mock_efi_bl.return_value = ['EFI/vendor/BOOTX64.CSV']
@ -246,7 +246,7 @@ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51)
@mock.patch.object(os, 'makedirs', autospec=True) @mock.patch.object(os, 'makedirs', autospec=True)
def test_nvme_device(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part, def test_nvme_device(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part,
mock_get_part_uuid, mock_execute, mock_rescan): mock_get_part_uuid, mock_execute, mock_rescan):
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_get_part_uuid.return_value = '/dev/fakenvme0p1' mock_get_part_uuid.return_value = '/dev/fakenvme0p1'
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']
@ -278,7 +278,7 @@ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51)
@mock.patch.object(os, 'makedirs', autospec=True) @mock.patch.object(os, 'makedirs', autospec=True)
def test_wholedisk(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part, def test_wholedisk(self, mkdir_mock, mock_efi_bl, mock_utils_efi_part,
mock_get_part_uuid, mock_execute, mock_rescan): mock_get_part_uuid, mock_execute, mock_rescan):
mock_utils_efi_part.return_value = '1' mock_utils_efi_part.return_value = {'number': '1'}
mock_get_part_uuid.side_effect = Exception mock_get_part_uuid.side_effect = Exception
mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI'] mock_efi_bl.return_value = ['EFI/BOOT/BOOTX64.EFI']

View File

@ -39,7 +39,7 @@
- openstack-tox-functional - openstack-tox-functional
- ipa-tempest-bios-ipmi-direct-src - ipa-tempest-bios-ipmi-direct-src
- ipa-tempest-uefi-redfish-vmedia-src - ipa-tempest-uefi-redfish-vmedia-src
- metalsmith-integration-ipa-src - metalsmith-integration-ipa-src-uefi
post: post:
jobs: jobs:
- ironic-python-agent-build-image-tinyipa - ironic-python-agent-build-image-tinyipa