From 9c241e946a9808b23e5f923ab9283666355883fd Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Mon, 30 Nov 2020 17:49:50 +0530 Subject: [PATCH] mgr/orchestrator: Remove 'CONTAINER ID' col from orch ps if unknown Signed-off-by: Varsha Rao --- src/pybind/mgr/orchestrator/module.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index c3f31ba663c6..9345a907a66e 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -601,6 +601,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('') == 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( -- 2.47.3