From 7949b7bd9ce55da0d13b3fe2c73d77312e74bf44 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 (cherry picked from commit 9c241e946a9808b23e5f923ab9283666355883fd) --- 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 bef69bcbe4f1a..8a34195a636bb 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -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('') == 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.39.5