Skip to content

Commit

Permalink
LVM migrate: Use keywords for the brick instance
Browse files Browse the repository at this point in the history
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
  • Loading branch information
flaper87 committed Dec 5, 2013
1 parent e99cd78 commit 69ce114
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 16 additions & 5 deletions cinder/tests/test_volume.py
Expand Up @@ -2191,17 +2191,28 @@ def test_lvm_migrate_volume_in_use(self):
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)

Expand Down
4 changes: 3 additions & 1 deletion cinder/volume/drivers/lvm.py
Expand Up @@ -708,7 +708,9 @@ def migrate_volume(self, ctxt, volume, host, thin=False, mirror_count=0):
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']),
Expand Down

0 comments on commit 69ce114

Please sign in to comment.