From: Andrew Schoen Date: Tue, 30 Jan 2018 15:21:47 +0000 (-0600) Subject: ceph-volume: return osd_id from util.prepare.check_id if it exists X-Git-Tag: v13.0.2~387^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=699aa65878ca18f2e2cd70d7444cad18b4a3fd98;p=ceph.git ceph-volume: return osd_id from util.prepare.check_id if it exists 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 --- diff --git a/src/ceph-volume/ceph_volume/util/prepare.py b/src/ceph-volume/ceph_volume/util/prepare.py index fccbf170bfc1..dc272d2ac7c2 100644 --- a/src/ceph-volume/ceph_volume/util/prepare.py +++ b/src/ceph-volume/ceph_volume/util/prepare.py @@ -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):