diff --git a/ceph/utils.py b/ceph/utils.py index ee555e2..e6229c2 100644 --- a/ceph/utils.py +++ b/ceph/utils.py @@ -177,7 +177,7 @@ def unmounted_disks(): for device in context.list_devices(DEVTYPE='disk'): if device['SUBSYSTEM'] == 'block': matched = False - for block_type in [u'dm', u'loop', u'ram', u'nbd']: + for block_type in [u'dm-', u'loop', u'ram', u'nbd']: if block_type in device.device_node: matched = True if matched: diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index f049f71..1ddd7a9 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -515,14 +515,20 @@ class CephTestCase(unittest.TestCase): dev3 = MagicMock(spec=TestDevice) dev3.__getitem__.return_value = "block" dev3.device_node = '/dev/loop1' - devices = [dev1, dev2, dev3] + dev4 = MagicMock(spec=TestDevice) + dev4.__getitem__.return_value = "block" + dev4.device_node = '/dev/sdm' + dev5 = MagicMock(spec=TestDevice) + dev5.__getitem__.return_value = "block" + dev5.device_node = '/dev/dm-1' + devices = [dev1, dev2, dev3, dev4, dev5] with patch( 'pyudev.Context.list_devices', return_value=devices): with patch.object(utils, 'is_device_mounted', return_value=False): devices = utils.unmounted_disks() - self.assertEqual(devices, ['/dev/sda', '/dev/sdb']) + self.assertEqual(devices, ['/dev/sda', '/dev/sdb', '/dev/sdm']) with patch.object(utils, 'is_device_mounted', return_value=True): devices = utils.unmounted_disks()