From 15d20e29a2f2d74caf05dfec559e30941c7a46ab Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Wed, 6 Mar 2019 16:51:06 -0600 Subject: [PATCH] ceph-volume: add systemd.systemctl.get_running_osd_ids This is used to retrieve a list of osd ids from the currently running ceph-osd systemd units. Signed-off-by: Andrew Schoen --- src/ceph-volume/ceph_volume/systemd/systemctl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ceph-volume/ceph_volume/systemd/systemctl.py b/src/ceph-volume/ceph_volume/systemd/systemctl.py index 41dbbc19e64..280ddada7e9 100644 --- a/src/ceph-volume/ceph_volume/systemd/systemctl.py +++ b/src/ceph-volume/ceph_volume/systemd/systemctl.py @@ -34,6 +34,22 @@ def is_active(unit): ) return rc == 0 +def get_running_osd_ids(): + out, err, rc = process.call([ + 'systemctl', + 'show', + '--no-pager', + '--property=Id', + '--state=running', + 'ceph-osd@*', + ]) + osd_ids = [] + for line in out: + if line: + # example line looks like: Id=ceph-osd@1.service + osd_id = line.split("@")[1].split(".service")[0] + osd_ids.append(osd_id) + return osd_ids def start_osd(id_): return start(osd_unit % id_) -- 2.39.5