]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: only fall back to sgdisk for 'list' if blkid seems old
authorSage Weil <sage@redhat.com>
Wed, 13 Aug 2014 18:40:34 +0000 (11:40 -0700)
committerSage Weil <sage@redhat.com>
Sat, 16 Aug 2014 00:15:37 +0000 (17:15 -0700)
If the blkid doesn't show us any ID_PART_ENTRY_* fields but we know it is
a GPT partition, *then* fallback.  Otherwise, don't bother.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit b1651afb34d9d2c324db3bf5f54ac9ce001c6af9)

src/ceph-disk

index 7297da3773febbf05bf12087d9e2fdc0dc983fd8..711365f4744823a74468216ebbdbf479e506a544 100755 (executable)
@@ -2163,10 +2163,36 @@ def get_partition_type(part):
             part,
         ]
     )
+    saw_part_entry = False
     for line in blkid.splitlines():
         (key, value) = line.split('=')
         if key == 'ID_PART_ENTRY_TYPE':
             return value
+        if key == 'ID_PART_ENTRY_SCHEME':
+            table_type = value
+        if key.startswith('ID_PART_ENTRY_'):
+            saw_part_entry = True
+
+    # hmm, is it in fact GPT?
+    table_type = None
+    base = get_partition_base(part)
+    blkid, _ = command(
+        [
+            'blkid',
+            '-p',
+            '-o', 'udev',
+            base
+        ]
+    )
+    for line in blkid.splitlines():
+        (key, value) = line.split('=')
+        if key == 'ID_PART_TABLE_TYPE':
+            table_type = value
+    if table_type != 'gpt':
+        return None    # not even GPT
+
+    if saw_part_entry:
+        return None    # GPT, and blkid appears to be new, so we're done.
 
     # bah, fall back to sgdisk.
     (base, partnum) = re.match('(\D+)(\d+)', part).group(1, 2)