From: Andrew Schoen Date: Wed, 17 Mar 2021 20:19:08 +0000 (-0500) Subject: ceph-volume: show devices with GPT headers as not available X-Git-Tag: v17.1.0~2522^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1347243242fc55c904c4d94fb43bdf0bcfc23ab0;p=ceph.git ceph-volume: show devices with GPT headers as not available This patch ensures that if a device has GPT headers it will not show up in `ceph-volume inventory` as available. Fixes: https://tracker.ceph.com/issues/48697 Resolves: rhbz#1908065 Signed-off-by: Andrew Schoen --- diff --git a/src/ceph-volume/ceph_volume/tests/util/test_device.py b/src/ceph-volume/ceph_volume/tests/util/test_device.py index ac8bc28afcbd..0df5ac61e9ea 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_device.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_device.py @@ -203,6 +203,18 @@ class TestDevice(object): disk = device.Device("/dev/sdb") assert not disk.available + def test_reject_device_with_gpt_headers(self, device_info): + data = {"/dev/sdb": {"removable": 0, "size": 5368709120}} + lsblk = {"TYPE": "disk"} + blkid= {"PTTYPE": "gpt"} + device_info( + devices=data, + blkid=blkid, + lsblk=lsblk, + ) + disk = device.Device("/dev/sdb") + assert not disk.available + def test_accept_non_removable_device(self, device_info): data = {"/dev/sdb": {"removable": 0, "size": 5368709120}} lsblk = {"TYPE": "disk"} diff --git a/src/ceph-volume/ceph_volume/util/device.py b/src/ceph-volume/ceph_volume/util/device.py index 461775202a72..deed06436d8e 100644 --- a/src/ceph-volume/ceph_volume/util/device.py +++ b/src/ceph-volume/ceph_volume/util/device.py @@ -478,6 +478,8 @@ class Device(object): rejected.append("Used by ceph-disk") if self.has_bluestore_label: rejected.append('Has BlueStore device label') + if self.has_gpt_headers: + rejected.append('Has GPT headers') return rejected def _check_lvm_reject_reasons(self):