From f7f6375b54233f1085ba8d64df1053c038ff3991 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Wed, 22 Mar 2017 10:11:44 +0100 Subject: [PATCH] ceph-disk: Reporting /sys directory in get_partition_dev() When get_partition_dev() fails, it reports the following message : ceph_disk.main.Error: Error: partition 2 for /dev/sdb does not appear to exist The code search for a directory inside the /sys/block/get_dev_name(os.path.realpath(dev)). The issue here is the error message doesn't report that path when failing while it might be involved in. This patch is about reporting where the code was looking at when trying to estimate if the partition was available. Signed-off-by: Erwan Velu (cherry picked from commit 413c9fcfbe8e6ab33d73b8428090ccacc33c5d15) --- src/ceph-disk/ceph_disk/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ceph-disk/ceph_disk/main.py b/src/ceph-disk/ceph_disk/main.py index 9fca6484e920a..d3e0773fb2752 100755 --- a/src/ceph-disk/ceph_disk/main.py +++ b/src/ceph-disk/ceph_disk/main.py @@ -703,11 +703,14 @@ def get_partition_dev(dev, pnum): cciss/c0d1 1 -> cciss!c0d1p1 """ partname = None + error_msg = "" if is_mpath(dev): partname = get_partition_mpath(dev, pnum) else: name = get_dev_name(os.path.realpath(dev)) - for f in os.listdir(os.path.join('/sys/block', name)): + sys_entry = os.path.join('/sys/block', name) + error_msg = " in %s" % sys_entry + for f in os.listdir(sys_entry): if f.startswith(name) and f.endswith(str(pnum)): # we want the shortest name that starts with the base name # and ends with the partition number @@ -716,8 +719,8 @@ def get_partition_dev(dev, pnum): if partname: return get_dev_path(partname) else: - raise Error('partition %d for %s does not appear to exist' % - (pnum, dev)) + raise Error('partition %d for %s does not appear to exist%s' % + (pnum, dev, error_msg)) def list_all_partitions(): -- 2.39.5