summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ironic_python_agent/extensions/image.py1
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_image.py48
2 files changed, 46 insertions, 3 deletions
diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py
index de880f84..46be48c2 100644
--- a/ironic_python_agent/extensions/image.py
+++ b/ironic_python_agent/extensions/image.py
@@ -425,6 +425,7 @@ def _mount_for_chroot(path):
LOG.debug('Mounting Linux standard partitions for bootloader '
'configuration generation')
for fs in BIND_MOUNTS:
+ utils.execute('mkdir', '-p', path + fs)
utils.execute('mount', '-o', 'bind', fs, path + fs)
utils.execute('mount', '-t', 'sysfs', 'none', path + '/sys')
diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py
index e488b74f..6958036f 100644
--- a/ironic_python_agent/tests/unit/extensions/test_image.py
+++ b/ironic_python_agent/tests/unit/extensions/test_image.py
@@ -538,10 +538,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
image._install_grub2(self.fake_dev, self.fake_root_uuid)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -601,10 +604,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
prep_boot_part_uuid=self.fake_prep_boot_part_uuid)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -674,10 +680,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
target_boot_mode='uefi')
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -775,10 +784,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
mock_open.assert_has_calls(write_calls)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -883,10 +895,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
mock_open.assert_has_calls(write_calls)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1001,10 +1016,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dir + '/boot/efi/EFI')])
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1087,10 +1105,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dir + '/boot/efi/EFI')])
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1168,10 +1189,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.assertFalse(mock_efi_setup.called)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1289,10 +1313,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.assertFalse(mock_efi_setup.called)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1414,10 +1441,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dir + '/boot/efi/EFI')])
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1494,10 +1524,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
target_boot_mode='uefi')
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1591,10 +1624,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
efi_system_part_uuid=self.fake_efi_system_part_uuid)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1705,7 +1741,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
mock_execute, mock_dispatch):
# return success for every execute call
- mock_execute.side_effect = [('', '')] * 21
+ mock_execute.side_effect = [('', '')] * 24
# make grub2-install calls fail
grub_failure = processutils.ProcessExecutionError(
@@ -1716,8 +1752,8 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
exit_code=1,
cmd='grub2-install'
)
- mock_execute.side_effect[9] = grub_failure
- mock_execute.side_effect[10] = grub_failure
+ mock_execute.side_effect[12] = grub_failure
+ mock_execute.side_effect[13] = grub_failure
mock_get_part_uuid.side_effect = [self.fake_root_part,
self.fake_efi_system_part]
@@ -1734,10 +1770,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1835,10 +1874,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
expected = [
mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',