From 7e43a8891018d52bd69298f11b684841b00e2523 Mon Sep 17 00:00:00 2001 From: Yaguang Tang Date: Mon, 23 Jun 2014 11:59:44 +0800 Subject: [PATCH] Fix host option isn't set when using multiple backend 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 | 8 ++++---- cinder/volume/drivers/block_device.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cinder/tests/test_block_device.py b/cinder/tests/test_block_device.py index 7def672fd..077ece39d 100644 --- a/cinder/tests/test_block_device.py +++ b/cinder/tests/test_block_device.py @@ -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') diff --git a/cinder/volume/drivers/block_device.py b/cinder/volume/drivers/block_device.py index 15da879e7..89a22b859 100644 --- a/cinder/volume/drivers/block_device.py +++ b/cinder/volume/drivers/block_device.py @@ -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) -- 2.45.2