Fetch_to_volume_format calls copy_volume using wrong parameter
When creating a volume from an image, if qemu-img is not installed, fetch_to_volume_format will call volume_utils.copy_volume to copy image to volume. Copy_volume need the size of image in megabyte, but fetch_to_volume_format call it using size in bytes. Change-Id: Ia3b0f9168235a977a12232e27a5755ad11ec18f5 Closes-Bug: #1414867
This commit is contained in:
parent
a36100bd34
commit
549144f754
@ -25,6 +25,7 @@ we should look at maybe pushing this up to Oslo
|
||||
|
||||
|
||||
import contextlib
|
||||
import math
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
@ -238,7 +239,8 @@ def fetch_to_volume_format(context, image_service,
|
||||
LOG.debug('Copying image from %(tmp)s to volume %(dest)s - '
|
||||
'size: %(size)s' % {'tmp': tmp, 'dest': dest,
|
||||
'size': image_meta['size']})
|
||||
volume_utils.copy_volume(tmp, dest, image_meta['size'], blocksize)
|
||||
image_size_m = math.ceil(image_meta['size'] / units.Mi)
|
||||
volume_utils.copy_volume(tmp, dest, image_size_m, blocksize)
|
||||
return
|
||||
|
||||
data = qemu_img_info(tmp, run_as_root=run_as_root)
|
||||
|
@ -15,8 +15,11 @@
|
||||
# under the License.
|
||||
"""Unit tests for image utils."""
|
||||
|
||||
import math
|
||||
|
||||
import mock
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_utils import units
|
||||
|
||||
from cinder import exception
|
||||
from cinder.image import image_utils
|
||||
@ -648,7 +651,8 @@ class TestFetchToVolumeFormat(test.TestCase):
|
||||
mock_conf.volume_copy_bps_limit = bps_limit
|
||||
tmp = mock_temp.return_value.__enter__.return_value
|
||||
image_service.show.return_value = {'disk_format': 'raw',
|
||||
'size': mock.sentinel.image_size}
|
||||
'size': 41126400}
|
||||
image_size_m = math.ceil(41126400 / units.Mi)
|
||||
|
||||
output = image_utils.fetch_to_volume_format(
|
||||
ctxt, image_service, image_id, dest, volume_format, blocksize,
|
||||
@ -662,7 +666,7 @@ class TestFetchToVolumeFormat(test.TestCase):
|
||||
mock_fetch.assert_called_once_with(ctxt, image_service, image_id,
|
||||
tmp, user_id, project_id)
|
||||
self.assertFalse(mock_repl_xen.called)
|
||||
mock_copy.assert_called_once_with(tmp, dest, mock.sentinel.image_size,
|
||||
mock_copy.assert_called_once_with(tmp, dest, image_size_m,
|
||||
blocksize)
|
||||
self.assertFalse(mock_convert.called)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user