From: Alfredo Deza Date: Wed, 30 Aug 2017 18:12:33 +0000 (-0400) Subject: ceph-volume util create a disk utility for blkid operations X-Git-Tag: v13.0.1~988^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a19e1288e8ae044f41dff9a1770126aa540cc729;p=ceph.git ceph-volume util create a disk utility for blkid operations Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/util/disk.py b/src/ceph-volume/ceph_volume/util/disk.py new file mode 100644 index 000000000000..0d3061d3cd06 --- /dev/null +++ b/src/ceph-volume/ceph_volume/util/disk.py @@ -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()