Merge "Include empty devices when listing block devices"
This commit is contained in:
@@ -265,7 +265,7 @@ def list_all_block_devices(block_type='disk',
|
|||||||
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
|
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
|
||||||
|
|
||||||
columns = ['KNAME', 'MODEL', 'SIZE', 'ROTA', 'TYPE']
|
columns = ['KNAME', 'MODEL', 'SIZE', 'ROTA', 'TYPE']
|
||||||
report = utils.execute('lsblk', '-Pbi', '-o{}'.format(','.join(columns)),
|
report = utils.execute('lsblk', '-Pbia', '-o{}'.format(','.join(columns)),
|
||||||
check_exit_code=[0])[0]
|
check_exit_code=[0])[0]
|
||||||
lines = report.splitlines()
|
lines = report.splitlines()
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
@@ -289,10 +289,12 @@ def list_all_block_devices(block_type='disk',
|
|||||||
# Other possible type values, which we skip recording:
|
# Other possible type values, which we skip recording:
|
||||||
# lvm, part, rom, loop
|
# lvm, part, rom, loop
|
||||||
if devtype != block_type:
|
if devtype != block_type:
|
||||||
if devtype is not None and 'raid' in devtype and not ignore_raid:
|
if (devtype is not None and
|
||||||
|
any(x in devtype for x in ['raid', 'md']) and
|
||||||
|
not ignore_raid):
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"TYPE detected to contain 'raid', signifying a RAID "
|
"TYPE detected to contain 'raid or 'md', signifying a "
|
||||||
"volume. Found: {!r}".format(line))
|
"RAID volume. Found: {!r}".format(line))
|
||||||
else:
|
else:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"TYPE did not match. Wanted: {!r} but found: {!r}".format(
|
"TYPE did not match. Wanted: {!r} but found: {!r}".format(
|
||||||
@@ -338,7 +340,7 @@ def list_all_block_devices(block_type='disk',
|
|||||||
|
|
||||||
devices.append(BlockDevice(name=name,
|
devices.append(BlockDevice(name=name,
|
||||||
model=device['MODEL'],
|
model=device['MODEL'],
|
||||||
size=int(device['SIZE']),
|
size=int(device['SIZE'] or 0),
|
||||||
rotational=bool(int(device['ROTA'])),
|
rotational=bool(int(device['ROTA'])),
|
||||||
vendor=_get_device_info(device['KNAME'],
|
vendor=_get_device_info(device['KNAME'],
|
||||||
'block', 'vendor'),
|
'block', 'vendor'),
|
||||||
|
|||||||
@@ -1103,7 +1103,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = (BLK_DEVICE_TEMPLATE, '')
|
mocked_execute.return_value = (BLK_DEVICE_TEMPLATE, '')
|
||||||
self.assertEqual('/dev/sdb', self.hardware.get_os_install_device())
|
self.assertEqual('/dev/sdb', self.hardware.get_os_install_device())
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbi', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
mock_cached_node.assert_called_once_with()
|
mock_cached_node.assert_called_once_with()
|
||||||
|
|
||||||
@@ -1125,7 +1125,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
# should always be smaller
|
# should always be smaller
|
||||||
self.assertEqual('/dev/md0', self.hardware.get_os_install_device())
|
self.assertEqual('/dev/md0', self.hardware.get_os_install_device())
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbi', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
mock_cached_node.assert_called_once_with()
|
mock_cached_node.assert_called_once_with()
|
||||||
|
|
||||||
@@ -1144,7 +1144,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
ex = self.assertRaises(errors.DeviceNotFound,
|
ex = self.assertRaises(errors.DeviceNotFound,
|
||||||
self.hardware.get_os_install_device)
|
self.hardware.get_os_install_device)
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbi', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
self.assertIn(str(4 * units.Gi), ex.details)
|
self.assertIn(str(4 * units.Gi), ex.details)
|
||||||
mock_cached_node.assert_called_once_with()
|
mock_cached_node.assert_called_once_with()
|
||||||
@@ -3051,7 +3051,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = (BLK_DEVICE_TEMPLATE_SMALL, '')
|
mocked_execute.return_value = (BLK_DEVICE_TEMPLATE_SMALL, '')
|
||||||
result = hardware.list_all_block_devices()
|
result = hardware.list_all_block_devices()
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbi', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
self.assertEqual(BLK_DEVICE_TEMPLATE_SMALL_DEVICES, result)
|
self.assertEqual(BLK_DEVICE_TEMPLATE_SMALL_DEVICES, result)
|
||||||
mocked_udev.assert_called_once_with()
|
mocked_udev.assert_called_once_with()
|
||||||
@@ -3070,7 +3070,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = (RAID_BLK_DEVICE_TEMPLATE, '')
|
mocked_execute.return_value = (RAID_BLK_DEVICE_TEMPLATE, '')
|
||||||
result = hardware.list_all_block_devices()
|
result = hardware.list_all_block_devices()
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbi', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
self.assertEqual(RAID_BLK_DEVICE_TEMPLATE_DEVICES, result)
|
self.assertEqual(RAID_BLK_DEVICE_TEMPLATE_DEVICES, result)
|
||||||
mocked_udev.assert_called_once_with()
|
mocked_udev.assert_called_once_with()
|
||||||
@@ -3083,7 +3083,7 @@ class TestModuleFunctions(base.IronicAgentTest):
|
|||||||
mocked_execute.return_value = ('TYPE="foo" MODEL="model"', '')
|
mocked_execute.return_value = ('TYPE="foo" MODEL="model"', '')
|
||||||
result = hardware.list_all_block_devices()
|
result = hardware.list_all_block_devices()
|
||||||
mocked_execute.assert_called_once_with(
|
mocked_execute.assert_called_once_with(
|
||||||
'lsblk', '-Pbi', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE',
|
||||||
check_exit_code=[0])
|
check_exit_code=[0])
|
||||||
self.assertEqual([], result)
|
self.assertEqual([], result)
|
||||||
mocked_udev.assert_called_once_with()
|
mocked_udev.assert_called_once_with()
|
||||||
|
|||||||
Reference in New Issue
Block a user