From: Alfredo Deza Date: Thu, 14 Sep 2017 11:35:47 +0000 (-0400) Subject: ceph-volume lvm.api use a helper to get an lv from an arg X-Git-Tag: v13.0.1~689^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3c5bbbc5822f02a038f093647c5de58bef2fe8f5;p=ceph.git ceph-volume lvm.api use a helper to get an lv from an arg Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/devices/lvm/api.py b/src/ceph-volume/ceph_volume/devices/lvm/api.py index e5bc26234715..0679639d4329 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/api.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/api.py @@ -131,6 +131,19 @@ def get_api_pvs(): return _output_parser(stdout, fields) +def get_lv_from_argument(argument): + """ + Helper proxy function that consumes a possible logical volume passed in from the CLI + in the form of `vg/lv`, but with some validation so that an argument that is a full + path to a device can be ignored + """ + try: + vg_name, lv_name = argument.split('/') + except (ValueError, AttributeError): + return None + return get_lv(lv_name=lv_name, vg_name=vg_name) + + def get_lv(lv_name=None, vg_name=None, lv_path=None, lv_uuid=None, lv_tags=None): """ Return a matching lv for the current system, requiring ``lv_name``,