diff --git a/ironic/common/images.py b/ironic/common/images.py index b80a47a341..4273d25e29 100644 --- a/ironic/common/images.py +++ b/ironic/common/images.py @@ -222,12 +222,12 @@ def create_isolinux_image_for_bios(output_file, kernel, ramdisk, raise exception.ImageCreationFailed(image_type='iso', error=e) -def create_isolinux_image_for_uefi(output_file, kernel, ramdisk, - deploy_iso=None, esp_image=None, - kernel_params=None): - """Creates an isolinux image on the specified file. +def create_esp_image_for_uefi(output_file, kernel, ramdisk, + deploy_iso=None, esp_image=None, + kernel_params=None): + """Creates an ESP image on the specified file. - Copies the provided kernel, ramdisk and EFI system partition image to + Copies the provided kernel, ramdisk and EFI system partition image (ESP) to a directory, generates the grub configuration file using kernel parameters and then generates a bootable ISO image for UEFI. @@ -317,6 +317,10 @@ def create_isolinux_image_for_uefi(output_file, kernel, ramdisk, raise exception.ImageCreationFailed(image_type='iso', error=e) +# NOTE(etingof): backward compatibility +create_isolinux_image_for_uefi = create_esp_image_for_uefi + + def fetch(context, image_href, path, force_raw=False): # TODO(vish): Improve context handling and add owner and auth data # when it is added to glance. Right now there is no @@ -489,12 +493,12 @@ def create_boot_iso(context, output_filename, kernel_href, elif CONF.esp_image: esp_image_path = CONF.esp_image - create_isolinux_image_for_uefi(output_filename, - kernel_path, - ramdisk_path, - deploy_iso=deploy_iso_path, - esp_image=esp_image_path, - kernel_params=params) + create_esp_image_for_uefi(output_filename, + kernel_path, + ramdisk_path, + deploy_iso=deploy_iso_path, + esp_image=esp_image_path, + kernel_params=params) else: create_isolinux_image_for_bios(output_filename, kernel_path, diff --git a/ironic/tests/unit/common/test_images.py b/ironic/tests/unit/common/test_images.py index 78514d1ea4..ddfd5b1501 100644 --- a/ironic/tests/unit/common/test_images.py +++ b/ironic/tests/unit/common/test_images.py @@ -485,7 +485,7 @@ class FsImageTestCase(base.TestCase): @mock.patch.object(images, '_mount_deploy_iso', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(images, '_generate_cfg', autospec=True) - def test_create_isolinux_image_for_uefi_with_deploy_iso( + def test_create_esp_image_for_uefi_with_deploy_iso( self, gen_cfg_mock, tempdir_mock, mount_mock, execute_mock, write_to_file_mock, create_root_fs_mock, umount_mock): @@ -517,11 +517,11 @@ class FsImageTestCase(base.TestCase): mount_mock.return_value = (uefi_path_info, e_img_rel_path, grub_rel_path) - images.create_isolinux_image_for_uefi('tgt_file', - 'path/to/kernel', - 'path/to/ramdisk', - deploy_iso='path/to/deploy_iso', - kernel_params=params) + images.create_esp_image_for_uefi('tgt_file', + 'path/to/kernel', + 'path/to/ramdisk', + deploy_iso='path/to/deploy_iso', + kernel_params=params) mount_mock.assert_called_once_with('path/to/deploy_iso', 'mountdir') create_root_fs_mock.assert_called_once_with('tmpdir', files_info) gen_cfg_mock.assert_any_call(params, CONF.grub_config_template, @@ -537,7 +537,7 @@ class FsImageTestCase(base.TestCase): @mock.patch.object(utils, 'execute', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(images, '_generate_cfg', autospec=True) - def test_create_isolinux_image_for_uefi_with_esp_image( + def test_create_esp_image_for_uefi_with_esp_image( self, gen_cfg_mock, tempdir_mock, execute_mock, create_root_fs_mock, write_to_file_mock): @@ -564,7 +564,7 @@ class FsImageTestCase(base.TestCase): tempdir_mock.side_effect = mock_file_handle, mock_file_handle1 mountdir_grub_cfg_path = 'tmpdir' + grub_cfg_file - images.create_isolinux_image_for_uefi( + images.create_esp_image_for_uefi( 'tgt_file', 'path/to/kernel', 'path/to/ramdisk', esp_image='sourceabspath/to/efiboot.img', kernel_params=params) @@ -643,11 +643,9 @@ class FsImageTestCase(base.TestCase): @mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'execute', autospec=True) @mock.patch.object(os, 'walk', autospec=True) - def test_create_isolinux_image_uefi_rootfs_fails(self, walk_mock, - utils_mock, - tempdir_mock, - create_root_fs_mock, - umount_mock): + def test_create_esp_image_uefi_rootfs_fails( + self, walk_mock, utils_mock, tempdir_mock, + create_root_fs_mock, umount_mock): mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle.__enter__.return_value = 'tmpdir' @@ -657,7 +655,7 @@ class FsImageTestCase(base.TestCase): create_root_fs_mock.side_effect = IOError self.assertRaises(exception.ImageCreationFailed, - images.create_isolinux_image_for_uefi, + images.create_esp_image_for_uefi, 'tgt_file', 'path/to/kernel', 'path/to/ramdisk', @@ -686,14 +684,9 @@ class FsImageTestCase(base.TestCase): @mock.patch.object(utils, 'execute', autospec=True) @mock.patch.object(images, '_mount_deploy_iso', autospec=True) @mock.patch.object(images, '_generate_cfg', autospec=True) - def test_create_isolinux_image_mkisofs_fails(self, - gen_cfg_mock, - mount_mock, - utils_mock, - tempdir_mock, - write_to_file_mock, - create_root_fs_mock, - umount_mock): + def test_create_esp_image_mkisofs_fails( + self, gen_cfg_mock, mount_mock, utils_mock, tempdir_mock, + write_to_file_mock, create_root_fs_mock, umount_mock): mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle1 = mock.MagicMock(spec=io.BytesIO) @@ -703,7 +696,7 @@ class FsImageTestCase(base.TestCase): utils_mock.side_effect = processutils.ProcessExecutionError self.assertRaises(exception.ImageCreationFailed, - images.create_isolinux_image_for_uefi, + images.create_esp_image_for_uefi, 'tgt_file', 'path/to/kernel', 'path/to/ramdisk', @@ -731,7 +724,7 @@ class FsImageTestCase(base.TestCase): 'tgt_file', 'path/to/kernel', 'path/to/ramdisk') - @mock.patch.object(images, 'create_isolinux_image_for_uefi', autospec=True) + @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True) def test_create_boot_iso_for_uefi_deploy_iso( @@ -759,7 +752,7 @@ class FsImageTestCase(base.TestCase): deploy_iso='tmpdir/deploy_iso-uuid', esp_image=None, kernel_params=params) - @mock.patch.object(images, 'create_isolinux_image_for_uefi', autospec=True) + @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True) def test_create_boot_iso_for_uefi_esp_image( @@ -787,7 +780,7 @@ class FsImageTestCase(base.TestCase): deploy_iso=None, esp_image='tmpdir/efiboot-uuid', kernel_params=params) - @mock.patch.object(images, 'create_isolinux_image_for_uefi', autospec=True) + @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True) def test_create_boot_iso_for_uefi_deploy_iso_for_hrefs( @@ -815,7 +808,7 @@ class FsImageTestCase(base.TestCase): deploy_iso='tmpdir/deploy_iso-href', esp_image=None, kernel_params=params) - @mock.patch.object(images, 'create_isolinux_image_for_uefi', autospec=True) + @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True) def test_create_boot_iso_for_uefi_esp_image_for_hrefs( diff --git a/releasenotes/notes/rename-iso-builder-func-46694ed6ded84f4a.yaml b/releasenotes/notes/rename-iso-builder-func-46694ed6ded84f4a.yaml new file mode 100644 index 0000000000..8bc40b621f --- /dev/null +++ b/releasenotes/notes/rename-iso-builder-func-46694ed6ded84f4a.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Renames misleadingly named `images.create_isolinux_image_for_uefi` + function into `images.create_esp_image_for_uefi`. The new name + reflects what's actually going on under the hood.