]> 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>
Wed, 13 Aug 2014 18:52:14 +0000 (11:52 -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>
src/ceph-disk

index 0fe1ee21457a025bf5de33f10703ecc0a87b4608..1e8cf795daae34b25866b261fd79f02c21ba1a29 100755 (executable)
@@ -2161,10 +2161,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)