Fixes secure_boot capability
This patch fixes the `secure_boot` capability for Gen10 servers. Change-Id: I56de423106a9e9e8e2cbe93630b8b7981b1eb30f Closes-Bug: #1749076
This commit is contained in:
parent
19072b86d1
commit
3886a0235d
|
@ -665,9 +665,7 @@ class RedfishOperations(operations.IloOperations):
|
|||
('trusted_boot',
|
||||
(tpm_state == sys_cons.TPM_PRESENT_ENABLED
|
||||
or tpm_state == sys_cons.TPM_PRESENT_DISABLED)),
|
||||
('secure_boot',
|
||||
GET_SECUREBOOT_CURRENT_BOOT_MAP.get(
|
||||
sushy_system.secure_boot.current_boot)),
|
||||
('secure_boot', self._has_secure_boot()),
|
||||
('iscsi_boot',
|
||||
(sushy_system.bios_settings.iscsi_resource.
|
||||
is_iscsi_boot_supported())),
|
||||
|
@ -756,6 +754,13 @@ class RedfishOperations(operations.IloOperations):
|
|||
LOG.debug(self._("Secure boot is Disabled"))
|
||||
return secure_boot_enabled
|
||||
|
||||
def _has_secure_boot(self):
|
||||
try:
|
||||
self._get_sushy_system(PROLIANT_SYSTEM_ID).secure_boot
|
||||
except (exception.MissingAttributeError, sushy.exceptions.SushyError):
|
||||
return False
|
||||
return True
|
||||
|
||||
def set_secure_boot_mode(self, secure_boot_enable):
|
||||
"""Enable/Disable secure boot on the server.
|
||||
|
||||
|
|
|
@ -699,8 +699,8 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
sys_cons.SRIOV_ENABLED)
|
||||
type(get_system_mock.return_value.bios_settings).cpu_vt = (
|
||||
sys_cons.CPUVT_ENABLED)
|
||||
type(get_system_mock.return_value.secure_boot).current_boot = (
|
||||
sys_cons.SECUREBOOT_CURRENT_BOOT_ENABLED)
|
||||
type(get_system_mock.return_value).secure_boot = (
|
||||
mock.MagicMock(spec='Hey I am secure_boot'))
|
||||
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'
|
||||
|
@ -774,8 +774,8 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
sys_cons.SRIOV_DISABLED)
|
||||
type(get_system_mock.return_value.bios_settings).cpu_vt = (
|
||||
sys_cons.CPUVT_DISABLED)
|
||||
type(get_system_mock.return_value.secure_boot).current_boot = (
|
||||
sys_cons.SECUREBOOT_CURRENT_BOOT_DISABLED)
|
||||
type(get_system_mock.return_value).secure_boot = (
|
||||
mock.PropertyMock(side_effect=exception.MissingAttributeError))
|
||||
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'
|
||||
|
@ -901,6 +901,21 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
'information about secure boot on the server.',
|
||||
self.rf_client.get_secure_boot_mode)
|
||||
|
||||
def test__has_secure_boot(self):
|
||||
sushy_system_mock = self.sushy.get_system.return_value
|
||||
type(sushy_system_mock).secure_boot = mock.PropertyMock(
|
||||
return_value='Hey I am secure_boot')
|
||||
self.assertTrue(self.rf_client._has_secure_boot())
|
||||
|
||||
def test__has_secure_boot_on_fail(self):
|
||||
sushy_system_mock = self.sushy.get_system.return_value
|
||||
type(sushy_system_mock).secure_boot = mock.PropertyMock(
|
||||
side_effect=sushy.exceptions.SushyError)
|
||||
self.assertFalse(self.rf_client._has_secure_boot())
|
||||
type(sushy_system_mock).secure_boot = mock.PropertyMock(
|
||||
side_effect=exception.MissingAttributeError)
|
||||
self.assertFalse(self.rf_client._has_secure_boot())
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_is_boot_mode_uefi',
|
||||
autospec=True)
|
||||
def test_set_secure_boot_mode(self, _is_boot_mode_uefi_mock):
|
||||
|
|
Loading…
Reference in New Issue