From: Rishabh Dave Date: Tue, 3 Sep 2019 13:06:23 +0000 (+0530) Subject: api/lvm: rewrite a condition X-Git-Tag: v14.2.5~181^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31228%2Fhead;p=ceph.git api/lvm: rewrite a condition Create the list of logical volumes if the list passed in arguments is empty and rewrite the condition to make it more readable. Fixes: https://tracker.ceph.com/issues/41649 Signed-off-by: Rishabh Dave (cherry picked from commit d1f1bfd3635501090f4069be59e0bcde94dd64ec) --- diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 92ac2c2283db..f4f3d6cf5eb1 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -274,7 +274,9 @@ def is_lv(dev, lvs=None): splitname = dmsetup_splitname(dev) # Allowing to optionally pass `lvs` can help reduce repetitive checks for # multiple devices at once. - lvs = lvs if lvs is not None else Volumes() + if lvs is None or len(lvs) == 0: + lvs = Volumes() + if splitname.get('LV_NAME'): lvs.filter(lv_name=splitname['LV_NAME'], vg_name=splitname['VG_NAME']) return len(lvs) > 0