Set imageext for IPA ramdisk

Without this, the existing image logic looks for a file named
ironic-python-agent.qcow2, which will never exist since IPA is a
ramdisk.  Note that there is no initrd type in dib, so we have to
leave that as qcow2 even though it's wrong.  I left a comment in
the yaml explaining why.

Additionally, this required some modification of the logic around
the image name.  For the purposes of checking existence, we need
the extension.  For the diskimage-builder call, we do not.  DIB
strips off any extension that matches the image type anyway, but
this does not work properly if we pass a type of qcow2 with an
extension of initramfs, so we end up with a file named
ironic-python-agent.initramfs.initramfs.

Change-Id: Ic5757c1f363979a6c52830bfa6c42c2b57740fd5
Closes-Bug: 1654002
This commit is contained in:
Ben Nemec 2017-01-04 15:31:32 +00:00
parent 6219e3d8ac
commit 4ec2e0d33b
3 changed files with 6 additions and 4 deletions

View File

@ -35,7 +35,10 @@ disk_images:
-
imagename: ironic-python-agent
arch: amd64
# This is bogus, but there's no initrd type in diskimage-builder
type: qcow2
# So we just override the extension instead
imageext: initramfs
elements:
- ironic-agent
- dynamic-login

View File

@ -60,11 +60,10 @@ class ImageBuildManager(BaseImageManager):
raise ImageSpecificationException('distro is required')
self.logger.info('imagename: %s' % image_name)
image_extension = image.get('imageext', image_type)
image_path = '%s/%s.%s' % (
self.output_directory, image_name, image_extension)
image_path = os.path.join(self.output_directory, image_name)
if self.skip:
self.logger.info('looking for image at path: %s' % image_path)
if os.path.exists(image_path):
if os.path.exists('%s.%s' % (image_path, image_extension)):
self.logger.info('Image file exists for image name: %s' %
image_name)
self.logger.info('Skipping image build')

View File

@ -42,7 +42,7 @@ class TestImageBuildManager(base.TestCase):
self.assertEqual(1, mock_load_config_files.call_count)
mock_builder.build_image.assert_called_with(
'./overcloud.qcow2', 'qcow2', 'some_awesome_os', 'amd64',
'./overcloud', 'qcow2', 'some_awesome_os', 'amd64',
['image_element'], [], [],
{'skip_base': False, 'docker_target': None, 'environment': {}})