]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: Reporting /sys directory in get_partition_dev()
authorErwan Velu <erwan@redhat.com>
Wed, 22 Mar 2017 09:11:44 +0000 (10:11 +0100)
committerNathan Cutler <ncutler@suse.com>
Wed, 5 Jul 2017 21:29:48 +0000 (23:29 +0200)
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 <erwan@redhat.com>
(cherry picked from commit 413c9fcfbe8e6ab33d73b8428090ccacc33c5d15)

src/ceph-disk/ceph_disk/main.py

index 9fca6484e920ac120957364eed46b5bcc2ea1ce2..d3e0773fb2752ed2a9d7ea4db617a292cb5ed0ff 100755 (executable)
@@ -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():