Redfish: Adds get_essential_properties()
Change-Id: Ifdb31f9ec65350d03831c9cb16759d585401426c
This commit is contained in:
parent
7a01a4fd98
commit
8e8d261d9b
|
@ -794,3 +794,27 @@ class RedfishOperations(operations.IloOperations):
|
|||
msg = (self._('System is not in UEFI boot mode. "SecureBoot" '
|
||||
'related resources cannot be changed.'))
|
||||
raise exception.IloCommandNotSupportedInBiosError(msg)
|
||||
|
||||
def get_essential_properties(self):
|
||||
"""Constructs the dictionary of essential properties
|
||||
|
||||
Constructs the dictionary of essential properties, named
|
||||
cpu, cpu_arch, local_gb, memory_mb. The MACs are also returned
|
||||
as part of this method.
|
||||
"""
|
||||
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
|
||||
try:
|
||||
# TODO(nisha): Add local_gb here and return after
|
||||
# local_gb changes are merged.
|
||||
# local_gb = sushy_system.storage_summary
|
||||
prop = {'memory_mb': (sushy_system.memory_summary.size_gib * 1024),
|
||||
'cpus': sushy_system.processors.summary.count,
|
||||
'cpu_arch': sushy_system.processors.summary.architecture}
|
||||
return {'properties': prop,
|
||||
'macs': sushy_system.ethernet_interfaces.summary}
|
||||
except sushy.exceptions.SushyError as e:
|
||||
msg = (self._('The Redfish controller failed to get the '
|
||||
'resource data. Error %(error)s')
|
||||
% {'error': str(e)})
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
|
|
|
@ -928,3 +928,37 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
'The Redfish controller failed to clear secure boot keys '
|
||||
'on the server.',
|
||||
self.rf_client.clear_secure_boot_keys)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_essential_properties(self, get_system_mock):
|
||||
memory_mock = mock.PropertyMock(return_value=20)
|
||||
type(get_system_mock.return_value.memory_summary).size_gib = (
|
||||
memory_mock)
|
||||
count_mock = mock.PropertyMock(return_value=40)
|
||||
type(get_system_mock.return_value.processors.summary).count = (
|
||||
count_mock)
|
||||
arch_mock = mock.PropertyMock(return_value='x86 or x86-64')
|
||||
type(get_system_mock.return_value.processors.summary).architecture = (
|
||||
arch_mock)
|
||||
type(get_system_mock.return_value.ethernet_interfaces).summary = (
|
||||
{'1': '12:44:6A:3B:04:11'})
|
||||
# TODO(nisha): To add after local_gb changes merge.
|
||||
# type(get_system_mock.return_value).storage_summary = 600
|
||||
actual = self.rf_client.get_essential_properties()
|
||||
expected = {'properties': {'cpus': 40,
|
||||
'cpu_arch': 'x86 or x86-64',
|
||||
'memory_mb': 20480},
|
||||
'macs': {'1': '12:44:6A:3B:04:11'}}
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_essential_properties_fail(self, get_system_mock):
|
||||
memory_mock = mock.PropertyMock(
|
||||
side_effect=sushy.exceptions.SushyError)
|
||||
type(get_system_mock.return_value.memory_summary).size_gib = (
|
||||
memory_mock)
|
||||
self.assertRaisesRegex(
|
||||
exception.IloError,
|
||||
"The Redfish controller failed to get the "
|
||||
"resource data. Error None",
|
||||
self.rf_client.get_essential_properties)
|
||||
|
|
Loading…
Reference in New Issue