summaryrefslogtreecommitdiff
path: root/ironic_python_agent
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-06-25 15:25:33 +0000
committerGerrit Code Review <review@openstack.org>2021-06-25 15:25:33 +0000
commit20e145e4da853cd759387e8d8727086f399e51b3 (patch)
treebc4541f7c4e35344b75e873a073321bab434acbb /ironic_python_agent
parentb605943796c24a174f0709b84170e0c6de7f4238 (diff)
parent27568204aeb7f063bf236ad7f2f8043db627baa9 (diff)
downloadironic-python-agent-20e145e4da853cd759387e8d8727086f399e51b3.tar.gz
Merge "Only mount the ESP if not yet mounted"
Diffstat (limited to 'ironic_python_agent')
-rw-r--r--ironic_python_agent/extensions/image.py4
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_image.py16
2 files changed, 13 insertions, 7 deletions
diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py
index ba7a2bb9..03fc7636 100644
--- a/ironic_python_agent/extensions/image.py
+++ b/ironic_python_agent/extensions/image.py
@@ -662,7 +662,9 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None,
LOG.warning("GRUB2 will be installed for UEFI on efi partition "
"%s using the install command which does not place "
"Secure Boot signed binaries.", efi_partition)
- utils.execute('mount', efi_partition, efi_partition_mount_point)
+ if not os.path.ismount(efi_partition_mount_point):
+ utils.execute('mount', efi_partition,
+ efi_partition_mount_point)
efi_mounted = True
try:
utils.execute('chroot %(path)s /bin/sh -c '
diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py
index 4f06e465..9661e6f3 100644
--- a/ironic_python_agent/tests/unit/extensions/test_image.py
+++ b/ironic_python_agent/tests/unit/extensions/test_image.py
@@ -576,7 +576,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
uuid=self.fake_prep_boot_part_uuid)
self.assertFalse(mock_dispatch.called)
- @mock.patch.object(os.path, 'ismount', lambda *_: True)
+ @mock.patch.object(os.path, 'ismount', lambda *_: False)
@mock.patch.object(os.path, 'exists', lambda *_: False)
@mock.patch.object(image, '_is_bootloader_loaded', lambda *_: True)
@mock.patch.object(image, '_append_uefi_to_fstab', autospec=True)
@@ -609,6 +609,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
self.fake_dir + '/sys'),
+ mock.call('mount', '/dev/fake2', self.fake_dir),
mock.call(('chroot %s /bin/sh -c "mount -a -t vfat"' %
(self.fake_dir)), shell=True,
env_variables={
@@ -664,7 +665,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
mock_append_to_fstab.assert_called_with(self.fake_dir,
self.fake_efi_system_part_uuid)
- @mock.patch.object(os.path, 'ismount', lambda *_: True)
+ @mock.patch.object(os.path, 'ismount', lambda *_: False)
@mock.patch.object(image, '_is_bootloader_loaded', lambda *_: True)
@mock.patch.object(os.path, 'exists', autospec=True)
@mock.patch.object(hardware, 'is_md_device', autospec=True)
@@ -706,6 +707,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
self.fake_dir + '/sys'),
+ mock.call('mount', '/dev/fake2', self.fake_dir),
mock.call(('chroot %s /bin/sh -c "mount -a -t vfat"' %
(self.fake_dir)), shell=True,
env_variables={
@@ -760,7 +762,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.assertFalse(mock_dispatch.called)
@mock.patch.object(image, '_efi_boot_setup', lambda *_: False)
- @mock.patch.object(os.path, 'ismount', lambda *_: True)
+ @mock.patch.object(os.path, 'ismount', lambda *_: False)
@mock.patch.object(image, '_is_bootloader_loaded', lambda *_: True)
@mock.patch.object(os.path, 'exists', autospec=True)
@mock.patch.object(hardware, 'is_md_device', autospec=True)
@@ -815,6 +817,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
'GRUB_SAVEDEFAULT': 'true'},
use_standard_locale=True),
mock.call('umount', self.fake_dir + '/boot/efi'),
+ mock.call('mount', '/dev/fake2', self.fake_dir),
# NOTE(TheJulia): chroot mount is for whole disk images
mock.call(('chroot %s /bin/sh -c "mount -a -t vfat"' %
(self.fake_dir)), shell=True,
@@ -1037,7 +1040,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
uuid=self.fake_efi_system_part_uuid)
self.assertFalse(mock_dispatch.called)
- @mock.patch.object(os.path, 'ismount', lambda *_: True)
+ @mock.patch.object(os.path, 'ismount', lambda *_: False)
@mock.patch.object(image, '_is_bootloader_loaded', lambda *_: False)
@mock.patch.object(image, '_append_uefi_to_fstab', autospec=True)
@mock.patch.object(image, '_preserve_efi_assets', autospec=True)
@@ -1089,6 +1092,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
'GRUB_DISABLE_OS_PROBER': 'true',
'GRUB_SAVEDEFAULT': 'true'},
use_standard_locale=True),
+ mock.call('mount', '/dev/fake2', self.fake_dir),
mock.call(('chroot %s /bin/sh -c "mount -a -t vfat"' %
(self.fake_dir)), shell=True,
env_variables={
@@ -1239,7 +1243,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.assertFalse(mock_dispatch.called)
self.assertEqual(2, mock_oslistdir.call_count)
- @mock.patch.object(os.path, 'ismount', lambda *_: True)
+ @mock.patch.object(os.path, 'ismount', lambda *_: False)
@mock.patch.object(image, '_is_bootloader_loaded', lambda *_: False)
@mock.patch.object(os, 'listdir', autospec=True)
@mock.patch.object(image, '_append_uefi_to_fstab', autospec=True)
@@ -1284,7 +1288,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
mock.call('mount', '-t', 'vfat', '/dev/fake1',
self.fake_dir + '/boot/efi'),
mock.call('umount', self.fake_dir + '/boot/efi'),
-
+ mock.call('mount', '/dev/fake2', self.fake_dir),
mock.call(('chroot %s /bin/sh -c "mount -a -t vfat"' %
(self.fake_dir)), shell=True,
env_variables={