Support to get hardware raid support

This commit adds support to get raid support
on a bare metal.

Change-Id: I4307a1003202ace6b153de69b04e0bd8f0616e07
This commit is contained in:
Aparna 2017-01-19 11:32:29 +00:00
parent f885f47e2d
commit 5cae90ec8e
3 changed files with 66 additions and 3 deletions

View File

@ -443,6 +443,20 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
raid_level.update({raid_level_var: 'true'})
return raid_level if len(raid_level.keys()) > 0 else None
def _is_raid_supported(self):
"""Get the RAID support on the server.
This method returns the raid support on the physical server. It
checks for the list of array controllers configured to the Smart
Storage. If one or more array controllers available then raid
is supported by the server. If none, raid is not supported.
:return: Raid support as a dictionary with true/false as its value.
"""
header, uri, array_resource = self._get_array_controller_resource()
return True if array_resource['Total'] > 0 else False
def _get_bios_settings_resource(self, data):
"""Get the BIOS settings resource."""
try:
@ -1177,6 +1191,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
raid_details = self._get_logical_raid_levels()
if raid_details is not None:
capabilities.update(raid_details)
if self._is_raid_supported():
capabilities['raid_support'] = 'true'
boot_modes = common.get_supported_boot_modes(
self.get_supported_boot_mode())
capabilities.update({

View File

@ -4179,3 +4179,25 @@ LogicalDrives/1"
}
}]
"""
ARRAY_SETTING_NO_CONTROLLER = """
{
"@odata.context": "/redfish/v1/$metadata#Systems/Members/1\
/SmartStorage/ArrayControllers",
"@odata.id": "/redfish/v1/Systems/1/SmartStorage/ArrayControllers/",
"@odata.type": "#HpSmartStorageArrayControllerCollection.\
1.0.0.HpSmartStorageArrayControllerCollection",
"Description": "HP Smart Storage Array Controllers View",
"MemberType": "HpSmartStorageArrayController.1",
"Members@odata.count": 0,
"Name": "HpSmartStorageArrayControllers",
"Total": 0,
"Type": "Collection.0.9.5",
"links": {
"self": {
"href": "/rest/v1/Systems/1/SmartStorage/\
ArrayControllers"
}
}
}
"""

View File

@ -437,6 +437,7 @@ class IloRisTestCase(testtools.TestCase):
validate_mock.assert_called_once_with(ris_outputs.GET_HEADERS,
settings_uri)
@mock.patch.object(ris.RISOperations, '_is_raid_supported')
@mock.patch.object(ris.RISOperations, '_get_logical_raid_levels')
@mock.patch.object(ris.RISOperations, '_get_drive_type_and_speed')
@mock.patch.object(ris.RISOperations, '_check_iscsi_rest_patch_allowed')
@ -455,7 +456,7 @@ class IloRisTestCase(testtools.TestCase):
secure_mock, boot_mode_mock, gpu_mock,
tpm_mock, cpu_vt_mock, nvdimm_n_mock,
bios_sriov_mock, iscsi_boot_mock,
drive_mock, raid_mock):
drive_mock, raid_mock, raid_support_mock):
host_details = json.loads(ris_outputs.RESPONSE_BODY_FOR_REST_OP)
get_details_mock.return_value = host_details
ilo_firm_mock.return_value = {'ilo_firmware_version': 'iLO 4 v2.20'}
@ -471,6 +472,7 @@ class IloRisTestCase(testtools.TestCase):
drive_mock.return_value = {'has_rotational': True,
'rotational_drive_4800_rpm': True}
raid_mock.return_value = {'logical_raid_volume_0': 'true'}
raid_support_mock.return_value = True
expected_caps = {'secure_boot': 'true',
'ilo_firmware_version': 'iLO 4 v2.20',
'rom_firmware_version': u'I36 v1.40 (01/28/2015)',
@ -484,10 +486,12 @@ class IloRisTestCase(testtools.TestCase):
'iscsi_boot': 'true',
'has_rotational': True,
'rotational_drive_4800_rpm': True,
'logical_raid_volume_0': 'true'}
'logical_raid_volume_0': 'true',
'raid_support': 'true'}
capabilities = self.client.get_server_capabilities()
self.assertEqual(expected_caps, capabilities)
@mock.patch.object(ris.RISOperations, '_is_raid_supported')
@mock.patch.object(ris.RISOperations, '_get_logical_raid_levels')
@mock.patch.object(ris.RISOperations, '_get_drive_type_and_speed')
@mock.patch.object(ris.RISOperations, '_check_iscsi_rest_patch_allowed')
@ -505,7 +509,7 @@ class IloRisTestCase(testtools.TestCase):
def test_get_server_capabilities_tp_absent(
self, get_details_mock, ilo_firm_mock, secure_mock, boot_mode_mock,
gpu_mock, tpm_mock, cpu_vt_mock, nvdimm_n_mock, bios_sriov_mock,
iscsi_mock, drive_mock, raid_mock):
iscsi_mock, drive_mock, raid_mock, raid_support_mock):
host_details = json.loads(ris_outputs.RESPONSE_BODY_FOR_REST_OP)
get_details_mock.return_value = host_details
ilo_firm_mock.return_value = {'ilo_firmware_version': 'iLO 4 v2.20'}
@ -521,6 +525,7 @@ class IloRisTestCase(testtools.TestCase):
drive_mock.return_value = {'has_rotational': True,
'rotational_drive_4800_rpm': True}
raid_mock.return_value = {'logical_raid_volume_0': 'true'}
raid_support_mock.return_value = False
expected_caps = {'secure_boot': 'true',
'ilo_firmware_version': 'iLO 4 v2.20',
'rom_firmware_version': u'I36 v1.40 (01/28/2015)',
@ -2135,3 +2140,23 @@ class TestRISOperationsPrivateMethods(testtools.TestCase):
nvdimm_n_status_return = self.client._get_nvdimm_n_status()
self.assertEqual(nvdimm_n_status_return, expected_nvdimm_n_status)
self.assertTrue(bios_mock.called)
@mock.patch.object(ris.RISOperations, '_get_array_controller_resource')
def test__is_raid_supported(self, get_array_mock):
array_settings = json.loads(ris_outputs.ARRAY_SETTINGS)
get_array_mock.return_value = (200, ris_outputs.GET_HEADERS,
array_settings)
expt_ret = True
ret = self.client._is_raid_supported()
self.assertEqual(ret, expt_ret)
get_array_mock.assert_called_once_with()
@mock.patch.object(ris.RISOperations, '_get_array_controller_resource')
def test__is_raid_supported_false(self, get_array_mock):
array_settings = json.loads(ris_outputs.ARRAY_SETTING_NO_CONTROLLER)
get_array_mock.return_value = (200, ris_outputs.GET_HEADERS,
array_settings)
expt_ret = False
ret = self.client._is_raid_supported()
self.assertEqual(ret, expt_ret)
get_array_mock.assert_called_once_with()