From: Sage Weil Date: Thu, 5 Mar 2020 12:42:15 +0000 (-0600) Subject: mgr/orch: factor out nice_delta X-Git-Tag: v15.1.1~103^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=94e77cc9c4facb0e8d4b46d0062d5eca5b279a0b;p=ceph-ci.git mgr/orch: factor out nice_delta Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 74501ee0a5a..3cc5c86d1db 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -25,6 +25,11 @@ from ._interface import OrchestratorClientMixin, DeviceLightLoc, _cli_read_comma NoOrchestrator, ServiceSpec, PlacementSpec, OrchestratorValidationError, NFSServiceSpec, \ RGWSpec, InventoryFilter, InventoryHost, HostPlacementSpec, HostSpec, CLICommandMeta +def nice_delta(now, t, suffix=''): + if t: + return to_pretty_timedelta(now - t) + suffix + else: + return '-' @six.add_metaclass(CLICommandMeta) class OrchestratorCli(OrchestratorClientMixin, MgrModule): @@ -351,16 +356,11 @@ 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): - 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), - nice_delta(s.last_refresh, ' age'), - nice_delta(s.created), + nice_delta(now, s.last_refresh, ' age'), + nice_delta(now, s.created), 'present' if s.spec else '-', s.spec.placement.pretty_str() if s.spec else '-', ukn(s.container_image_name), @@ -415,17 +415,12 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): if s.status == 1 and s.started: status += ' (%s)' % to_pretty_timedelta(now - s.started) - def nice_delta(t, suffix=''): - if t: - return to_pretty_timedelta(now - t) + suffix - else: - return '-' table.add_row(( s.name(), ukn(s.hostname), status, - nice_delta(s.last_refresh, ' ago'), - nice_delta(s.created), + nice_delta(now, s.last_refresh, ' ago'), + nice_delta(now, s.created), ukn(s.version), ukn(s.container_image_name), ukn(s.container_image_id)[0:12],