From 69ce114232f9102220b45c8242eda3e78872a3e6 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Thu, 5 Dec 2013 13:48:24 +0100 Subject: [PATCH] LVM migrate: Use keywords for the brick instance In the `migrate_volume` method a new instance is created when the dest_vg is not equal to the source vg. This new brick instance is created using positional arguments instead of keywords. However, some of those arguments are passed in the wrong positions. This patch uses keywords for the misplaced arguments. The patch also changes `test_lvm_migrate_volume_proceed` in order to fully test the happy path and catch things like this. Closes-bug: #1258128 Change-Id: I75cf91171709554053fd5b52a4aae4e176e8364e --- cinder/tests/test_volume.py | 21 ++++++++++++++++----- cinder/volume/drivers/lvm.py | 4 +++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 06721dc1d..43aa3c52e 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -2191,17 +2191,28 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): def test_lvm_migrate_volume_proceed(self): hostname = socket.gethostname() capabilities = {'location_info': 'LVMVolumeDriver:%s:' - 'cinder-volumes:default:0' % hostname} + 'cinder-volumes-2:default:0' % hostname} host = {'capabilities': capabilities} vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'} - self.stubs.Set(self.volume.driver, 'remove_export', - lambda x, y: None) - self.stubs.Set(self.volume.driver, '_create_volume', - lambda x, y, z: None) + + def fake_execute(*args, **kwargs): + pass + + def get_all_volume_groups(): + return [{'name': 'cinder-volumes-2'}, + {'name': 'cinder-volumes'}] + + self.stubs.Set(self.volume.driver, '_execute', fake_execute) + self.stubs.Set(volutils, 'copy_volume', lambda x, y, z, sync=False, execute='foo': None) + + self.stubs.Set(volutils, 'get_all_volume_groups', + get_all_volume_groups) + self.stubs.Set(self.volume.driver, '_delete_volume', lambda x: None) + self.stubs.Set(self.volume.driver, '_create_export', lambda x, y, vg='vg': None) diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 29fc556fc..187d05215 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -708,7 +708,9 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver): return false_ret helper = utils.get_root_helper() - dest_vg_ref = lvm.LVM(dest_vg, helper, lvm_type, self._execute) + dest_vg_ref = lvm.LVM(dest_vg, helper, + lvm_type=lvm_type, + executor=self._execute) self.remove_export(ctxt, volume) self._create_volume(volume['name'], self._sizestr(volume['size']), -- 2.45.2