diff options
| author | Boris Filippov <bfilippov@griddynamics.com> | 2012-09-26 04:45:07 +0400 |
|---|---|---|
| committer | Boris Filippov <bfilippov@griddynamics.com> | 2012-10-10 19:27:07 +0400 |
| commit | 477549488ee8e2bf3bfa545ddb2bffe8b7be33bc (patch) | |
| tree | 2b74e2f717034d9b8a5e8ccb04801d3555fd1fa1 /nova | |
| parent | 800c08dfe36de52429364f96d708fb3bba0c4e3b (diff) | |
| download | nova-477549488ee8e2bf3bfa545ddb2bffe8b7be33bc.tar.gz nova-477549488ee8e2bf3bfa545ddb2bffe8b7be33bc.tar.xz nova-477549488ee8e2bf3bfa545ddb2bffe8b7be33bc.zip | |
Add util for image conversion
blueprint snapshots-for-everyone
Add nova.virt.images.convert_image(source, dest, format)
that converts image to other format using qemu-img convert
Change-Id: I2c92cb31114c42717d0ddd011645dc7c661c82c6
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/virt/images.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py index 9f53af645..d94a1aeba 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -60,6 +60,12 @@ def qemu_img_info(path): return data +def convert_image(source, dest, out_format): + """Convert image to other format""" + cmd = ('qemu-img', 'convert', '-O', out_format, source, dest) + utils.execute(*cmd) + + def fetch(context, image_href, path, _user_id, _project_id): # TODO(vish): Improve context handling and add owner and auth data # when it is added to glance. Right now there is no @@ -94,8 +100,7 @@ def fetch_to_raw(context, image_href, path, user_id, project_id): staged = "%s.converted" % path LOG.debug("%s was %s, converting to raw" % (image_href, fmt)) with utils.remove_path_on_error(staged): - utils.execute('qemu-img', 'convert', '-O', 'raw', path_tmp, - staged) + convert_image(path_tmp, staged, 'raw') data = qemu_img_info(staged) if data.get('file format') != "raw": |
