From: Rishabh Dave Date: Sat, 12 Oct 2019 11:32:33 +0000 (+0530) Subject: ceph-volume: make get_pv() accepts list of PVs X-Git-Tag: v14.2.5~132^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31408%2Fhead;p=ceph.git ceph-volume: make get_pv() accepts list of PVs ...so that the code calling it can pass its copy which would prevent creating a new one within get_pv(). Signed-off-by: Rishabh Dave (cherry picked from commit 2cdf467f76ab3331c04bec2b9f0e198ff67dd2dd) --- diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 0f86785508c8..b6661522e342 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -496,7 +496,7 @@ def remove_pv(pv_name): ) -def get_pv(pv_name=None, pv_uuid=None, pv_tags=None): +def get_pv(pv_name=None, pv_uuid=None, pv_tags=None, pvs=None): """ Return a matching pv (physical volume) for the current system, requiring ``pv_name``, ``pv_uuid``, or ``pv_tags``. Raises an error if more than one @@ -504,7 +504,9 @@ def get_pv(pv_name=None, pv_uuid=None, pv_tags=None): """ if not any([pv_name, pv_uuid, pv_tags]): return None - pvs = PVolumes() + if pvs is None or len(pvs) == 0: + pvs = PVolumes() + return pvs.get(pv_name=pv_name, pv_uuid=pv_uuid, pv_tags=pv_tags)