From: Eric Harney Date: Tue, 28 Oct 2014 21:03:42 +0000 (-0400) Subject: Brick LVM: Rename get_all_volumes, further optimize X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2cb519dbd20de68b1c182e772621098527e97e17;p=openstack-build%2Fcinder-build.git Brick LVM: Rename get_all_volumes, further optimize This method can process all LVs, those in a VG, or an individual LV. Rename it to be more descriptive. Optimize update_volume_group_info check for thin pool. Remove volume.utils.get_all_volumes, which is unused. Remove fake_lvm.get_all_volumes and fake_lvm.get_all_volume_groups which don't appear to have correct signatures/returns and are unused. Change-Id: I412c62230517cbfc08cc0076aaeea45224e6b50e --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 1befdfa9c..aecdb3c2b 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -233,8 +233,8 @@ class LVM(executor.Executor): return self._supports_lvchange_ignoreskipactivation @staticmethod - def get_all_volumes(root_helper, vg_name=None, lv_name=None): - """Static method to get all LV's on a system. + def get_lv_info(root_helper, vg_name=None, lv_name=None): + """Retrieve info about LVs (all, in a VG, or a single LV). :param root_helper: root_helper to use for execute :param vg_name: optional, gathers info for only the specified VG @@ -273,9 +273,9 @@ class LVM(executor.Executor): :returns: List of Dictionaries with LV info """ - self.lv_list = self.get_all_volumes(self._root_helper, - self.vg_name, - lv_name) + self.lv_list = self.get_lv_info(self._root_helper, + self.vg_name, + lv_name) return self.lv_list def get_volume(self, name): @@ -389,7 +389,9 @@ class LVM(executor.Executor): self.vg_uuid = vg_list[0]['uuid'] if self.vg_thin_pool is not None: - for lv in self.get_all_volumes(self._root_helper, self.vg_name): + for lv in self.get_lv_info(self._root_helper, + self.vg_name, + self.vg_thin_pool): if lv['name'] == self.vg_thin_pool: self.vg_thin_pool_size = lv['size'] tpfs = self._get_thin_pool_free_space(self.vg_name, diff --git a/cinder/tests/brick/fake_lvm.py b/cinder/tests/brick/fake_lvm.py index f1cc0adb7..cadb3d80e 100644 --- a/cinder/tests/brick/fake_lvm.py +++ b/cinder/tests/brick/fake_lvm.py @@ -27,11 +27,6 @@ class FakeBrickLVM(object): def supports_thin_provisioning(): return False - def get_all_volumes(vg_name=None): - if vg_name is not None: - return [vg_name] - return ['cinder-volumes', 'fake-vg-1'] - def get_volumes(self): return ['fake-volume'] @@ -44,9 +39,6 @@ class FakeBrickLVM(object): def get_physical_volumes(self): return [] - def get_all_volume_groups(vg_name=None): - return ['cinder-volumes', 'fake-vg'] - def update_volume_group_info(self): pass diff --git a/cinder/volume/utils.py b/cinder/volume/utils.py index 56f5b0c62..24ccf6141 100644 --- a/cinder/volume/utils.py +++ b/cinder/volume/utils.py @@ -393,12 +393,6 @@ def supports_thin_provisioning(): utils.get_root_helper()) -def get_all_volumes(vg_name=None): - return brick_lvm.LVM.get_all_volumes( - utils.get_root_helper(), - vg_name) - - def get_all_physical_volumes(vg_name=None): return brick_lvm.LVM.get_all_physical_volumes( utils.get_root_helper(),