From d8f81540600ee1687030259ed535a390a5b65f09 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 18 May 2020 12:35:34 +0200 Subject: [PATCH] cephadm: `ls`: also return systemd_unit Let users directly know the systemd unit name. Enable things like ``` cephadm ls | jq -r '.[].systemd_unit' | xargs -n 1 systemctl status | cat ``` Signed-off-by: Sebastian Wagner --- src/cephadm/cephadm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 6a7c568bd8f6e..45c03f33e40a3 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2993,14 +2993,15 @@ def list_daemons(detail=True, legacy_dir=None): fsid = get_legacy_daemon_fsid( cluster, daemon_type, daemon_id, legacy_dir=legacy_dir) + legacy_unit_name = 'ceph-%s@%s' % (daemon_type, daemon_id) i = { 'style': 'legacy', 'name': '%s.%s' % (daemon_type, daemon_id), 'fsid': fsid if fsid is not None else 'unknown', + 'systemd_unit': legacy_unit_name, } if detail: - (i['enabled'], i['state'], _) = check_unit( - 'ceph-%s@%s' % (daemon_type, daemon_id)) + (i['enabled'], i['state'], _) = check_unit(legacy_unit_name) if not host_version: try: out, err, code = call(['ceph', '-v']) @@ -3108,6 +3109,7 @@ def list_daemons(detail=True, legacy_dir=None): os.path.join(data_dir, fsid, j, 'unit.image')) i['configured'] = get_file_timestamp( os.path.join(data_dir, fsid, j, 'unit.configured')) + i['systemd_unit'] = unit_name ls.append(i) -- 2.39.5