From 6ccc654a0509c4e308713f9e6fd95266cd112c9d Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Fri, 13 Dec 2013 10:39:09 -0500 Subject: [PATCH] LVM: Activate Thin Pool LV upon initialization 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index ddb46c8f1..0037632b2 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -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')) -- 2.45.2