]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util create a disk utility for blkid operations
authorAlfredo Deza <adeza@redhat.com>
Wed, 30 Aug 2017 18:12:33 +0000 (14:12 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 31 Aug 2017 19:56:16 +0000 (15:56 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit a19e1288e8ae044f41dff9a1770126aa540cc729)

src/ceph-volume/ceph_volume/util/disk.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/util/disk.py b/src/ceph-volume/ceph_volume/util/disk.py
new file mode 100644 (file)
index 0000000..0d3061d
--- /dev/null
@@ -0,0 +1,24 @@
+from ceph_volume import process
+
+
+def get_partuuid(device):
+    """
+    If a device is a partition, it will probably have a PARTUUID on it that
+    will persist and can be queried against `blkid` later to detect the actual
+    device
+    """
+    out, err, rc = process.call(
+        ['sudo', 'blkid', '-s', 'PARTUUID', '-o', 'value', device]
+    )
+    return ' '.join(out).strip()
+
+
+def get_device_from_partuuid(partuuid):
+    """
+    If a device has a partuuid, query blkid so that it can tell us what that
+    device is
+    """
+    out, err, rc = process.call(
+        ['sudo', 'blkid', '-t', 'PARTUUID="%s"' % partuuid, '-o', 'device']
+    )
+    return ' '.join(out).strip()