From: Bill Owen Date: Mon, 22 Jul 2013 00:35:50 +0000 (-0700) Subject: GPFS convert glance image to raw only when needed X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=84ca4b3698ae8512f6ba4cd72a57f662e35b59a0;p=openstack-build%2Fcinder-build.git GPFS convert glance image to raw only when needed Modify _gpfs_fetch_to_raw to check image format. If already in raw format, no need to call convert_image. In that case, simply rename to destination name. Change-Id: I197d99194f93c02ce3c501de25433d89b23e6a35 Fixes: bug #1201676 --- diff --git a/cinder/volume/drivers/gpfs.py b/cinder/volume/drivers/gpfs.py index 901924c7e..e463ca5ea 100644 --- a/cinder/volume/drivers/gpfs.py +++ b/cinder/volume/drivers/gpfs.py @@ -448,14 +448,8 @@ class GPFSDriver(driver.VolumeDriver): 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}) @@ -464,16 +458,25 @@ class GPFSDriver(driver.VolumeDriver): 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)}