From: Theofilos Mouratidis Date: Fri, 4 May 2018 09:37:18 +0000 (+0200) Subject: ceph-volume: sort and align output X-Git-Tag: v14.0.1~1211^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F21812%2Fhead;p=ceph.git ceph-volume: sort and align output This commit targets the `ceph-volume lvm list` command. The output is sorted by the osd id and each device's attributed are sorted, so the ceph operators can find relevant information easier. The devices (block,db,..etc) are now properly aligned. Signed-off-by: Theofilos Mouratidis --- diff --git a/src/ceph-volume/ceph_volume/devices/lvm/listing.py b/src/ceph-volume/ceph_volume/devices/lvm/listing.py index a84a39c182a5..6bc84a16864e 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/listing.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/listing.py @@ -17,7 +17,7 @@ osd_list_header_template = """\n osd_device_header_template = """ - [{type: >4}] {path} + {type: <13} {path} """ device_metadata_item_template = """ @@ -31,18 +31,18 @@ def readable_tag(tag): def pretty_report(report): output = [] - for _id, devices in report.items(): + for _id, devices in sorted(report.items()): output.append( osd_list_header_template.format(osd_id=" osd.%s " % _id) ) for device in devices: output.append( osd_device_header_template.format( - type=device['type'], + type='[%s]' % device['type'], path=device['path'] ) ) - for tag_name, value in device.get('tags', {}).items(): + for tag_name, value in sorted(device.get('tags', {}).items()): output.append( device_metadata_item_template.format( tag_name=readable_tag(tag_name), @@ -179,7 +179,6 @@ class List(object): return self.full_report(lvs=lvs) if lv: - try: _id = lv.tags['ceph.osd_id'] except KeyError: diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py index a49a3e9e6a08..fba7d73e135d 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py @@ -26,7 +26,7 @@ class TestPrettyReport(object): {'type': 'data', 'path': '/dev/sda1', 'devices': ['/dev/sda']} ]}) stdout, stderr = capsys.readouterr() - assert '[data] /dev/sda1' in stdout + assert '[data] /dev/sda1' in stdout def test_osd_id_header_is_reported(self, capsys): lvm.listing.pretty_report({0: [