From 6bcf50548534231174e1ebd29a03990c0a4c27a6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 5 Nov 2019 12:08:55 -0600 Subject: [PATCH] mgr/orchestrator: include container_image in 'service ls' output Rearrange the columns a bit too. Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator.py | 12 +++++++++--- src/pybind/mgr/orchestrator_cli/module.py | 11 ++++++----- src/pybind/mgr/ssh/module.py | 6 ++++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 1bdc7fec178..bd32fad32a2 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -723,15 +723,21 @@ class ServiceDescription(object): has decided the service should run. """ - def __init__(self, nodename=None, container_id=None, service=None, service_instance=None, + def __init__(self, nodename=None, + container_id=None, container_image_id=None, + container_image_name=None, + service=None, service_instance=None, service_type=None, version=None, rados_config_location=None, service_url=None, status=None, status_desc=None): # Node is at the same granularity as InventoryNode self.nodename = nodename # Not everyone runs in containers, but enough people do to - # justify having this field here. - self.container_id = container_id + # justify having the container_id (runtime id) and container_image + # (image name) + self.container_id = container_id # runtime id + self.container_image_id = container_image_id # image hash + self.container_image_name = container_image_name # image friendly name # Some services can be deployed in groups. For example, mds's can # have an active and standby daemons, and nfs-ganesha can run daemons diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index cf4734118c3..f11c870a496 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -251,8 +251,8 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): return HandleCommandResult(stdout=json.dumps(data)) else: table = PrettyTable( - ['NAME', 'HOST', 'CONTAINER', 'VERSION', 'STATUS', - 'DESCRIPTION'], + ['NAME', 'HOST', 'STATUS', + 'VERSION', 'IMAGE NAME', 'IMAGE ID', 'CONTAINER ID'], border=False) table.align = 'l' table.left_padding_width = 0 @@ -268,10 +268,11 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): table.add_row(( s.name(), ukn(s.nodename), - ukn(s.container_id), - ukn(s.version), status, - ukn(s.status_desc))) + ukn(s.version), + ukn(s.container_image_name), + ukn(s.container_image_id)[0:12], + ukn(s.container_id)[0:12])) return HandleCommandResult(stdout=table.get_string()) diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index c04742e6263..ea3842f9dc9 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -617,8 +617,10 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): if service_name and not sd.service_instance.startswith(service_name + '.'): continue sd.nodename = host - sd.container_id = d['container_id'] - sd.version = d['version'] + sd.container_id = d.get('container_id') + sd.container_image_name = d.get('container_image_name') + sd.container_image_id = d.get('container_image_id') + sd.version = d.get('version') sd.status_desc = d['state'] sd.status = { 'running': 1, -- 2.39.5