ceph-volume lvm.api use a helper to get an lv from an arg

Signed-off-by: Alfredo Deza <adeza@redhat.com>
This commit is contained in:
Alfredo Deza 2017-09-14 07:35:47 -04:00
parent ff72fd0ed5
commit 3c5bbbc582

View 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``,