Merge "Software RAID: Trigger grub installation on the holder disks"

This commit is contained in:
Zuul 2019-06-06 01:11:06 +00:00 committed by Gerrit Code Review
commit 91e5a145f2
2 changed files with 46 additions and 2 deletions

View File

@ -775,8 +775,24 @@ class AgentDeployMixin(HeartbeatMixin):
"""
node = task.node
LOG.debug('Configuring local boot for node %s', node.uuid)
if not node.driver_internal_info.get(
'is_whole_disk_image') and root_uuid:
# If the target RAID configuration is set to 'software' for the
# 'controller', we need to trigger the installation of grub on
# the holder disks of the desired Software RAID.
internal_info = node.driver_internal_info
raid_config = node.target_raid_config
logical_disks = raid_config.get('logical_disks', [])
software_raid = False
for logical_disk in logical_disks:
if logical_disk['controller'] == 'software':
LOG.debug('Node %s has a Software RAID configuration',
node.uuid)
software_raid = True
root_uuid = internal_info.get('root_uuid_or_disk_id')
break
whole_disk_image = internal_info.get('is_whole_disk_image')
if software_raid or (root_uuid and not whole_disk_image):
LOG.debug('Installing the bootloader for node %(node)s on '
'partition %(part)s, EFI system partition %(efi)s',
{'node': node.uuid, 'part': root_uuid,

View File

@ -1035,6 +1035,34 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest):
try_set_boot_device_mock.assert_called_once_with(
task, boot_devices.DISK, persistent=True)
@mock.patch.object(deploy_utils, 'try_set_boot_device', autospec=True)
@mock.patch.object(agent_client.AgentClient, 'install_bootloader',
autospec=True)
def test_configure_local_boot_on_software_raid(
self, install_bootloader_mock, try_set_boot_device_mock):
with task_manager.acquire(self.context, self.node['uuid'],
shared=False) as task:
task.node.driver_internal_info['is_whole_disk_image'] = True
task.node.target_raid_config = {
"logical_disks": [
{
"size_gb": 100,
"raid_level": "1",
"controller": "software",
},
{
"size_gb": 'MAX',
"raid_level": "0",
"controller": "software",
}
]
}
self.deploy.configure_local_boot(task)
self.assertTrue(install_bootloader_mock.called)
try_set_boot_device_mock.assert_called_once_with(
task, boot_devices.DISK, persistent=True)
@mock.patch.object(deploy_utils, 'try_set_boot_device', autospec=True)
@mock.patch.object(agent_client.AgentClient, 'install_bootloader',
autospec=True)