Make floppy images more floppy

Some vendors insist that floppy images need to be exactly 1440 KiB in
size and have a suffix of ".img". Let's adapt to this and assume that
this doesn't break other vendors.

Closes-Bug: 2100276
Change-Id: I5be6380e8c8c3eac5bea1c189b205b05a9fae625
(cherry picked from commit 56dbf38ed8f200ff91d58559962d9265dff9ee83)
This commit is contained in:
Dr. Jens Harbott 2025-02-26 13:14:46 +01:00
parent 5aa51d6985
commit bc565cf543
3 changed files with 22 additions and 12 deletions

View File

@ -208,7 +208,7 @@ def prepare_floppy_image(task, params=None):
:raises: SwiftOperationError, if any operation with Swift fails.
:returns: image URL for the floppy image.
"""
object_name = _get_name(task.node, prefix='image')
object_name = _get_name(task.node, prefix='image', suffix='.img')
params = override_api_url(params)
LOG.debug("Trying to create floppy image for node "
@ -218,7 +218,8 @@ def prepare_floppy_image(task, params=None):
dir=CONF.tempdir, suffix='.img') as vfat_image_tmpfile_obj:
vfat_image_tmpfile = vfat_image_tmpfile_obj.name
images.create_vfat_image(vfat_image_tmpfile, parameters=params)
images.create_vfat_image(vfat_image_tmpfile, fs_size_kib=1440,
parameters=params)
img_handler = ImageHandler(task.node.driver)
node_http_url = task.node.driver_info.get("external_http_url")
@ -239,7 +240,8 @@ def cleanup_floppy_image(task):
:param task: an ironic node object.
"""
ImageHandler.unpublish_image_for_node(task.node, prefix='image')
ImageHandler.unpublish_image_for_node(task.node, prefix='image',
suffix='.img')
def prepare_configdrive_image(task, content):

View File

@ -122,7 +122,7 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
shared=True) as task:
image_utils.cleanup_floppy_image(task)
object_name = 'image-%s' % task.node.uuid
object_name = 'image-%s.img' % task.node.uuid
mock_unpublish.assert_called_once_with(mock.ANY, object_name)
@ -139,13 +139,13 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
url = image_utils.prepare_floppy_image(task)
object_name = 'image-%s' % task.node.uuid
object_name = 'image-%s.img' % task.node.uuid
mock_publish_image.assert_called_once_with(mock.ANY, mock.ANY,
object_name, None)
mock_create_vfat_image.assert_called_once_with(
mock.ANY, parameters=None)
mock.ANY, fs_size_kib=1440, parameters=None)
self.assertEqual(expected_url, url)
@ -163,13 +163,14 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
url = image_utils.prepare_floppy_image(task)
object_name = 'image-%s' % task.node.uuid
object_name = 'image-%s.img' % task.node.uuid
mock_publish_image.assert_called_once_with(mock.ANY, mock.ANY,
object_name, None)
mock_create_vfat_image.assert_called_once_with(
mock.ANY, parameters={"ipa-api-url": "http://callback"})
mock.ANY, fs_size_kib=1440,
parameters={"ipa-api-url": "http://callback"})
self.assertEqual(expected_url, url)
@ -189,13 +190,14 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
url = image_utils.prepare_floppy_image(task)
object_name = 'image-%s' % task.node.uuid
object_name = 'image-%s.img' % task.node.uuid
mock_publish_image.assert_called_once_with(mock.ANY, mock.ANY,
object_name, None)
mock_create_vfat_image.assert_called_once_with(
mock.ANY, parameters={"ipa-api-url": "http://callback"})
mock.ANY, fs_size_kib=1440,
parameters={"ipa-api-url": "http://callback"})
self.assertEqual(expected_url, url)
@ -218,13 +220,14 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
url = image_utils.prepare_floppy_image(task)
object_name = 'image-%s' % task.node.uuid
object_name = 'image-%s.img' % task.node.uuid
mock_publish_image.assert_called_once_with(
mock.ANY, mock.ANY, object_name, override_url)
mock_create_vfat_image.assert_called_once_with(
mock.ANY, parameters={"ipa-api-url": "http://callback"})
mock.ANY, fs_size_kib=1440,
parameters={"ipa-api-url": "http://callback"})
self.assertEqual(expected_url, url)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Some vendors insist that floppy images must be 1440 KiB in size and
that the file name ends with ``.img``. Make it so.