]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util.disk fix issue when capturing partition information
authorAlfredo Deza <adeza@redhat.com>
Tue, 27 Nov 2018 14:26:33 +0000 (09:26 -0500)
committerAlfredo Deza <adeza@redhat.com>
Fri, 30 Nov 2018 19:06:32 +0000 (14:06 -0500)
Before, the `if` condition meant that it would only work when the output
was '1', which is incorrect as that would only happen if a partition was
the first one, ignoring any other partition. The contents of that file
is the partition number, not a boolean to tell if it is a partition or
not.

It now includes the `holders` file contents which is needed for
dm-mapper work

Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 28cb13a970909dc8efe508aee18f47e0fb3fdde3)

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

index ccc2ff7a15226498e698f0322f3a463989a57558..171212d5601c64238c71b27892833388c2b7ac43 100644 (file)
@@ -631,7 +631,7 @@ def get_partitions_facts(sys_block_path):
         folder_path = os.path.join(sys_block_path, folder)
         if os.path.exists(os.path.join(folder_path, 'partition')):
             contents = get_file_contents(os.path.join(folder_path, 'partition'))
-            if '1' in contents:
+            if contents:
                 part = {}
                 partname = folder
                 part_sys_block_path = os.path.join(sys_block_path, partname)
@@ -645,6 +645,9 @@ def get_partitions_facts(sys_block_path):
                     part['sectorsize'] = get_file_contents(
                         part_sys_block_path + "/queue/hw_sector_size", 512)
                 part['size'] = human_readable_size(float(part['sectors']) * 512)
+                part['holders'] = []
+                for holder in os.listdir(part_sys_block_path + '/holders'):
+                    part['holders'].append(holder)
 
                 partition_metadata[partname] = part
     return partition_metadata