]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
LVM migrate: Use keywords for the brick instance
authorFlavio Percoco <flaper87@gmail.com>
Thu, 5 Dec 2013 12:48:24 +0000 (13:48 +0100)
committerFlavio Percoco <flaper87@gmail.com>
Thu, 5 Dec 2013 22:26:08 +0000 (23:26 +0100)
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
cinder/volume/drivers/lvm.py

index 06721dc1d3444342e97f093aefe864eae52b2a8d..43aa3c52eceea0bf263ce0491f0dd3bc8c4c9d46 100644 (file)
@@ -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)
 
index 29fc556fca56cf320b894c7d1f1d31b1fa316246..187d052151a793be12563f4fc311574085e9a3a9 100644 (file)
@@ -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']),