Merge "Make divisible py3 compatible in remotefs driver"

This commit is contained in:
Jenkins 2016-10-18 17:13:18 +00:00 committed by Gerrit Code Review
commit 95b4c4eb7d
2 changed files with 9 additions and 2 deletions

View File

@ -466,3 +466,10 @@ class RemoteFsSnapDriverTestCase(test.TestCase):
mock_copy_volume_from_snapshot.assert_called_once_with(
snap_ref, volume_ref, volume['size'])
self.assertTrue(mock_delete_snapshot.called)
def test_create_regular_file(self):
self._driver._create_regular_file('/path', 1)
self._driver._execute.assert_called_once_with('dd', 'if=/dev/zero',
'of=/path', 'bs=1M',
'count=1024',
run_as_root=True)

View File

@ -332,7 +332,7 @@ class RemoteFSDriver(driver.LocalVD, driver.TransferVD, driver.BaseVD):
"""Creates a regular file of given size in GiB."""
block_size_mb = 1
block_count = size * units.Gi / (block_size_mb * units.Mi)
block_count = size * units.Gi // (block_size_mb * units.Mi)
self._execute('dd', 'if=/dev/zero', 'of=%s' % path,
'bs=%dM' % block_size_mb,
@ -417,7 +417,7 @@ class RemoteFSDriver(driver.LocalVD, driver.TransferVD, driver.BaseVD):
data = image_utils.qemu_img_info(self.local_path(volume),
run_as_root=run_as_root)
virt_size = data.virtual_size / units.Gi
virt_size = data.virtual_size // units.Gi
if virt_size != volume.size:
raise exception.ImageUnacceptable(
image_id=image_id,