From: Flaper Fesp Date: Tue, 3 Sep 2013 16:26:42 +0000 (+0200) Subject: Set vg_thin_pool to pool name instead of pool_path X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=29e889bde9364f30c3f1cbeb7ee835b036451cba;p=openstack-build%2Fcinder-build.git Set vg_thin_pool to pool name instead of pool_path create_thin_pool is setting vg_thin_pool to the pool path instead of the pool_name. This makes volumes creation fail when the create_thin_pool method is called. This happens because create_volume builds the pool path itself as create_thin_pool does. Keeping the pool name in vg_thin_pool instead of the path makes more sense and allows it to be used in other places in the brick. Also, most commands return both vg_name and pool_name separated. Change-Id: Ibf5cd746fc050eab5ce6aff13dd70c1e8066b228 Closes-Bug: #1220286 --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 5f4050029..b0d4a4d07 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -337,7 +337,7 @@ class LVM(executor.Executor): self._execute(*cmd, root_helper=self._root_helper, run_as_root=True) - self.vg_thin_pool = pool_path + self.vg_thin_pool = name def create_volume(self, name, size_str, lv_type='default', mirror_count=0): """Creates a logical volume on the object's VG. diff --git a/cinder/tests/brick/test_brick_lvm.py b/cinder/tests/brick/test_brick_lvm.py index 264be4859..76d18d8d2 100644 --- a/cinder/tests/brick/test_brick_lvm.py +++ b/cinder/tests/brick/test_brick_lvm.py @@ -144,6 +144,25 @@ class BrickLvmTestCase(test.TestCase): self.stubs.Set(processutils, 'execute', self.fake_old_lvm_version) self.assertFalse(self.vg.supports_thin_provisioning('sudo')) + def test_volume_create_after_thin_creation(self): + """Test self.vg.vg_thin_pool is set to pool_name + + See bug #1220286 for more info. + """ + + vg_name = "vg-name" + pool_name = vg_name + "-pool" + pool_path = "%s/%s" % (vg_name, pool_name) + + def executor(obj, *cmd, **kwargs): + self.assertEqual(pool_path, cmd[-1]) + + self.vg._executor = executor + self.vg.create_thin_pool(pool_name, "1G") + self.vg.create_volume("test", "1G", lv_type='thin') + + self.assertEqual(self.vg.vg_thin_pool, pool_name) + def test_lv_has_snapshot(self): self.assertTrue(self.vg.lv_has_snapshot('fake-volumes')) self.assertFalse(self.vg.lv_has_snapshot('test-volumes'))