From f06366836ffabe9ff4fb1cb2b74298a3971ded58 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 25 Nov 2019 08:44:54 -0600 Subject: [PATCH] mgr/orchestrator_cli: print table for 'host ls' Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator_cli/module.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 3da51bd123c..3d3bba53956 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -171,8 +171,15 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): completion = self.get_hosts() self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) - result = "\n".join(map(lambda node: node.name, completion.result)) - return HandleCommandResult(stdout=result) + table = PrettyTable( + ['HOST', 'LABELS'], + border=False) + table.align = 'l' + table.left_padding_width = 0 + table.right_padding_width = 1 + for node in completion.result: + table.add_row((node.name, ' '.join(node.labels))) + return HandleCommandResult(stdout=table.get_string()) @orchestrator._cli_write_command( 'orchestrator host label add', -- 2.39.5