]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: Remove 'CONTAINER ID' col from orch ps if unknown
authorVarsha Rao <varao@redhat.com>
Mon, 30 Nov 2020 12:19:50 +0000 (17:49 +0530)
committerSebastian Wagner <sebastian.wagner@suse.com>
Thu, 7 Jan 2021 12:02:21 +0000 (13:02 +0100)
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit 9c241e946a9808b23e5f923ab9283666355883fd)

src/pybind/mgr/orchestrator/module.py

index bef69bcbe4f1ad1936295373af42c0773d9f75c9..8a34195a636bbf97a422eb19c99864720d1bc95e 100644 (file)
@@ -603,6 +603,18 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule):
                     ukn(s.container_image_id)[0:12],
                     ukn(s.container_id)))
 
+            remove_column = 'CONTAINER ID'
+            if table.get_string(fields=[remove_column], border=False,
+                    header=False).count('<unknown>') == len(daemons):
+                try:
+                    table.del_column(remove_column)
+                except AttributeError as e:
+                    # del_column method was introduced in prettytable 2.0
+                    if str(e) != "del_column":
+                        raise
+                    table.field_names.remove(remove_column)
+                    table._rows = [row[:-1] for row in table._rows]
+
             return HandleCommandResult(stdout=table.get_string())
 
     @_cli_write_command(