ProLiant Servers (ML,DL,SL)
1825768 Members
2082 Online
109687 Solutions
New Discussion

change persistent boot order using Redfish API

 
SOLVED
Go to solution
bradawk1
Trusted Contributor

change persistent boot order using Redfish API

Trying to change the persistent boot config order array using the redfish api.  This is the code I am using:

SERVER=my-fqdn.org
ACTV=$(python3 -c "import urllib.parse, sys; print urllib.parse.quote(sys.argv[1])"'serverName' = '${SERVER}'\"")
UUID=$(curl --insecure --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --silent \
   --request GET ${OneView}/rest/server-hardware?filter=${ACTV} | jq -r '.members[] | .uuid'})
read iLOSSO iLOAuth <<< $(curl --silent --insecure --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" \
   --request GET ${OneView}/rest/server-hardware/${UUID}/remoteConsoleUrl | \
   jq -r '.remoteConsoleUrl ' | sed -e 's|hplocons|https|' -e 's|addr=||' \
   -e 's|^\(.*\)&sessionkey=\(.*\)$|\1 \2|')
PBCO=$(curl --insecure --silent --header "X-API-Token: ${iLOAuth}" --request GET ${iLOSSO}/redfish/v1/systems/1/bios/oem/hpe/boot | jq -r '.PersistentBootConfigOrder')
#
# Change the order of the array:
PBCOn=${"PersistentBootConfigOrder":["'$(echo ${PBCO} | jq -r ".[0]")]","'$(echo ${PBCO} | jq -r ".[2]")]","'$(echo ${PBCO} | jq -r ".[1]")]","'$(echo ${PBCO} | jq -r ".[3]")]","'$(echo ${PBCO} | jq -r ".[4]")]","'$(echo ${PBCO} | jq -r ".[5]")'"]}'
echo ${PBCOn} | jq -r '.'
#
# Upload to iLO:
curl --insecure --silent  --header "X-API-Token: ${iLOAuth}" --header "content-type: application/json" --data "${PBCOn}" --request PATCH ${iLOSSO}/redfish/v1/systems/1/bios/oem/hpe/boot/settings | jq -r '.'
#
curl --insecure --silent  --header "X-API-Token: ${iLOAuth}" --header "content-type: application/json" --data '{"Action": "Manager.Reset"}' --request POST ${iLOSSO}/redfish/v1/Managers/1/Actions/Manager.Reset | jq -r '.'
 

I get back:

{
  "error": {
    "code": "iLO.0.10.ExtendedInfo",
    "message": "See @Message.ExtendedInfo for more information.",
    "@Message.ExtendedInfo": [
      {
        "MessageId": "iLO.2.15.SystemResetRequired"
      }
    ]
  }
}

I took that to mean there really was not an error, but that a iLO reset was required.  I sent the reset command and waited for that to complete.  I then pulled down  the PersistentBootConfigOrder array again and it had not changed.  Any idea what I am doing wrong?

3 REPLIES 3
thutchings
HPE Pro
Solution

Re: change persistent boot order using Redfish API

Hello,

 

In order to apply this change it does not require an iLO reset. A system (server) reset is required to apply a change to BIOS settings. You should be able to do this with the following:

"Actions": {
"#ComputerSystem.Reset": {
"ResetType@Redfish.AllowableValues": ["On", "ForceOff", "GracefulShutdown", "ForceRestart", "Nmi", "PushPowerButton", "GracefulRestart"],
"target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset"
}

 

 

Regards



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
bradawk1
Trusted Contributor

Re: change persistent boot order using Redfish API

Oh!  Thanks!  That is more intrusive to operations than I realized.  I will make that update.

bradawk1
Trusted Contributor

Re: change persistent boot order using Redfish API

Just to summarize:

# Get the current boot order:
SERVER=my-fqdn.org
ACTV=$(python3 -c "import urllib.parse, sys; print urllib.parse.quote(sys.argv[1])"'serverName' = '${SERVER}'\"")
UUID=$(curl --insecure --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --silent \
   --request GET ${OneView}/rest/server-hardware?filter=${ACTV} | jq -r '.members[] | .uuid'})
read iLOSSO iLOAuth <<< $(curl --silent --insecure --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" \
   --request GET ${OneView}/rest/server-hardware/${UUID}/remoteConsoleUrl | \
   jq -r '.remoteConsoleUrl ' | sed -e 's|hplocons|https|' -e 's|addr=||' \
   -e 's|^\(.*\)&sessionkey=\(.*\)$|\1 \2|')
PBCO=$(curl --insecure --silent --header "X-API-Token: ${iLOAuth}" --request GET ${iLOSSO}/redfish/v1/systems/1/bios/oem/hpe/boot | jq -r '.PersistentBootConfigOrder')
#
# Change the order of the array:
PBCOn=${"PersistentBootConfigOrder":["'$(echo ${PBCO} | jq -r ".[0]")]","'$(echo ${PBCO} | jq -r ".[2]")]","'$(echo ${PBCO} | jq -r ".[1]")]","'$(echo ${PBCO} | jq -r ".[3]")]","'$(echo ${PBCO} | jq -r ".[4]")]","'$(echo ${PBCO} | jq -r ".[5]")'"]}'
echo ${PBCOn} | jq -r '.'
#
# Upload to the server:
curl --insecure --silent  --header "X-API-Token: ${iLOAuth}" --header "content-type: application/json" --data "${PBCOn}" --request PATCH ${iLOSSO}/redfish/v1/systems/1/bios/oem/hpe/boot/settings | jq -r '.'
# 
# Send a reboot command to the server to activate the change(s):
curl --insecure --silent  --header "X-API-Token: ${iLOAuth}" --header "content-type: application/json" --data '{"ResetType": "GracefulRestart"}' --request POST ${iLOSSO}/redfish/v1/systems/1/actions/Computersystem.Reset | jq -r '.'