]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: return osd_id from util.prepare.check_id if it exists
authorAndrew Schoen <aschoen@redhat.com>
Tue, 30 Jan 2018 15:21:47 +0000 (09:21 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 5 Feb 2018 15:14:18 +0000 (09:14 -0600)
This also changes this so the osd_id is returned as a string so
an ID of 0 would evaluate to True.

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

src/ceph-volume/ceph_volume/util/prepare.py

index fccbf170bfc1b300ce787a8dc70240d1165deb38..dc272d2ac7c2cdc66dd3f07e68657c337ba81278 100644 (file)
@@ -73,12 +73,12 @@ def create_id(fsid, json_secrets):
 
 def check_id(osd_id):
     """
-    Checks to see if an osd ID exists or not. Returns True
+    Checks to see if an osd ID exists or not. Returns osd_id
     if it does exist, False if it doesn't.
 
     :param osd_id: The osd ID to check
     """
-    if not osd_id:
+    if osd_id is None:
         return False
     bootstrap_keyring = '/var/lib/ceph/bootstrap-osd/%s.keyring' % conf.cluster
     stdout, stderr, returncode = process.call(
@@ -98,7 +98,11 @@ def check_id(osd_id):
 
     output = json.loads(stdout)
     osds = output['nodes']
-    return any([osd['id'] == osd_id for osd in osds])
+    found_osd = any([str(osd['id']) == str(osd_id) for osd in osds])
+    if found_osd:
+        # return a string so an ID of 0 evaluates to True
+        return str(osd_id)
+    return False
 
 
 def mount_tmpfs(path):