]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orch: show spec age in 'orch ls'
authorSage Weil <sage@redhat.com>
Wed, 4 Mar 2020 17:28:55 +0000 (11:28 -0600)
committerSage Weil <sage@redhat.com>
Thu, 5 Mar 2020 12:42:27 +0000 (06:42 -0600)
Also rearrange the columns a bit.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator/module.py

index 36143f90da47171273bc22f8b9e53bccb4469162..74501ee0a5aed9bcb1544f81a6605a562c0bbbe8 100644 (file)
@@ -335,11 +335,15 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule):
         else:
             now = datetime.datetime.utcnow()
             table = PrettyTable(
-                ['NAME', 'RUNNING', 'REFRESHED', 'IMAGE NAME', 'IMAGE ID', 'SPEC', 'PLACEMENT'],
+                ['NAME', 'RUNNING', 'REFRESHED', 'AGE',
+                 'SPEC', 'PLACEMENT',
+                 'IMAGE NAME', 'IMAGE ID',
+                ],
                 border=False)
             table.align['NAME'] = 'l'
             table.align['RUNNING'] = 'r'
             table.align['REFRESHED'] = 'l'
+            table.align['AGE'] = 'l'
             table.align['IMAGE NAME'] = 'l'
             table.align['IMAGE ID'] = 'l'
             table.align['SPEC'] = 'l'
@@ -347,18 +351,20 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule):
             table.left_padding_width = 0
             table.right_padding_width = 2
             for s in sorted(services, key=lambda s: s.service_name):
-                if s.last_refresh:
-                    age = to_pretty_timedelta(now - s.last_refresh) + ' ago'
-                else:
-                    age = '-'
+                def nice_delta(t, suffix=''):
+                    if t:
+                        return to_pretty_timedelta(now - t) + suffix
+                    else:
+                        return '-'
                 table.add_row((
                     s.service_name,
                     '%d/%d' % (s.running, s.size),
-                    age,
-                    ukn(s.container_image_name),
-                    ukn(s.container_image_id)[0:12],
+                    nice_delta(s.last_refresh, ' age'),
+                    nice_delta(s.created),
                     'present' if s.spec else '-',
                     s.spec.placement.pretty_str() if s.spec else '-',
+                    ukn(s.container_image_name),
+                    ukn(s.container_image_id)[0:12],
                 ))
 
             return HandleCommandResult(stdout=table.get_string())