From: Alfredo Deza Date: Fri, 15 Aug 2014 23:40:15 +0000 (-0400) Subject: Merge pull request #2247 from ceph/wip-ceph-disk X-Git-Tag: v0.85~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc611e864b6275f9233fef7bd3eb61fc12fed98d;p=ceph.git Merge pull request #2247 from ceph/wip-ceph-disk ceph-disk: fix various dmcrypt bugs Reviewed-by: Alfredo Deza --- dc611e864b6275f9233fef7bd3eb61fc12fed98d diff --cc src/ceph-disk index 01bd85530aad,1bd380a08fa7..c5bb56cb1560 --- a/src/ceph-disk +++ b/src/ceph-disk @@@ -2165,8 -2150,55 +2180,56 @@@ def get_dev_fs(dev) else: return None + def get_partition_type(part): + """ + Get the GPT partition type UUID. If we have an old blkid and can't + get it that way, use sgdisk and use the description instead (and hope + dmcrypt isn't being used). + """ + blkid, _ = command( + [ + 'blkid', + '-p', + '-o', 'udev', + 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. + if 'blkid' not in warned_about: + LOG.warning('Old blkid does not support ID_PART_ENTRY_* fields, trying sgdisk; may not correctly identify ceph volumes with dmcrypt') + warned_about['blkid'] = True (base, partnum) = re.match('(\D+)(\d+)', part).group(1, 2) sgdisk, _ = command( [ @@@ -2182,10 -2214,15 +2245,16 @@@ num = m.group(1) if num != partnum: continue - return m.group(2) + desc = m.group(2) + # assume unencrypted ... blkid has failed us :( + if desc == 'ceph data': + return OSD_UUID + if desc == 'ceph journal': + return JOURNAL_UUID + return None + def get_partition_uuid(dev): (base, partnum) = re.match('(\D+)(\d+)', dev).group(1, 2) out, _ = command(['sgdisk', '-i', partnum, base])