diff options
author | Julia Kreger <juliaashleykreger@gmail.com> | 2020-02-08 07:18:12 -0800 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-03-18 10:47:14 +0100 |
commit | 0819e416b029939f403a0b736ef302a02a01dfac (patch) | |
tree | 5410ca42a63060ff862a3a710bec356af0ec361b /ironic_python_agent/extensions/image.py | |
parent | cd839b008f85d23dd784e4392ecee9653095da6c (diff) | |
download | ironic-python-agent-3.6.4.tar.gz |
Rescan devices before performing uefi checks3.6.4
With the fix to the uefi code path so secure boot works properly
and is not accidently stomped on, we forgot to rescan the device
and force the partition table to update, which is vital for iscsi
based deploys.
Conflicts:
ironic_python_agent/extensions/image.py
Depends-On: https://review.opendev.org/706960
Change-Id: Ic2f338be075e93a2ce8c76c706d37db9bf8792ea
Story: 2007276
Task: 38713
(cherry picked from commit 6f1f9c7f6ed55689f5e738e7b6f01a5c789099e5)
Diffstat (limited to 'ironic_python_agent/extensions/image.py')
-rw-r--r-- | ironic_python_agent/extensions/image.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index bb5801ff..34b10501 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -36,20 +36,28 @@ BIND_MOUNTS = ('/dev', '/proc', '/run') BOOTLOADERS_EFI = ['bootx64.efi', 'grubaa64.efi', 'winload.efi'] +def _rescan_device(device): + """Force the device to be rescanned + + :param device: device upon which to rescan and update + kernel partition records. + """ + try: + utils.execute('partx', '-u', device, attempts=3, + delay_on_retry=True) + utils.execute('udevadm', 'settle') + except processutils.ProcessExecutionError: + LOG.warning("Couldn't re-read the partition table " + "on device %s", device) + + def _get_partition(device, uuid): """Find the partition of a given device.""" LOG.debug("Find the partition %(uuid)s on device %(dev)s", {'dev': device, 'uuid': uuid}) try: - # Try to tell the kernel to re-read the partition table - try: - utils.execute('partx', '-u', device, attempts=3, - delay_on_retry=True) - utils.execute('udevadm', 'settle') - except processutils.ProcessExecutionError: - LOG.warning("Couldn't re-read the partition table " - "on device %s", device) + _rescan_device(device) lsblk = utils.execute('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE', device) report = lsblk[0] @@ -162,6 +170,10 @@ def _manage_uefi(device, efi_system_part_uuid=None): efi_mounted = False try: + # Force UEFI to rescan the device. Required if the deployment + # was over iscsi. + _rescan_device(device) + local_path = tempfile.mkdtemp() # Trust the contents on the disk in the event of a whole disk image. efi_partition = utils.get_efi_part_on_device(device) |