]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/orchestrator_cli: print table for 'host ls'
authorSage Weil <sage@redhat.com>
Mon, 25 Nov 2019 14:44:54 +0000 (08:44 -0600)
committerSage Weil <sage@redhat.com>
Tue, 26 Nov 2019 14:01:26 +0000 (08:01 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator_cli/module.py

index 3da51bd123c60959ed0388ac71d89e467084c4ba..3d3bba53956781619cd3e9dba5f42254c5b1c9e1 100644 (file)
@@ -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',