Skip to content

Commit

Permalink
Merge "GPFS convert glance image to raw only when needed"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jul 24, 2013
2 parents b06a90b + 84ca4b3 commit 601fce7
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cinder/volume/drivers/gpfs.py
Expand Up @@ -448,14 +448,8 @@ def _gpfs_fetch_to_raw(self, context, image_service, image_id, dest,

data = image_utils.qemu_img_info(tmp)
fmt = data.file_format
if fmt is None:
msg = _("'qemu-img info' parsing failed.")
LOG.error(msg)
raise exception.ImageUnacceptable(
reason=msg,
image_id=image_id)

backing_file = data.backing_file

if backing_file is not None:
msg = (_("fmt = %(fmt)s backed by: %(backing_file)s") %
{'fmt': fmt, 'backing_file': backing_file})
Expand All @@ -464,16 +458,25 @@ def _gpfs_fetch_to_raw(self, context, image_service, image_id, dest,
image_id=image_id,
reason=msg)

LOG.debug("%s was %s, converting to raw" % (image_id, fmt))
image_utils.convert_image(tmp, dest, 'raw')
if fmt is None:
msg = _("'qemu-img info' parsing failed.")
LOG.error(msg)
raise exception.ImageUnacceptable(
reason=msg,
image_id=image_id)
elif fmt == 'raw': # already in raw format - just rename to dest
self._execute('mv', tmp, dest, run_as_root=True)
else: # conversion to raw format required
LOG.debug("%s was %s, converting to raw" % (image_id, fmt))
image_utils.convert_image(tmp, dest, 'raw')
os.unlink(tmp)

data = image_utils.qemu_img_info(dest)
if data.file_format != "raw":
msg = (_("Converted to raw, but format is now %s") %
msg = (_("Expected image to be in raw format, but is %s") %
data.file_format)
LOG.error(msg)
raise exception.ImageUnacceptable(
image_id=image_id,
reason=msg)
os.unlink(tmp)
return {'size': math.ceil(data.virtual_size / 1024.0 ** 3)}

0 comments on commit 601fce7

Please sign in to comment.