]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Pass the size when fetching image in xenapi driver
authorXavier Queralt <xqueralt@redhat.com>
Fri, 22 Nov 2013 09:39:37 +0000 (10:39 +0100)
committerXavier Queralt <xqueralt@redhat.com>
Fri, 22 Nov 2013 09:39:37 +0000 (10:39 +0100)
In commit 6e287c0f2bb7d4994d50f1763f412277e4dac6f7 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

cinder/tests/test_xenapi_sm.py
cinder/volume/drivers/xenapi/sm.py

index d619d257066164ffe8061309ef6d6a3ea1a043ad..ed01dbaa685ea95284100fd96bdf264cced7d530 100644 (file)
@@ -392,7 +392,7 @@ class DriverTestCase(test.TestCase):
         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')
@@ -402,7 +402,7 @@ class DriverTestCase(test.TestCase):
                 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(
index c2f53777d92a2415d10a3ac6f89d29817759f2cc..f19d48054c9f7f7b1fc06ea7c50aa8217ea13ca0 100644 (file)
@@ -175,7 +175,8 @@ class XenAPINFSDriver(driver.VolumeDriver):
             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):