Fix getting RAID configuration for iRMC S5
In case of iRMC S5, there is no key named 'LogicalDrives' with no RAID configuration. This patch changes to use ".get()" for this key. Change-Id: Ia2de9d2025d317ff0fa87d9b82a9783e73874f05
This commit is contained in:
parent
eb3c658fc4
commit
4585ce2f76
|
@ -1014,7 +1014,7 @@ def create_raid_configuration(irmc_info, target_raid_config):
|
|||
# create new RAID config.
|
||||
raid_adapter = get_raid_adapter(irmc_info)
|
||||
logical_drives = raid_adapter['Server']['HWConfigurationIrmc'][
|
||||
'Adapters']['RAIDAdapter'][0]['LogicalDrives']
|
||||
'Adapters']['RAIDAdapter'][0].get('LogicalDrives')
|
||||
session_timeout = irmc_info.get('irmc_raid_session_timeout',
|
||||
RAID_CONFIG_SESSION_TIMEOUT)
|
||||
if logical_drives is not None:
|
||||
|
|
|
@ -1152,6 +1152,76 @@ class ELCMTestCase(testtools.TestCase):
|
|||
restore_bios_config_mock.assert_called_once_with(
|
||||
irmc_info=self.irmc_info, bios_config=bios_config_data)
|
||||
|
||||
@mock.patch.object(elcm, 'get_raid_adapter')
|
||||
@mock.patch.object(elcm, 'elcm_profile_set')
|
||||
@mock.patch.object(elcm, '_process_session_data')
|
||||
def test_create_raid_config_without_logical_drives(
|
||||
self, session_mock, elcm_profile_set_mock, raid_info_mock):
|
||||
elcm_profile_set_mock.return_value = {
|
||||
"Session": {
|
||||
"Id": 1,
|
||||
"A_Param": "abc123"
|
||||
}
|
||||
}
|
||||
session_id = 1
|
||||
session_timeout = 1800
|
||||
operation = 'CONFIG_RAID'
|
||||
|
||||
target_raid_config = {
|
||||
'logical_disks': [
|
||||
{
|
||||
'size_gb': 100,
|
||||
'raid_level': '1',
|
||||
}
|
||||
]
|
||||
}
|
||||
expected_input = {
|
||||
'Server': {
|
||||
'HWConfigurationIrmc': {
|
||||
'@Processing': 'execute',
|
||||
'Adapters': {
|
||||
'RAIDAdapter': [
|
||||
{
|
||||
'Arrays': {
|
||||
'Array': []
|
||||
},
|
||||
'LogicalDrives': {
|
||||
'LogicalDrive': [
|
||||
{
|
||||
'@Number': 0,
|
||||
'@Action': 'Create',
|
||||
'RaidLevel': '1',
|
||||
'InitMode': 'slow',
|
||||
'Size': {
|
||||
'@Unit': 'GB',
|
||||
'#text': 100
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
'@Version': '1.00'
|
||||
},
|
||||
'@Version': '1.01'
|
||||
}
|
||||
}
|
||||
# In case of "LogicalDrives" doesn't exist
|
||||
del self.raid_info['Server']['HWConfigurationIrmc'][
|
||||
'Adapters']['RAIDAdapter'][0]['LogicalDrives']
|
||||
raid_info_mock.return_value = self.raid_info
|
||||
|
||||
elcm.create_raid_configuration(
|
||||
self.irmc_info, target_raid_config=target_raid_config)
|
||||
|
||||
session_mock.assert_called_once_with(self.irmc_info, operation,
|
||||
session_id, session_timeout)
|
||||
# Check raid_input data
|
||||
raid_info_mock.assert_called_once_with(self.irmc_info)
|
||||
elcm_profile_set_mock.assert_called_once_with(
|
||||
self.irmc_info, expected_input)
|
||||
|
||||
@mock.patch.object(elcm, 'get_raid_adapter')
|
||||
@mock.patch.object(elcm, 'elcm_profile_set')
|
||||
@mock.patch.object(elcm, '_process_session_data')
|
||||
|
|
Loading…
Reference in New Issue