]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
LVM: Activate Thin Pool LV upon initialization
authorEric Harney <eharney@redhat.com>
Fri, 13 Dec 2013 15:39:09 +0000 (10:39 -0500)
committerGerrit Code Review <review@openstack.org>
Thu, 2 Jan 2014 15:51:06 +0000 (15:51 +0000)
If the LVM thin pool is not active, space calculation fails,
as data_percent is not known.  Activate the pool upon initialization,
since we intend to use it anyway.

Slightly refactors _get_thin_pool_free_space so that it is clear
which missing/unexpected value is breaking things if a similar error
occurs for some other reason.

Closes-Bug: #1260773

Change-Id: I7cb187746c1ac297b82254c6efa37ba1c5fbb3e1

cinder/brick/local_dev/lvm.py

index ddb46c8f18dad6d894d74a31f6246c1bcc471245..0037632b2383b7d3d98d2ff00dfd5252a95c9c09 100644 (file)
@@ -82,6 +82,8 @@ class LVM(executor.Executor):
             LOG.error(_('Unable to locate Volume Group %s') % vg_name)
             raise exception.VolumeGroupNotFound(vg_name=vg_name)
 
+        # NOTE: we assume that the VG has been activated outside of Cinder
+
         if lvm_type == 'thin':
             pool_name = "%s-pool" % self.vg_name
             if self.get_volume(pool_name) is None:
@@ -89,6 +91,8 @@ class LVM(executor.Executor):
             else:
                 self.vg_thin_pool = pool_name
 
+            self.activate_lv(self.vg_thin_pool)
+
     def _vg_exists(self):
         """Simple check to see if VG exists.
 
@@ -144,8 +148,10 @@ class LVM(executor.Executor):
             if out is not None:
                 out = out.strip()
                 data = out.split(':')
-                consumed_space = float(data[0]) / 100 * (float(data[1]))
-                free_space = float(data[0]) - consumed_space
+                pool_size = float(data[0])
+                data_percent = float(data[1])
+                consumed_space = pool_size / 100 * data_percent
+                free_space = pool_size - consumed_space
                 free_space = round(free_space, 2)
         except putils.ProcessExecutionError as err:
             LOG.exception(_('Error querying thin pool about data_percent'))