From 43e33dcd82dea7072c2d61d48a6638cdf0ebf941 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 18 Aug 2017 17:10:54 -0400 Subject: [PATCH] ceph-volume lvm.api uses the new parser for lvs Signed-off-by: Alfredo Deza --- .../ceph_volume/devices/lvm/api.py | 35 +++++-------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/api.py b/src/ceph-volume/ceph_volume/devices/lvm/api.py index 8ff2faf4d60ef..29749ef2565c9 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/api.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/api.py @@ -87,37 +87,18 @@ def get_api_lvs(): Return the list of logical volumes available in the system using flags to include common metadata associated with them - Command and sample JSON output, should look like:: + Command and delimeted output, should look like:: - $ sudo lvs -o lv_tags,lv_path,lv_name,vg_name --reportformat=json - { - "report": [ - { - "lv": [ - { - "lv_tags":"", - "lv_path":"/dev/VolGroup00/LogVol00", - "lv_name":"LogVol00", - "vg_name":"VolGroup00"}, - { - "lv_tags":"ceph.osd_fsid=aaa-fff-0000,ceph.osd_fsid=aaa-fff-bbbb,ceph.osd_id=0", - "lv_path":"/dev/osd_vg/OriginLV", - "lv_name":"OriginLV", - "vg_name":"osd_vg" - } - ] - } - ] - } + $ sudo lvs --noheadings --separator=';' -o lv_tags,lv_path,lv_name,vg_name + ;/dev/ubuntubox-vg/root;root;ubuntubox-vg + ;/dev/ubuntubox-vg/swap_1;swap_1;ubuntubox-vg """ + fields = 'lv_tags,lv_path,lv_name,vg_name' stdout, stderr, returncode = process.call( - ['sudo', 'lvs', '-o', 'lv_tags,lv_path,lv_name,vg_name', '--reportformat=json']) - report = json.loads(''.join(stdout)) - for report_item in report.get('report', []): - # is it possible to get more than one item in "report" ? - return report_item['lv'] - return [] + ['sudo', 'lvs', '--noheadings', '--separator=";"', '-o', fields] + ) + return _output_parser(stdout, fields) def get_lv(lv_name=None, vg_name=None, lv_path=None, lv_tags=None): -- 2.39.5