Add 'sriov_enabled' capability

This commits adds 'sriov_enabled' capability
for redfish and ris.

Change-Id: Iade847df6257096db2ca4101b02537f994aae073
This commit is contained in:
Aparna 2017-07-13 16:06:04 +00:00
parent 699bc6879c
commit a999200227
8 changed files with 49 additions and 8 deletions

View File

@ -959,6 +959,10 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
except Exception:
return None
def _is_sriov_enabled(self):
"""Return sriov enabled or not"""
return (self._get_bios_setting('Sriov') == 'Enabled')
def get_server_capabilities(self):
"""Gets server properties which can be used for scheduling
@ -989,6 +993,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
# If an error is raised dont populate the capability
# secure_boot
pass
if self._is_sriov_enabled():
capabilities['sriov_enabled'] = 'true'
return capabilities
def activate_license(self, key):

View File

@ -597,16 +597,25 @@ class RedfishOperations(operations.IloOperations):
def get_server_capabilities(self):
"""Returns the server capabilities
:raises: IloError if any Sushy error is encountered.
raises: IloError on an error from iLO.
"""
capabilities = {}
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
try:
count = len(sushy_system.pci_devices.gpu_devices)
capabilities.update({'pci_gpu_devices': count})
capabilities.update(
{key: 'true'
for (key, value) in ((
'sriov_enabled',
sushy_system.bios_settings.sriov == sys_cons.SRIOV_ENABLED
),)})
except sushy.exceptions.SushyError as e:
msg = (self._("The Redfish controller is unable to get "
"resource or its members. Error"
"resource or its members. Error "
"%(error)s)") % {'error': str(e)})
LOG.debug(msg)
raise exception.IloError(msg)

View File

@ -36,6 +36,9 @@ class BIOSSettings(base.ResourceBase):
boot_mode = base.MappedField(["Attributes", "BootMode"],
mappings.GET_BIOS_BOOT_MODE_MAP)
sriov = base.MappedField(['Attributes', 'Sriov'], mappings.SRIOV_MAP)
_pending_settings = None
_boot_settings = None
_base_configs = None

View File

@ -30,3 +30,8 @@ BOOT_SOURCE_TARGET_CD = 'Cd'
BOOT_SOURCE_TARGET_PXE = 'Pxe'
BOOT_SOURCE_TARGET_UEFI_TARGET = 'UefiTarget'
BOOT_SOURCE_TARGET_HDD = 'Hdd'
# BIOS Sriov constants
SRIOV_ENABLED = 'sriov enabled'
SRIOV_DISABLED = 'sriov disabled'

View File

@ -34,3 +34,10 @@ GET_BIOS_BOOT_MODE_MAP = {
GET_BIOS_BOOT_MODE_MAP_REV = (
utils.revert_dictionary(GET_BIOS_BOOT_MODE_MAP))
# BIOS Sriov mappings
SRIOV_MAP = {
'Enabled': constants.SRIOV_ENABLED,
'Disabled': constants.SRIOV_DISABLED
}

View File

@ -375,6 +375,7 @@ class IloRisTestCase(testtools.TestCase):
validate_mock.assert_called_once_with(ris_outputs.GET_HEADERS,
settings_uri)
@mock.patch.object(ris.RISOperations, '_get_bios_setting')
@mock.patch.object(ris.RISOperations, '_get_nvdimm_n_status')
@mock.patch.object(ris.RISOperations,
'_get_cpu_virtualization')
@ -386,7 +387,8 @@ class IloRisTestCase(testtools.TestCase):
@mock.patch.object(ris.RISOperations, '_get_host_details')
def test_get_server_capabilities(self, get_details_mock, ilo_firm_mock,
secure_mock, gpu_mock, tpm_mock,
cpu_vt_mock, nvdimm_n_mock):
cpu_vt_mock, nvdimm_n_mock,
bios_sriov_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'}
@ -395,6 +397,7 @@ class IloRisTestCase(testtools.TestCase):
secure_mock.return_value = False
nvdimm_n_mock.return_value = True
tpm_mock.return_value = True
bios_sriov_mock.return_value = 'Disabled'
expected_caps = {'secure_boot': 'true',
'ilo_firmware_version': 'iLO 4 v2.20',
'rom_firmware_version': u'I36 v1.40 (01/28/2015)',
@ -406,6 +409,7 @@ class IloRisTestCase(testtools.TestCase):
capabilities = self.client.get_server_capabilities()
self.assertEqual(expected_caps, capabilities)
@mock.patch.object(ris.RISOperations, '_get_bios_setting')
@mock.patch.object(ris.RISOperations, '_get_nvdimm_n_status')
@mock.patch.object(ris.RISOperations,
'_get_cpu_virtualization')
@ -419,7 +423,8 @@ class IloRisTestCase(testtools.TestCase):
get_details_mock,
ilo_firm_mock, secure_mock,
gpu_mock, tpm_mock,
cpu_vt_mock, nvdimm_n_mock):
cpu_vt_mock, nvdimm_n_mock,
bios_sriov_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'}
@ -428,13 +433,15 @@ class IloRisTestCase(testtools.TestCase):
nvdimm_n_mock.return_value = True
tpm_mock.return_value = False
cpu_vt_mock.return_value = True
bios_sriov_mock.return_value = 'Enabled'
expected_caps = {'secure_boot': 'true',
'ilo_firmware_version': 'iLO 4 v2.20',
'rom_firmware_version': u'I36 v1.40 (01/28/2015)',
'server_model': u'ProLiant BL460c Gen9',
'pci_gpu_devices': 2,
'cpu_vt': 'true',
'nvdimm_n': 'true'}
'nvdimm_n': 'true',
'sriov_enabled': 'true'}
capabilities = self.client.get_server_capabilities()
self.assertEqual(expected_caps, capabilities)

View File

@ -41,6 +41,8 @@ class BIOSSettingsTestCase(testtools.TestCase):
def test_attributes(self):
self.assertEqual(sys_cons.BIOS_BOOT_MODE_UEFI,
self.bios_inst.boot_mode)
self.assertEqual(sys_cons.SRIOV_ENABLED,
self.bios_inst.sriov)
def test_pending_settings(self):
self.assertIsNone(self.bios_inst._pending_settings)

View File

@ -28,6 +28,7 @@ from proliantutils.redfish.resources.manager import manager
from proliantutils.redfish.resources.manager import virtual_media
from proliantutils.redfish.resources.system import bios
from proliantutils.redfish.resources.system import constants as sys_cons
from proliantutils.redfish.resources.system import pci_device
from proliantutils.redfish.resources.system import system as pro_sys
from sushy.resources.system import system
@ -655,11 +656,12 @@ class RedfishOperationsTestCase(testtools.TestCase):
'pci_device.json')
with open(path, 'r') as f:
val.append(json.loads(f.read()))
gpu_mock = mock.PropertyMock(return_value=val)
type(get_system_mock.return_value.pci_devices).gpu_devices = (
gpu_mock)
[mock.MagicMock(spec=pci_device.PCIDevice)])
type(get_system_mock.return_value.bios_settings).sriov = (
sys_cons.SRIOV_ENABLED)
actual = self.rf_client.get_server_capabilities()
expected = {'pci_gpu_devices': 1}
expected = {'pci_gpu_devices': 1, 'sriov_enabled': 'true'}
self.assertEqual(expected, actual)
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')