]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Set vg_thin_pool to pool name instead of pool_path
authorFlaper Fesp <flaper87@gmail.com>
Tue, 3 Sep 2013 16:26:42 +0000 (18:26 +0200)
committerFlaper Fesp <flaper87@gmail.com>
Tue, 3 Sep 2013 16:33:44 +0000 (18:33 +0200)
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

cinder/brick/local_dev/lvm.py
cinder/tests/brick/test_brick_lvm.py

index 5f40500296192bdcd32319124845ff6714edac34..b0d4a4d075a3c19834a0428b94bf37edcd19fcfd 100644 (file)
@@ -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.
index 264be48597c1ecf5b2ac15b7cb9864748cfd71f8..76d18d8d241bbfa2f3958b8be26cce0c2dc0f40a 100644 (file)
@@ -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'))