summaryrefslogtreecommitdiffstats
path: root/src/ceph-volume/ceph_volume/tests
diff options
context:
space:
mode:
authorErwan Velu <erwan@redhat.com>2018-10-09 21:04:02 +0200
committerErwan Velu <erwan@redhat.com>2018-10-22 11:56:14 +0200
commitd8fdf0b7532cdffcae56511c377679e51841caec (patch)
tree0509f2bda79630566d8a30ee203cdd9fa6b3f1a2 /src/ceph-volume/ceph_volume/tests
parentMerge PR #24184 into master (diff)
downloadceph-d8fdf0b7532cdffcae56511c377679e51841caec.tar.xz
ceph-d8fdf0b7532cdffcae56511c377679e51841caec.zip
ceph_volume: Adding Device.is_valid()
A block device can be filtered-out/ignored because it have features that doesn't match Ceph's expectations. As of today, the current code was rejected removable devices but it was pretty hidden from the user, and implicit in the get_devices() function. This patch is creating a new is_valid() function to perform all the rejection tests and returns if this device can be used in the Ceph context or not. If is_valid() is returning False, the 'rejected_reasons' list reports all the reasons why that devices got rejected. Signed-off-by: Erwan Velu <erwan@redhat.com>
Diffstat (limited to 'src/ceph-volume/ceph_volume/tests')
-rw-r--r--src/ceph-volume/ceph_volume/tests/util/test_device.py12
-rw-r--r--src/ceph-volume/ceph_volume/tests/util/test_disk.py13
2 files changed, 12 insertions, 13 deletions
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 369beeef3a3..1e6766b45a3 100644
--- a/src/ceph-volume/ceph_volume/tests/util/test_device.py
+++ b/src/ceph-volume/ceph_volume/tests/util/test_device.py
@@ -150,6 +150,18 @@ class TestCephDiskDevice(object):
assert disk.is_member is True
+ def test_reject_removable_device(self, device_info):
+ data = {"/dev/sdb": {"removable": 1}}
+ device_info(devices=data)
+ disk = device.Device("/dev/sdb")
+ assert not disk.is_valid
+
+ def test_accept_non_removable_device(self, device_info):
+ data = {"/dev/sdb": {"removable": 0}}
+ device_info(devices=data)
+ disk = device.Device("/dev/sdb")
+ assert disk.is_valid
+
@pytest.mark.parametrize("label", ceph_partlabels)
def test_is_member_lsblk(self, device_info, label):
lsblk = {"PARTLABEL": label}
diff --git a/src/ceph-volume/ceph_volume/tests/util/test_disk.py b/src/ceph-volume/ceph_volume/tests/util/test_disk.py
index fd3839307e8..5d1bd82b602 100644
--- a/src/ceph-volume/ceph_volume/tests/util/test_disk.py
+++ b/src/ceph-volume/ceph_volume/tests/util/test_disk.py
@@ -220,19 +220,6 @@ class TestGetDevices(object):
assert result[dev_sda_path]['model'] == ''
assert result[dev_sda_path]['partitions'] == {}
- def test_sda_is_removable_gets_skipped(self, tmpfile, tmpdir):
- block_path, dev_path, mapper_path = self.setup_paths(tmpdir)
- dev_sda_path = os.path.join(dev_path, 'sda')
- block_sda_path = os.path.join(block_path, 'sda')
- os.makedirs(block_sda_path)
- os.makedirs(dev_sda_path)
-
- tmpfile('removable', contents='1', directory=block_sda_path)
- result = disk.get_devices(
- _sys_block_path=block_path,
- _dev_path=dev_path,
- _mapper_path=mapper_path)
- assert result == {}
def test_dm_device_is_not_used(self, monkeypatch, tmpdir):
# the link to the mapper is used instead