Skip to content

Commit

Permalink
Pass the size when fetching image in xenapi driver
Browse files Browse the repository at this point in the history
In commit 6e287c0 the fetch_to_raw
method was changed to accept the volume size so it can fail when the
image doesn't fit in the destination volume. In this commit we also
updated all the volume drivers to pass the volume size to that method so
it could perform the check. The xenapi driver missed that change.

This commit updates the xenapi driver to pass the volume size when
fetching the image to enable the introduced check.

Change-Id: I89bc4b3b1c1e6b06f5c529166cf9ffa1fe600c96
Related-Bug: #1235358
(cherry picked from commit c4db75a)
  • Loading branch information
Xavier Queralt committed Nov 27, 2013
1 parent c5cb131 commit 704b72c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cinder/tests/test_xenapi_sm.py
Expand Up @@ -392,7 +392,7 @@ def test_use_image_utils_to_pipe_bytes_to_volume(self):
mock, drv = self._setup_mock_driver(
'server', 'serverpath', '/var/run/sr-mount')

volume = dict(provider_location='sr-uuid/vdi-uuid')
volume = dict(provider_location='sr-uuid/vdi-uuid', size=1)
context = MockContext('token')

mock.StubOutWithMock(driver.image_utils, 'fetch_to_raw')
Expand All @@ -402,7 +402,7 @@ def test_use_image_utils_to_pipe_bytes_to_volume(self):
simple_context('device'))

driver.image_utils.fetch_to_raw(
context, 'image_service', 'image_id', 'device')
context, 'image_service', 'image_id', 'device', size=1)

mock.ReplayAll()
drv._use_image_utils_to_pipe_bytes_to_volume(
Expand Down
3 changes: 2 additions & 1 deletion cinder/volume/drivers/xenapi/sm.py
Expand Up @@ -175,7 +175,8 @@ def _use_image_utils_to_pipe_bytes_to_volume(self, context, volume,
image_utils.fetch_to_raw(context,
image_service,
image_id,
device)
device,
size=volume['size'])

def _use_glance_plugin_to_copy_image_to_volume(self, context, volume,
image_service, image_id):
Expand Down

0 comments on commit 704b72c

Please sign in to comment.