Skip to content

Commit

Permalink
Merge pull request ceph#44604 from mgfritch/c-v-skip-rbd-devs
Browse files Browse the repository at this point in the history
ceph-volume: show RBD devices as not available
  • Loading branch information
guits authored Jan 21, 2022
2 parents f300687 + 47325ec commit f23e1ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ceph-volume/ceph_volume/tests/util/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ def test_is_rotational(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
result = disk.get_devices(_sys_block_path=block_path)
assert result[sda_path]['rotational'] == '1'

def test_is_ceph_rbd(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
rbd_path = '/dev/rbd0'
patched_get_block_devs_lsblk.return_value = [[rbd_path, rbd_path, 'disk']]
block_path = self.setup_path(tmpdir)
block_rbd_path = os.path.join(block_path, 'rbd0')
os.makedirs(block_rbd_path)
result = disk.get_devices(_sys_block_path=block_path)
assert rbd_path not in result


class TestSizeCalculations(object):

Expand Down
11 changes: 11 additions & 0 deletions src/ceph-volume/ceph_volume/util/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ def is_partition(dev):
return False


def is_ceph_rbd(dev):
"""
Boolean to determine if a given device is a ceph RBD device, like /dev/rbd0
"""
return dev.startswith(('/dev/rbd'))


class BaseFloatUnit(float):
"""
Base class to support float representations of size values. Suffix is
Expand Down Expand Up @@ -764,6 +771,10 @@ def get_devices(_sys_block_path='/sys/block'):
sysdir = os.path.join(_sys_block_path, devname)
metadata = {}

# If the device is ceph rbd it gets excluded
if is_ceph_rbd(diskname):
continue

# If the mapper device is a logical volume it gets excluded
if is_mapper_device(diskname):
if lvm.get_device_lvs(diskname):
Expand Down

0 comments on commit f23e1ba

Please sign in to comment.