From 55c0eda3f31f1327578daa11435720d1e513a250 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Tue, 30 Jan 2018 09:21:47 -0600 Subject: [PATCH] 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 (cherry picked from commit 699aa65878ca18f2e2cd70d7444cad18b4a3fd98) --- src/ceph-volume/ceph_volume/util/prepare.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ceph-volume/ceph_volume/util/prepare.py b/src/ceph-volume/ceph_volume/util/prepare.py index fccbf170bfc1b..dc272d2ac7c2c 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): -- 2.39.5