]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util.disk add a PART_ENTRY_TYPE detection utility
authorAlfredo Deza <adeza@redhat.com>
Tue, 30 Jan 2018 14:19:06 +0000 (09:19 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 7 Feb 2018 14:45:23 +0000 (08:45 -0600)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit cdb812438d6064089bac964cf38817d877afca38)

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

index b5de66eccb9ee925ca2a4c86c82d9f9536687695..c3a791540051df82edddca92cf25ca3484f66bc5 100644 (file)
@@ -3,6 +3,13 @@ import stat
 from ceph_volume import process
 
 
+# The blkid CLI tool has some oddities which prevents having one common call
+# to extract the information instead of having separate utilities. The `udev`
+# type of output is needed in older versions of blkid (v 2.23) that will not
+# work correctly with just the ``-p`` flag to bypass the cache for example.
+# Xenial doesn't have this problem as it uses a newer blkid version.
+
+
 def get_partuuid(device):
     """
     If a device is a partition, it will probably have a PARTUUID on it that
@@ -15,6 +22,20 @@ def get_partuuid(device):
     return ' '.join(out).strip()
 
 
+def get_part_entry_type(device):
+    """
+    Parses the ``ID_PART_ENTRY_TYPE`` from the "low level" (bypasses the cache)
+    output that uses the ``udev`` type of output. This output is intended to be
+    used for udev rules, but it is useful in this case as it is the only
+    consistent way to retrieve the GUID used by ceph-disk to identify devices.
+    """
+    out, err, rc = process.call(['blkid', '-p', '-o', 'udev', device])
+    for line in out:
+        if 'ID_PART_ENTRY_TYPE=' in line:
+            return line.split('=')[-1].strip()
+    return ''
+
+
 def get_device_from_partuuid(partuuid):
     """
     If a device has a partuuid, query blkid so that it can tell us what that