diff options
| author | Iury Gregory Melo Ferreira <imelofer@redhat.com> | 2019-12-02 16:56:42 +0100 |
|---|---|---|
| committer | Iury Gregory Melo Ferreira <imelofer@redhat.com> | 2020-01-16 11:23:41 +0100 |
| commit | b6210be196fea271b2c49f89d3e1638517c1198c (patch) | |
| tree | 27e8dfd35248a8ece8d7bcffdd9b12f4a03018f8 /ironic_python_agent/tests/unit/test_utils.py | |
| parent | 1b20dd9b96c9b73e45618fc88bfddfe82652d203 (diff) | |
| download | ironic-python-agent-b6210be196fea271b2c49f89d3e1638517c1198c.tar.gz | |
Avoid grub2-install when on UEFI boot mode
This patch changes the workflow for whole disk images when using uefi.
If we can identify the bootloader and it's valid we can update using
efibootmgr since grub2-install have problems specially on secure boot
mode.
We also updated the regex to search for the uefi partition on the disk,
since in some cases the parted command output can be without the FS
for the partition with esp Flag.
Change-Id: I7167e71e5d2352a045565289b200e5530d0ba11d
Story: #2006847
Task: #37435
Diffstat (limited to 'ironic_python_agent/tests/unit/test_utils.py')
| -rw-r--r-- | ironic_python_agent/tests/unit/test_utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py index 94c3a31f..8eb505ef 100644 --- a/ironic_python_agent/tests/unit/test_utils.py +++ b/ironic_python_agent/tests/unit/test_utils.py @@ -45,6 +45,18 @@ Number Start End Size File system Name Flags 1 116MB 2361MB 2245MB ext4 ''' +PARTED_OUTPUT_UNFORMATTED_NOFS = '''Model: whatever +Disk /dev/sda: 480GB +Sector size (logical/physical): 512B/512B +Partition Table: gpt +Disk Flags: + +Number Start End Size File system Name Flags +1 1049kB 9437kB 8389kB ESP boot, esp +2 9437kB 17.8MB 8389kB BSP bios_grub +3 17.8MB 40.0GB 40.0GB +4 479GB 480GB 68.1MB +''' PARTED_OUTPUT_NO_EFI = '''Model: whatever Disk /dev/sda: 450GB @@ -631,6 +643,18 @@ class TestUtils(testtools.TestCase): self.assertEqual('15', ret) @mock.patch.object(utils, 'execute', autospec=True) + def test_get_efi_part_on_device_without_fs(self, mocked_execute): + parted_ret = PARTED_OUTPUT_UNFORMATTED_NOFS.format('gpt') + mocked_execute.side_effect = [ + (parted_ret, None) + ] + ret = utils.get_efi_part_on_device('/dev/sda') + mocked_execute.assert_has_calls( + [mock.call('parted', '-s', '/dev/sda', '--', 'print')] + ) + self.assertEqual('1', ret) + + @mock.patch.object(utils, 'execute', autospec=True) def test_get_efi_part_on_device_not_found(self, mocked_execute): mocked_execute.side_effect = [ (PARTED_OUTPUT_NO_EFI, None) |
