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:
kesper 2017-07-21 06:09:17 +00:00
parent ac0595ecf9
commit fb81af18d7
3 changed files with 42 additions and 14 deletions

View File

@ -89,7 +89,7 @@ class BIOSSettings(base.ResourceBase):
def update_bios_to_default(self):
"""Updates bios default settings"""
self.pending_settings.update_bios_data(
self.pending_settings.update_bios_data_by_post(
self._get_base_configs().default_config)
def refresh(self):
@ -125,10 +125,10 @@ class BIOSPendingSettings(base.ResourceBase):
if boot_mode == sys_cons.BIOS_BOOT_MODE_UEFI:
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):
"""Update bios data
def update_bios_data_by_post(self, data):
"""Update bios data by post
:param data: default bios config data
"""
@ -137,6 +137,16 @@ class BIOSPendingSettings(base.ResourceBase):
}
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):

View File

@ -201,21 +201,27 @@ class BIOSPendingSettingsTestCase(testtools.TestCase):
def test_set_pending_boot_mode_bios(self):
self.bios_settings_inst.set_pending_boot_mode(
sys_cons.BIOS_BOOT_MODE_LEGACY_BIOS)
data = {}
data['BootMode'] = 'LegacyBios'
data = {
'Attributes': {
'BootMode': 'LegacyBios'
}
}
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):
self.bios_settings_inst.set_pending_boot_mode(
sys_cons.BIOS_BOOT_MODE_UEFI)
data = {}
data['UefiOptimizedBoot'] = 'Enabled'
data['BootMode'] = 'Uefi'
data = {
'Attributes': {
'BootMode': 'Uefi',
'UefiOptimizedBoot': 'Enabled'
}
}
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/'
'json_samples/bios_base_configs.json', 'r') as f:
bios_settings = json.loads(f.read())['BaseConfigs'][0]['default']
@ -223,10 +229,22 @@ class BIOSPendingSettingsTestCase(testtools.TestCase):
data = {
'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,
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):

View File

@ -721,7 +721,7 @@ class RedfishOperationsTestCase(testtools.TestCase):
self.rf_client.get_server_capabilities)
@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):
with open('proliantutils/tests/redfish/'
'json_samples/system.json', 'r') as f: