From: Varsha Rao Date: Mon, 30 Nov 2020 12:19:50 +0000 (+0530) Subject: mgr/orchestrator: Remove 'CONTAINER ID' col from orch ps if unknown X-Git-Tag: v15.2.9~88^2~21 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7949b7bd9ce55da0d13b3fe2c73d77312e74bf44;p=ceph.git mgr/orchestrator: Remove 'CONTAINER ID' col from orch ps if unknown Signed-off-by: Varsha Rao (cherry picked from commit 9c241e946a9808b23e5f923ab9283666355883fd) --- 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(