From: Sage Weil Date: Fri, 25 Oct 2019 22:50:26 +0000 (-0500) Subject: ceph-daemon: include container_id and version in 'ls' output X-Git-Tag: v15.1.0~1156^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2039d3aa4ac94b9b6e8913b016573168ca30be11;p=ceph.git ceph-daemon: include container_id and version in 'ls' output Signed-off-by: Sage Weil --- diff --git a/src/ceph-daemon b/src/ceph-daemon index 32c594a3164c..a655da92a979 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -1191,6 +1191,7 @@ def command_unit(): def command_ls(): ls = [] + host_version = None # /var/lib/ceph if os.path.exists(args.data_dir): @@ -1205,12 +1206,18 @@ def command_ls(): daemon_id) or 'unknown' (enabled, active) = check_unit('ceph-%s@%s' % (daemon_type, daemon_id)) + if not host_version: + out, err, code = call(['ceph', '-v']) + if not code and out.startswith('ceph version '): + host_version = out.split(' ')[3] + ls.append({ 'style': 'legacy', 'name': '%s.%s' % (daemon_type, daemon_id), 'fsid': fsid, 'enabled': enabled, 'active': active, + 'version': host_version, }) elif is_fsid(i): fsid = i @@ -1228,12 +1235,32 @@ def command_ls(): (enabled, active) = check_unit(get_unit_name(fsid, daemon_type, daemon_id)) + + # get container id + container_id = None + version = None + out, err, code = call( + [ + podman_path, 'inspect', + '--format', '{{.Id}}', + 'ceph-%s-%s' % (fsid, j) + ], + podman_path) + if not code: + container_id = out.strip()[0:12] + out, err, code = call( + [podman_path, 'exec', container_id, 'ceph', '-v'], + podman_path) + if not code and out.startswith('ceph version '): + version = out.split(' ')[2] ls.append({ 'style': 'ceph-daemon:v1', 'name': name, 'fsid': fsid, 'enabled': enabled, 'active': active, + 'container_id': container_id, + 'version': version, }) # /var/lib/rook