Redfish: [Fix] Set pending boot mode json payload
This commit modifies 'set_pending_boot_mode' by adding new function for patch bios pending settings. Change-Id: I684bff82487b623dcc645a83024f8f23942a7876 Closes-bug: #1705632
This commit is contained in:
parent
ac0595ecf9
commit
fb81af18d7
|
@ -89,7 +89,7 @@ class BIOSSettings(base.ResourceBase):
|
||||||
|
|
||||||
def update_bios_to_default(self):
|
def update_bios_to_default(self):
|
||||||
"""Updates bios default settings"""
|
"""Updates bios default settings"""
|
||||||
self.pending_settings.update_bios_data(
|
self.pending_settings.update_bios_data_by_post(
|
||||||
self._get_base_configs().default_config)
|
self._get_base_configs().default_config)
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
|
@ -125,10 +125,10 @@ class BIOSPendingSettings(base.ResourceBase):
|
||||||
if boot_mode == sys_cons.BIOS_BOOT_MODE_UEFI:
|
if boot_mode == sys_cons.BIOS_BOOT_MODE_UEFI:
|
||||||
bios_properties['UefiOptimizedBoot'] = 'Enabled'
|
bios_properties['UefiOptimizedBoot'] = 'Enabled'
|
||||||
|
|
||||||
self._conn.patch(self.path, bios_properties)
|
self.update_bios_data_by_patch(bios_properties)
|
||||||
|
|
||||||
def update_bios_data(self, data):
|
def update_bios_data_by_post(self, data):
|
||||||
"""Update bios data
|
"""Update bios data by post
|
||||||
|
|
||||||
:param data: default bios config data
|
:param data: default bios config data
|
||||||
"""
|
"""
|
||||||
|
@ -137,6 +137,16 @@ class BIOSPendingSettings(base.ResourceBase):
|
||||||
}
|
}
|
||||||
self._conn.post(self.path, data=bios_settings_data)
|
self._conn.post(self.path, data=bios_settings_data)
|
||||||
|
|
||||||
|
def update_bios_data_by_patch(self, data):
|
||||||
|
"""Update bios data by patch
|
||||||
|
|
||||||
|
:param data: default bios config data
|
||||||
|
"""
|
||||||
|
bios_settings_data = {
|
||||||
|
'Attributes': data
|
||||||
|
}
|
||||||
|
self._conn.patch(self.path, data=bios_settings_data)
|
||||||
|
|
||||||
|
|
||||||
class BIOSBootSettings(base.ResourceBase):
|
class BIOSBootSettings(base.ResourceBase):
|
||||||
|
|
||||||
|
|
|
@ -201,21 +201,27 @@ class BIOSPendingSettingsTestCase(testtools.TestCase):
|
||||||
def test_set_pending_boot_mode_bios(self):
|
def test_set_pending_boot_mode_bios(self):
|
||||||
self.bios_settings_inst.set_pending_boot_mode(
|
self.bios_settings_inst.set_pending_boot_mode(
|
||||||
sys_cons.BIOS_BOOT_MODE_LEGACY_BIOS)
|
sys_cons.BIOS_BOOT_MODE_LEGACY_BIOS)
|
||||||
data = {}
|
data = {
|
||||||
data['BootMode'] = 'LegacyBios'
|
'Attributes': {
|
||||||
|
'BootMode': 'LegacyBios'
|
||||||
|
}
|
||||||
|
}
|
||||||
self.bios_settings_inst._conn.patch.assert_called_once_with(
|
self.bios_settings_inst._conn.patch.assert_called_once_with(
|
||||||
'/redfish/v1/Systems/1/bios/settings', data)
|
'/redfish/v1/Systems/1/bios/settings', data=data)
|
||||||
|
|
||||||
def test_set_pending_boot_mode_uefi(self):
|
def test_set_pending_boot_mode_uefi(self):
|
||||||
self.bios_settings_inst.set_pending_boot_mode(
|
self.bios_settings_inst.set_pending_boot_mode(
|
||||||
sys_cons.BIOS_BOOT_MODE_UEFI)
|
sys_cons.BIOS_BOOT_MODE_UEFI)
|
||||||
data = {}
|
data = {
|
||||||
data['UefiOptimizedBoot'] = 'Enabled'
|
'Attributes': {
|
||||||
data['BootMode'] = 'Uefi'
|
'BootMode': 'Uefi',
|
||||||
|
'UefiOptimizedBoot': 'Enabled'
|
||||||
|
}
|
||||||
|
}
|
||||||
self.bios_settings_inst._conn.patch.assert_called_once_with(
|
self.bios_settings_inst._conn.patch.assert_called_once_with(
|
||||||
'/redfish/v1/Systems/1/bios/settings', data)
|
'/redfish/v1/Systems/1/bios/settings', data=data)
|
||||||
|
|
||||||
def test_update_bios_data(self):
|
def test_update_bios_data_by_post(self):
|
||||||
with open('proliantutils/tests/redfish/'
|
with open('proliantutils/tests/redfish/'
|
||||||
'json_samples/bios_base_configs.json', 'r') as f:
|
'json_samples/bios_base_configs.json', 'r') as f:
|
||||||
bios_settings = json.loads(f.read())['BaseConfigs'][0]['default']
|
bios_settings = json.loads(f.read())['BaseConfigs'][0]['default']
|
||||||
|
@ -223,10 +229,22 @@ class BIOSPendingSettingsTestCase(testtools.TestCase):
|
||||||
data = {
|
data = {
|
||||||
'Attributes': bios_settings
|
'Attributes': bios_settings
|
||||||
}
|
}
|
||||||
self.bios_settings_inst.update_bios_data(bios_settings)
|
self.bios_settings_inst.update_bios_data_by_post(bios_settings)
|
||||||
self.bios_settings_inst._conn.post.assert_called_once_with(target_uri,
|
self.bios_settings_inst._conn.post.assert_called_once_with(target_uri,
|
||||||
data=data)
|
data=data)
|
||||||
|
|
||||||
|
def test_update_bios_data_by_patch(self):
|
||||||
|
with open('proliantutils/tests/redfish/'
|
||||||
|
'json_samples/bios_base_configs.json', 'r') as f:
|
||||||
|
bios_settings = json.loads(f.read())['BaseConfigs'][0]['default']
|
||||||
|
target_uri = '/redfish/v1/Systems/1/bios/settings'
|
||||||
|
data = {
|
||||||
|
'Attributes': bios_settings
|
||||||
|
}
|
||||||
|
self.bios_settings_inst.update_bios_data_by_patch(bios_settings)
|
||||||
|
self.bios_settings_inst._conn.patch.assert_called_once_with(target_uri,
|
||||||
|
data=data)
|
||||||
|
|
||||||
|
|
||||||
class BIOSBootSettingsTestCase(testtools.TestCase):
|
class BIOSBootSettingsTestCase(testtools.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -721,7 +721,7 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
||||||
self.rf_client.get_server_capabilities)
|
self.rf_client.get_server_capabilities)
|
||||||
|
|
||||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||||
@mock.patch.object(bios.BIOSPendingSettings, 'update_bios_data')
|
@mock.patch.object(bios.BIOSPendingSettings, 'update_bios_data_by_post')
|
||||||
def test_reset_bios_to_default(self, update_bios_mock, get_system_mock):
|
def test_reset_bios_to_default(self, update_bios_mock, get_system_mock):
|
||||||
with open('proliantutils/tests/redfish/'
|
with open('proliantutils/tests/redfish/'
|
||||||
'json_samples/system.json', 'r') as f:
|
'json_samples/system.json', 'r') as f:
|
||||||
|
|
Loading…
Reference in New Issue