Redfish: Adds server capabilities

This commit adds the following server capabilities
   1)ilo_firmware_version
   2)rom_firmware_version
   3)server_model

Change-Id: Ia6ab3937af33cc6789b95603d09ce088f30ceb25
This commit is contained in:
ankit 2017-07-19 08:39:14 +00:00
parent ff36d7d7d5
commit df11e21349
6 changed files with 57 additions and 16 deletions

View File

@ -179,7 +179,7 @@ class RedfishOperations(operations.IloOperations):
:raises: IloError, on an error from iLO.
"""
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
return sushy_system.json.get('Model')
return sushy_system.model
def get_host_power_status(self):
"""Request the power state of the server.
@ -608,17 +608,22 @@ class RedfishOperations(operations.IloOperations):
capabilities = {}
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
sushy_manager = self._get_sushy_manager(PROLIANT_MANAGER_ID)
try:
count = len(sushy_system.pci_devices.gpu_devices)
capabilities.update({'pci_gpu_devices': count})
capabilities.update(
{'pci_gpu_devices': count,
'ilo_firmware_version': sushy_manager.firmware_version,
'rom_firmware_version': sushy_system.rom_version,
'server_model': sushy_system.model})
capabilities.update(
{key: 'true'
for (key, value) in ((
'sriov_enabled',
sushy_system.bios_settings.sriov == sys_cons.SRIOV_ENABLED
),)})
),)
if value})
except sushy.exceptions.SushyError as e:
msg = (self._("The Redfish controller is unable to get "
"resource or its members. Error "
@ -632,8 +637,8 @@ class RedfishOperations(operations.IloOperations):
:raises: IloError, on an error from iLO.
"""
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
try:
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
sushy_system.bios_settings.update_bios_to_default()
except sushy.exceptions.SushyError as e:
msg = (self._("The Redfish controller is unable to update bios "

View File

@ -18,6 +18,7 @@ from sushy.resources import base
class HPEAccount(base.ResourceBase):
"""Class that defines the functionality for Account."""
username = base.Field('UserName')
@ -33,6 +34,7 @@ class HPEAccount(base.ResourceBase):
class HPEAccountCollection(base.ResourceCollectionBase):
"""Class that defines the functionality for AccountCollection."""
@property
def _resource_type(self):

View File

@ -76,7 +76,7 @@ class BIOSSettings(base.ResourceBase):
return self._boot_settings
def _get_base_configs(self):
"""Property to provide reference to bios settings instance"""
"""Method that returns object of bios base configs."""
if self._base_configs is None:
self._base_configs = BIOSBaseConfigs(
self._conn, utils.get_subresource_path_by(
@ -105,7 +105,7 @@ class BIOSBaseConfigs(base.ResourceBase):
class BIOSPendingSettings(base.ResourceBase):
"""Class that defines the functionality for BIOS settings."""
"""Class that defines the functionality for BIOS pending settings."""
boot_mode = base.MappedField(["Attributes", "BootMode"],
mappings.GET_BIOS_BOOT_MODE_MAP)
@ -133,7 +133,7 @@ class BIOSPendingSettings(base.ResourceBase):
bios_settings_data = {
'Attributes': data
}
self._conn.post(self.path, bios_settings_data)
self._conn.post(self.path, data=bios_settings_data)
class BIOSBootSettings(base.ResourceBase):

View File

@ -56,6 +56,9 @@ class HPESystem(system.System):
from sushy
"""
model = base.Field(['Model'])
rom_version = base.Field(['Oem', 'Hpe', 'Bios', 'Current',
'VersionString'])
_hpe_actions = HpeActionsField(['Oem', 'Hpe', 'Actions'], required=True)
"""Oem specific system extensibility actions"""

View File

@ -225,7 +225,7 @@ class BIOSPendingSettingsTestCase(testtools.TestCase):
}
self.bios_settings_inst.update_bios_data(bios_settings)
self.bios_settings_inst._conn.post.assert_called_once_with(target_uri,
data)
data=data)
class BIOSBootSettingsTestCase(testtools.TestCase):

View File

@ -78,11 +78,10 @@ class RedfishOperationsTestCase(testtools.TestCase):
'The Redfish Manager "banana" was not found.',
self.rf_client._get_sushy_manager, 'banana')
def test_get_product_name(self):
with open('proliantutils/tests/redfish/'
'json_samples/system.json', 'r') as f:
system_json = json.loads(f.read())
self.sushy.get_system().json = system_json['default']
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
def test_get_product_name(self, get_system_mock):
product_mock = mock.PropertyMock(return_value='ProLiant DL180 Gen10')
type(get_system_mock.return_value).model = product_mock
product_name = self.rf_client.get_product_name()
self.assertEqual('ProLiant DL180 Gen10', product_name)
@ -650,7 +649,8 @@ class RedfishOperationsTestCase(testtools.TestCase):
self.rf_client.reset_ilo_credential, 'fake-password')
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
def test_get_server_capabilities(self, get_system_mock):
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_manager')
def test_get_server_capabilities(self, get_manager_mock, get_system_mock):
val = []
path = ('proliantutils/tests/redfish/json_samples/'
'pci_device.json')
@ -660,8 +660,39 @@ class RedfishOperationsTestCase(testtools.TestCase):
[mock.MagicMock(spec=pci_device.PCIDevice)])
type(get_system_mock.return_value.bios_settings).sriov = (
sys_cons.SRIOV_ENABLED)
type(get_system_mock.return_value).rom_version = (
'U31 v1.00 (03/11/2017)')
type(get_manager_mock.return_value).firmware_version = 'iLO 5 v1.15'
type(get_system_mock.return_value).model = 'ProLiant DL180 Gen10'
actual = self.rf_client.get_server_capabilities()
expected = {'pci_gpu_devices': 1, 'sriov_enabled': 'true'}
expected = {'pci_gpu_devices': 1, 'sriov_enabled': 'true',
'rom_firmware_version': 'U31 v1.00 (03/11/2017)',
'ilo_firmware_version': 'iLO 5 v1.15',
'server_model': 'ProLiant DL180 Gen10'}
self.assertEqual(expected, actual)
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_manager')
def test_get_server_capabilities_optional_capabilities_absent(
self, get_manager_mock, get_system_mock):
val = []
path = ('proliantutils/tests/redfish/json_samples/'
'pci_device.json')
with open(path, 'r') as f:
val.append(json.loads(f.read()))
type(get_system_mock.return_value.pci_devices).gpu_devices = (
[mock.MagicMock(spec=pci_device.PCIDevice)])
type(get_system_mock.return_value.bios_settings).sriov = (
sys_cons.SRIOV_DISABLED)
type(get_system_mock.return_value).rom_version = (
'U31 v1.00 (03/11/2017)')
type(get_manager_mock.return_value).firmware_version = 'iLO 5 v1.15'
type(get_system_mock.return_value).model = 'ProLiant DL180 Gen10'
actual = self.rf_client.get_server_capabilities()
expected = {'pci_gpu_devices': 1,
'rom_firmware_version': 'U31 v1.00 (03/11/2017)',
'ilo_firmware_version': 'iLO 5 v1.15',
'server_model': 'ProLiant DL180 Gen10'}
self.assertEqual(expected, actual)
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')