Fix setting "HttpBootUri" attributes

Enhance handling of 'HttpBootUri' so that it is set against
SettingsURI if it present there. If not, fall back to System URI.

Change-Id: I8c29be1332f7ff1ce7346e9bcdccb72be49199d4
This commit is contained in:
Derek Higgins 2024-09-27 15:45:17 +01:00
parent 8928f45402
commit 11ff4bcfcf
4 changed files with 41 additions and 3 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
PATCH 'HttpBootUri' against SettingsURI if present. If not,
fall back to System URI.

View File

@ -337,9 +337,11 @@ class System(base.ResourceBase):
if not http_boot_uri:
# This should clear out any old entries, as no URI translates
# to the intent of "use whatever the dhcp server says".
data['Boot']['HttpBootUri'] = None
http_boot_uri = None
if (settings_resp and "HttpBootUri" in settings_boot_section):
settings_data['Boot']['HttpBootUri'] = http_boot_uri
else:
# Explicitly set the URI.
data['Boot']['HttpBootUri'] = http_boot_uri
elif not http_boot_uri:
# We're not doing boot from URL, we should cleanup any setting

View File

@ -41,7 +41,8 @@
"RemoteDrive",
"UefiBootNext"
],
"UefiTargetBootSourceOverride": ""
"UefiTargetBootSourceOverride": "",
"HttpBootUri": null
},
"Description": "System Self",
"Id": "Self",

View File

@ -504,6 +504,35 @@ class SystemTestCase(base.TestCase):
'HttpBootUri': 'http://test.lan/test_image.iso'}},
etag=mock.ANY)
def test_set_system_boot_options_httpboot_settings(self):
with open('sushy/tests/unit/json_samples/settings-nokia.json') as f:
settings_obj = json.load(f)
self.json_doc.update(settings_obj)
self.sys_inst._parse_attributes(self.json_doc)
with open('sushy/tests/unit/json_samples/'
'settings-body-nokia.json') as f:
settings_body = json.load(f)
get_settings = mock.MagicMock(headers={'ETag': '"3d7b838291941d"'})
get_settings.json.return_value = settings_body
get_system = mock.MagicMock(headers={'ETag': '"222"'})
self.conn.get.side_effect = [get_settings, get_system]
self.sys_inst.set_system_boot_options(
sushy.BootSource.UEFI_HTTP,
enabled=sushy.BootSourceOverrideEnabled.ONCE,
http_boot_uri='http://test.lan/test_image.iso'
)
self.sys_inst._conn.patch.assert_called_once_with(
'/redfish/v1/Systems/Self/SD',
data={'Boot': {'BootSourceOverrideTarget': 'UefiHttp',
'BootSourceOverrideEnabled': 'Once',
'HttpBootUri': 'http://test.lan/test_image.iso'}},
etag=mock.ANY)
def test_set_system_boot_options_httpboot(self):
self.sys_inst.set_system_boot_options(
sushy.BootSource.UEFI_HTTP,