Move settings object get to patch_SetBootOverrideUrl_override-handling

The 0003-Add-config-file-based-setBootOverride-Url-handling-n.patch
introduced special setBootOverride handling for specific server
models. That patch tries to get a @Redish.Settings" key/value pair that
does not exist with some older servers such as the HPE Proliant DL360.

This patch moves the offending @Redish.Settings" key/value pair get
into the recently added patch_SetBootOverrideUrl_override condition
and adds some more graceful failure handling around getting the
Redfish settings.

Test Plan:

PASS: Verify redfishtool setBootOverride handling only tries to get
      the "@Redish.Settings" key/value pair for servers that qualify
      for the patch_SetBootOverrideUrl_override condition.

Failure Path Handling:

PASS: Verify failure to get @Redfish.Settings object
      - error log rather than traceback
PASS: Verify handling of settings_uri=None case
PASS: Verify handling of failed rftSendRecvRequest HEAD request case

Partial-Bug: 2125462
Change-Id: If7ae9aa44b080b3232d2eebbc7681c3f75fc32ad
Signed-off-by: Eric Macdonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric Macdonald
2025-10-15 16:03:41 -04:00
committed by Eric MacDonald
parent fe71102cf8
commit c0d102ed63
2 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
From: Eric Macdonald <eric.macdonald@windriver.com>
Date: Wed, 15 Oct 2025 10:57:57 -0400
Subject: Move settings object get to
patch_SetBootOverrideUrl_override-handling
The 0003-Add-config-file-based-setBootOverride-Url-handling-n.patch
introduced special setBootOverride handling for specific server
models. That patch tries to get a @Redish.Settings" key/value pair that
does not exist with some older servers such as the HPE Proliant DL360.
This patch moves the offending @Redish.Settings" key/value pair get
into the recently added patch_SetBootOverrideUrl_override condition
and adds some more graceful failure handling around getting the
Redfish settings.
Signed-off-by: Eric Macdonald <eric.macdonald@windriver.com>
---
redfishtoollib/Systems.py | 69 ++++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/redfishtoollib/Systems.py b/redfishtoollib/Systems.py
index 8daa792..22dbf4c 100644
--- a/redfishtoollib/Systems.py
+++ b/redfishtoollib/Systems.py
@@ -703,37 +703,46 @@ class RfSystemsOperations():
"BootSourceOverrideTarget": targetVal,\
"BootSourceOverrideMode": d["Boot"]["BootSourceOverrideMode"] } }
- rft.printVerbose(4,"Patch payload :{}".format(json.dumps(d,indent=4)))
- # Get the Settings URI from /redfish/v1/Systems/<ComputerSystemId>
- # In response look for:
- # "@Redfish.Settings": {
- # "SettingsObject": {
- # "@odata.id": "/redfish/v1/Systems/<ComputerSystemId>/Settings"
- # },
- # "SupportedApplyTimes": [
- # "OnReset"
- # ],
- # "@odata.type": "#Settings.v1_4_0.Settings"
- # },
- settings_uri=d["@Redfish.Settings"]["SettingsObject"]["@odata.id"]
- rft.printVerbose(1,"Systems Settings Patch uri:{} url:{}".format(settings_uri, r.url))
- if patch_SetBootOverrideUrl_override is True and settings_uri:
-
- # Perform a HEAD operation to the override Settings URL to learn
- # the System Settings request Etag for use ion the rftSendRecvRequest
- settings_url = urljoin(r.url, settings_uri)
- rft.printVerbose(4,"Systems Settings uri:{}".format(settings_uri))
- rft.printVerbose(1,"Systems Settings url:{}".format(settings_url))
- rc, r, j, d = rft.rftSendRecvRequest(rft.AUTHENTICATED_API, "HEAD", settings_url)
- if rc:
- rft.printErr(f"Error: SendRecvRequest HEAD to "
- f"{settings_url} ; "
- f"Response: rc={rc}, type(r)={type(r)}, "
- f"status={getattr(r,'status_code',None)}, "
- f"url={getattr(r,'url',None)}")
+ if patch_SetBootOverrideUrl_override is True:
+ rft.printVerbose(4,"Patch payload :{}".format(json.dumps(d,indent=4)))
+ # Get the Settings URI from /redfish/v1/Systems/<ComputerSystemId>
+ # In response look for:
+ # "@Redfish.Settings": {
+ # "SettingsObject": {
+ # "@odata.id": "/redfish/v1/Systems/<ComputerSystemId>/Settings"
+ # },
+ # "SupportedApplyTimes": [
+ # "OnReset"
+ # ],
+ # "@odata.type": "#Settings.v1_4_0.Settings"
+ # },
+ try:
+ settings_uri=d["@Redfish.Settings"]["SettingsObject"]["@odata.id"]
+ rft.printVerbose(1,"Systems Settings Patch uri:{} url:{}".format(settings_uri, r.url))
+ except:
+ rft.printErr("Error, failed to get @Redfish.Settings object from {}".format(r.url))
+ return(8,None,False,None)
+
+ if settings_uri:
+ rft.printVerbose(4,"Systems Settings uri from {}".format(r.url))
+
+ # Perform a HEAD operation to the override Settings URL to learn
+ # the System Settings request Etag for use ion the rftSendRecvRequest
+ settings_url = urljoin(r.url, settings_uri)
+ rft.printVerbose(1,"Systems Settings url:{}".format(settings_url))
+ rc, r, j, d = rft.rftSendRecvRequest(rft.AUTHENTICATED_API, "HEAD", settings_url)
+ if rc:
+ rft.printErr(f"Error: SendRecvRequest HEAD to "
+ f"{settings_url} ; "
+ f"Response: rc={rc}, type(r)={type(r)}, "
+ f"status={getattr(r,'status_code',None)}, "
+ f"url={getattr(r,'url',None)}")
+ else:
+ rc,r,j,d=rft.patchResource(rft, r, patchData)
+ rft.printVerbose(4,"Patch Settings Response Data :{}".format(json.dumps(d,indent=4)))
else:
- rc,r,j,d=rft.patchResource(rft, r, patchData)
- rft.printVerbose(4,"Patch Settings Response Data :{}".format(json.dumps(d,indent=4)))
+ rft.printErr("Error, failed to get settings_uri from @Redfish.Settings object\n{}".format(d))
+ return(8,None,False,None)
else:
#call the generic patch command to send the patch. This takes care of etag support
rc,r,j,d=rft.patchResource(rft, r, patchData)

View File

@@ -1,3 +1,4 @@
0001-1.1.8-versioning.patch
0002-Add-config-file-based-BootSourceOverrideMode-handlin.patch
0003-Add-config-file-based-setBootOverride-Url-handling-n.patch
0004-Move-settings-object-get-to-patch_SetBootOverrideUrl.patch