]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add systemd.systemctl.get_running_osd_ids
authorAndrew Schoen <aschoen@redhat.com>
Wed, 6 Mar 2019 22:51:06 +0000 (16:51 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Fri, 8 Mar 2019 17:08:39 +0000 (11:08 -0600)
This is used to retrieve a list of osd ids from the currently
running ceph-osd systemd units.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
(cherry picked from commit 15d20e29a2f2d74caf05dfec559e30941c7a46ab)

src/ceph-volume/ceph_volume/systemd/systemctl.py

index 41dbbc19e644d42e059d850c203543e5d89ec8ab..280ddada7e9983d05212e8f699dd2240d4e365f3 100644 (file)
@@ -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_)