Browse Source

Make the install_bootloader command asynchronous

It does not return anything, so it makes no point for it to be
synchronous. Ironic always calls it with wait=True, so there is
no problem with backward compatibility either.

Change-Id: I44fec2e0cb54486328ce71263613d8592e384870
(cherry picked from commit 7e5fe1121e)
changes/94/734594/1
Dmitry Tantsur 1 month ago
parent
commit
ed3f00f07a
2 changed files with 13 additions and 12 deletions
  1. +1
    -1
      ironic_python_agent/extensions/image.py
  2. +12
    -11
      ironic_python_agent/tests/unit/extensions/test_image.py

+ 1
- 1
ironic_python_agent/extensions/image.py View File

@@ -687,7 +687,7 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None,

class ImageExtension(base.BaseAgentExtension):

@base.sync_command('install_bootloader')
@base.async_command('install_bootloader')
def install_bootloader(self, root_uuid, efi_system_part_uuid=None,
prep_boot_part_uuid=None,
target_boot_mode='bios'):


+ 12
- 11
ironic_python_agent/tests/unit/extensions/test_image.py View File

@@ -54,7 +54,8 @@ class TestImageExtension(base.IronicAgentTest):
mock_dispatch.side_effect = [
self.fake_dev, hardware.BootInfo(current_boot_mode='bios')
]
self.agent_extension.install_bootloader(root_uuid=self.fake_root_uuid)
self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid).join()
mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
self.assertEqual(2, mock_dispatch.call_count)
@@ -79,7 +80,7 @@ class TestImageExtension(base.IronicAgentTest):
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=self.fake_efi_system_part_uuid,
target_boot_mode='uefi'
)
).join()
mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
self.assertEqual(2, mock_dispatch.call_count)
@@ -131,7 +132,7 @@ class TestImageExtension(base.IronicAgentTest):

self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=self.fake_efi_system_part_uuid)
efi_system_part_uuid=self.fake_efi_system_part_uuid).join()

mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
@@ -179,7 +180,7 @@ class TestImageExtension(base.IronicAgentTest):

self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None)
efi_system_part_uuid=None).join()

mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
@@ -234,7 +235,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n

self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None)
efi_system_part_uuid=None).join()

mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
@@ -289,7 +290,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n

self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None)
efi_system_part_uuid=None).join()

mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
@@ -309,7 +310,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None,
prep_boot_part_uuid=self.fake_prep_boot_part_uuid)
prep_boot_part_uuid=self.fake_prep_boot_part_uuid).join()
mock_dispatch.assert_any_call('get_os_install_device')
mock_dispatch.assert_any_call('get_boot_info')
self.assertEqual(2, mock_dispatch.call_count)
@@ -331,10 +332,10 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.fake_dev, hardware.BootInfo(current_boot_mode='uefi')
]
mock_execute.side_effect = FileNotFoundError
self.assertRaises(FileNotFoundError,
self.agent_extension.install_bootloader,
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None)
result = self.agent_extension.install_bootloader(
root_uuid=self.fake_root_uuid,
efi_system_part_uuid=None).join()
self.assertIsNotNone(result.command_error)
expected = [mock.call('efibootmgr', '--version')]
mock_execute.assert_has_calls(expected)



Loading…
Cancel
Save