]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: `ls`: also return systemd_unit
authorSebastian Wagner <sebastian.wagner@suse.com>
Mon, 18 May 2020 10:35:34 +0000 (12:35 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Mon, 18 May 2020 10:35:34 +0000 (12:35 +0200)
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 <sebastian.wagner@suse.com>
src/cephadm/cephadm

index 6a7c568bd8f6e19ffac8de52d85dc2a1b8f56e18..45c03f33e40a3ba96e2e2171fbeadca9da1f6ea4 100755 (executable)
@@ -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)