diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-10-10 17:29:29 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-10-10 17:29:29 +0000 |
| commit | 825c8065089236d0cc43ea06789afe320884cb7f (patch) | |
| tree | cc3ce700a8c3c954619800555b9a9e90ebe0e3f2 /nova | |
| parent | 9125dfe007aaaad9a3f276ebcde8c451c0193c25 (diff) | |
| parent | 477549488ee8e2bf3bfa545ddb2bffe8b7be33bc (diff) | |
Merge "Add util for image conversion"
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": |
