Simplify UEFI logic and change the UefiHttp flow

In trying to test the Redfish UEFI Http interface logic, it was
observed that we were not getting the values out of the emulator we
expected. So this change simplifies the logic which wasn't quite
working for us.

We also realized the code was trying to set the boot interface before
actually creating it. Doh!

It seems, also I might have had some other issues in the original patch
which we couldn't detect without fully getting everything working, so
some additional refactoring exists with this patch.

Change-Id: Ibfe5a560a25251965e8bad87012f64e89d9640be
This commit is contained in:
Julia Kreger 2023-11-16 12:55:46 -08:00
parent b5edaadd8d
commit 64b4453cc6
2 changed files with 32 additions and 23 deletions

View File

@ -389,6 +389,7 @@ def system_resource(identity):
total_cpus=try_get(app.systems.get_total_cpus),
boot_source_target=app.systems.get_boot_device(identity),
boot_source_mode=try_get(app.systems.get_boot_mode),
uefi_mode=(try_get(app.systems.get_boot_mode) == 'UEFI'),
managers=app.managers.get_managers_for_system(identity),
chassis=app.chassis.chassis[:1],
indicator_led=app.indicators.get_indicator_state(
@ -405,6 +406,36 @@ def system_resource(identity):
if boot:
target = boot.get('BootSourceOverrideTarget')
mode = boot.get('BootSourceOverrideMode')
http_uri = boot.get('HttpBootUri')
if http_uri and target == 'UefiHttp':
try:
# Download the image
image_path = app.vmedia.insert_image(
identity, 'Cd', http_uri)
except Exception as e:
app.logger.error('Unable to insert image for HttpBootUri '
'request processing. Error: %s', e)
return '', 400
try:
# Mount it as an ISO
app.systems.set_boot_image(
identity,
'Cd', boot_image=image_path,
write_protected=True)
# Set it for our emulator's API surface to return it
# if queried.
except Exception as e:
app.logger.error('Unable to attach HttpBootUri for boot '
'operation. Error: %s', e)
try:
app.systems.set_http_boot_uri(http_uri)
except Exception as e:
app.logger.error('Unable to record HttpBootUri for boot '
'operation. Error: %s', e)
return '', 400
if target == 'UefiHttp':
# Reset to Cd, in our case, since we can't force override
@ -422,34 +453,12 @@ def system_resource(identity):
app.logger.info('Set boot device to "%s" for system "%s"',
target, identity)
mode = boot.get('BootSourceOverrideMode')
if mode:
app.systems.set_boot_mode(identity, mode)
app.logger.info('Set boot mode to "%s" for system "%s"',
mode, identity)
http_uri = boot.get('HttpBootUri')
if http_uri:
try:
# Download the image
image_path = flask.current_app.vmedia.insert_image(
identity, 'Cd', http_uri)
# Mount it as an ISO
flask.current_app.systems.set_boot_image(
'Cd', boot_image=image_path,
write_protected=True)
# Set it for our emulator's API surface to return it
# if queried.
flask.current_app.systems.set_http_boot_uri(http_uri)
except Exception as e:
app.logger.error('Unable to load HttpBootUri for boot '
'operation. Error: %s', e)
return '', 400
if not target and not mode and not http_uri:
return ('Missing the BootSourceOverrideTarget and/or '
'BootSourceOverrideMode and/or HttpBootUri '

View File

@ -20,7 +20,7 @@
"Pxe",
"Cd",
{%- if boot_source_mode %}
{%- if 'uefi' in boot_source_mode.lower() %}
{%- if uefi_mode %}
"Hdd",
"UefiHttp"
],