]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix host option isn't set when using multiple backend
authorYaguang Tang <yaguang.tang@canonical.com>
Mon, 23 Jun 2014 03:59:44 +0000 (11:59 +0800)
committerYaguang Tang <yaguang.tang@canonical.com>
Wed, 2 Jul 2014 10:28:29 +0000 (10:28 +0000)
When using multiple volume backend, and volume driver is
cinder.volume.drivers.block_device.BlockDeviceDriver, host
option isn't set so a call to get volumes of a host returns none,
This patch changes to use self.host instead of self.configuration.host

Change-Id: Ide34ed29adad14b778b1a7388e9dc313241fa243
Closes-Bug: 1332909

cinder/tests/test_block_device.py
cinder/volume/drivers/block_device.py

index 7def672fdc6fe856c1bb6e26993cdef106d3e79a..077ece39dd38b3c7af7fa593036f699e4d3911e6 100644 (file)
@@ -32,9 +32,10 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
         super(TestBlockDeviceDriver, self).setUp()
         self.configuration = mox.MockAnything()
         self.configuration.available_devices = ['/dev/loop1', '/dev/loop2']
-        self.configuration.host = 'localhost'
+        self.host = 'localhost'
         self.configuration.iscsi_port = 3260
-        self.drv = BlockDeviceDriver(configuration=self.configuration)
+        self.drv = BlockDeviceDriver(configuration=self.configuration,
+                                     host='localhost')
 
     def test_initialize_connection(self):
         TEST_VOLUME1 = {'host': 'localhost1',
@@ -181,8 +182,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
         self.mox.StubOutWithMock(api, 'volume_get_all_by_host')
         self.mox.StubOutWithMock(context, 'get_admin_context')
         context.get_admin_context()
-        api.volume_get_all_by_host(None,
-                                   self.configuration.host) \
+        api.volume_get_all_by_host(None, self.host) \
             .AndReturn([TEST_VOLUME1, TEST_VOLUME2])
         self.mox.StubOutWithMock(self.drv, 'local_path')
         path1 = self.drv.local_path(TEST_VOLUME1).AndReturn('/dev/loop1')
index 15da879e7c4d07d73957c82a1f8fc6772773089a..89a22b85933c8597b02a83f2f2f02b0aa5683dee 100644 (file)
@@ -180,7 +180,7 @@ class BlockDeviceDriver(driver.ISCSIDriver):
 
     def _get_used_devices(self):
         lst = api.volume_get_all_by_host(context.get_admin_context(),
-                                         self.configuration.host)
+                                         self.host)
         used_devices = set()
         for volume in lst:
             local_path = self.local_path(volume)