]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: sort and align output 21812/head
authorTheofilos Mouratidis <t.mour@cern.ch>
Fri, 4 May 2018 09:37:18 +0000 (11:37 +0200)
committerTheofilos Mouratidis <t.mour@cern.ch>
Thu, 31 May 2018 08:49:57 +0000 (10:49 +0200)
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 <t.mour@cern.ch>
src/ceph-volume/ceph_volume/devices/lvm/listing.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py

index a84a39c182a512e4a6032e60be0afbf083dd1203..6bc84a16864ee824a16ea4e271fd693f421703ff 100644 (file)
@@ -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:
index a49a3e9e6a08f44246ad06ce86e14380c4809b5e..fba7d73e135d3ad3a7aa9376edbf5a6b7f9c087e 100644 (file)
@@ -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: [