Merge "Add setBootOveride Patch for Patch request to System Settings"

This commit is contained in:
Zuul
2025-10-06 14:48:42 +00:00
committed by Gerrit Code Review
3 changed files with 152 additions and 0 deletions

View File

@@ -12,4 +12,7 @@ exclude_BootSourceOverrideMode_Models = "R740XD vSAN Ready Node", "PowerEdge R75
# For entire manufacturers - second filter
exclude_BootSourceOverrideMode_Manufacturers = "HPE", "Dell Inc."
# For specific servers
patch_setBootOverrideUrl_Models = "PowerEdge XR8720t"
[Settings]

View File

@@ -0,0 +1,148 @@
From: Eric Macdonald <eric.macdonald@windriver.com>
Date: Mon, 22 Sep 2025 00:45:11 +0000
Subject: Add config file based setBootOverride Url handling named server
models
This patch reads /etc/redfishtool/redfishtool.ini config file in
search for the setBootOverride_overrides section that has a
list of server models that require setBootOverride payload to be
patched to the Systems Settings URL.
This update performs the server model detection and patch URL override.
[setBootOverride_overrides]
patch_setBootOverrideUrl_Models = "<model>", "<model>"
Signed-off-by: Eric Macdonald <eric.macdonald@windriver.com>
---
redfishtoollib/Systems.py | 88 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 81 insertions(+), 7 deletions(-)
diff --git a/redfishtoollib/Systems.py b/redfishtoollib/Systems.py
index 6abee66..8daa792 100644
--- a/redfishtoollib/Systems.py
+++ b/redfishtoollib/Systems.py
@@ -502,6 +502,42 @@ class RfSystemsOperations():
def setIndicatorLed(self, sc, op, rft, cmdTop=False, prop=None):
return op.iterate_op(op.setIndicatorLed_single, sc, op, rft, cmdTop=cmdTop, prop=prop)
+ def get_patch_SetBootOverrideUrl(self, rft, d):
+ """
+ Query redfishtool.ini for models that need the setBootOverride to be patched
+ through a Systems Setting URL rather than the normal default Systems URL.
+
+ Use the 'setBootOverride_overrides' config label and load the list of
+ affected server models from patch_setBootOverrideUrl_Models.
+
+ Servers in the patch_setBootOverrideUrl_Models list must get the setBootOverride
+ settings patched through /redfish/v1/Systems/<ComputerSystemId>/Settings
+ instead of /redfish/v1/Systems/<ComputerSystemId>
+ """
+
+ # include the config file parser
+ import configparser
+
+ # the config file path
+ config_file="/etc/redfishtool/redfishtool.ini"
+ config = configparser.ConfigParser()
+ # read the configuration file
+ files_read = config.read(config_file)
+ if not files_read:
+ rft.printVerbose(0, "Configuration file '{}' not found or could not be read.".format(config_file))
+ return(False)
+
+ patch_url_override_models_list = []
+ section="setBootOverride_overrides"
+ patch_setBootOverrideUrl_Models="patch_setBootOverrideUrl_Models"
+ if section in config:
+ patch_url_override_models_list = config[section][patch_setBootOverrideUrl_Models]
+ model=d["Model"]
+ if model in patch_url_override_models_list:
+ rft.printVerbose(0, "Using System Settings URL for setBootOverride "
+ "for server: '{}'".format(model))
+ return True
+ return False
def get_exclude_BootSourceOverrideMode(self, rft, d):
"""
@@ -597,6 +633,13 @@ class RfSystemsOperations():
print("Error, can't read boot properties from remote service")
return(8,None,False,None)
+ # this call will open the redfishtool.ini file and search for server models
+ # that must patch setBootOverride payload to the Systems Settings URL.
+ # override: /redfish/v1/Systems/<ComputerSystemId>
+ # with: /redfish/v1/Systems/<ComputerSystemId>/Settings
+ # If found then a True (to overrride) is returned.
+ patch_SetBootOverrideUrl_override = op.get_patch_SetBootOverrideUrl(rft, d)
+
# this call will open the redfishtool.ini file and search for server models or
# manufacturers that don't support or behave well when the 'setBootOverride Once <target>'
# key:value pair is part of the payload of the PATCH method.
@@ -642,12 +685,12 @@ class RfSystemsOperations():
else:
rft.printErr("Error, the remote service does not have a Boot prop")
return (8, None, False, None)
-
+
# verify that they have a BootSourceOverrideEnabled and BootSourceOverrideTarget prop
if( not "BootSourceOverrideTarget" in bootRes ):
rft.printErr("Error, the service does not have oneOf BootSourceOverride..Enabled or ..Target property")
return(8,None,False,None)
-
+
#form the patch data
# Get the value of "BootSourceOverrideTarget" property and pass it in the patch request.
@@ -660,15 +703,46 @@ class RfSystemsOperations():
"BootSourceOverrideTarget": targetVal,\
"BootSourceOverrideMode": d["Boot"]["BootSourceOverrideMode"] } }
- #call the generic patch command to send the patch. This takes care of etag support
- rc,r,j,d=rft.patchResource(rft, r, patchData)
-
-
+ 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)}")
+ else:
+ rc,r,j,d=rft.patchResource(rft, r, patchData)
+ rft.printVerbose(4,"Patch Settings Response Data :{}".format(json.dumps(d,indent=4)))
+ 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)
+
if(rc==0):
rft.printVerbose(1," Systems setBootOverride:",skip1=True, printV12=cmdTop)
bootd={"Boot": d["Boot"]}
return(rc,r,j,bootd)
-
+
else: return(rc,r,False,None)

View File

@@ -1,2 +1,3 @@
0001-1.1.8-versioning.patch
0002-Add-config-file-based-BootSourceOverrideMode-handlin.patch
0003-Add-config-file-based-setBootOverride-Url-handling-n.patch