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
(cherry picked from commit 69ce114232)

Conflicts:
	cinder/volume/drivers/lvm.py

Change-Id: I75cf91171709554053fd5b52a4aae4e176e8364e
This commit is contained in:
Flavio Percoco 2013-12-05 13:48:24 +01:00
parent 430f0b9dbe
commit f39441662d
2 changed files with 19 additions and 6 deletions

View File

@ -2133,17 +2133,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)

View File

@ -713,7 +713,9 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
return false_ret
helper = 'sudo cinder-rootwrap %s' % CONF.rootwrap_config
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']),