]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume lvm.api use a helper to get an lv from an arg
authorAlfredo Deza <adeza@redhat.com>
Thu, 14 Sep 2017 11:35:47 +0000 (07:35 -0400)
committerAlfredo Deza <adeza@redhat.com>
Tue, 3 Oct 2017 13:00:13 +0000 (09:00 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/devices/lvm/api.py

index e5bc26234715675543625d42484a14ef3c907114..0679639d4329877cf5514dd892f1698354dfa810 100644 (file)
@@ -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``,