'Copy the volume to the specified image.'

def copy_volume_to_image(self, context, volume, image_service, image_meta):

    disk_format = self._tgt_utils.get_supported_disk_format()
    temp_vhd_path = os.path.join(CONF.image_conversion_dir, ((str(image_meta['id']) + '.') + disk_format))
    try:
        with self._temporary_snapshot(volume.name) as tmp_snap_name:
            self._tgt_utils.export_snapshot(tmp_snap_name, temp_vhd_path)
            image_utils.upload_volume(context, image_service, image_meta, temp_vhd_path, 'vhd')
    finally:
        fileutils.delete_if_exists(temp_vhd_path)
