HPE OneView
1833590 Members
4050 Online
110061 Solutions
New Discussion

Query: rest api building server profile template

 
bradawk1
Trusted Contributor

rest api building server profile template

I'm trying to build a server profile template using the rest api.  I have the base template created.  However, when I try to add in the iLO active directory connection, I get:

"taskErrors": [{ "data":{},"details": "","errorCode": "InvalidParameterSHT","errorSource": null,"message": "The server hardware type null is not valid or not supported.","netstedErrors": [],"recommendedActions":["Verify the parameters"]}]

Here is the code I am using:

MODEL="ProLiant DL325 Gen10 Plus"
HRDWUUID=$(curl --insecure --silent \
     --header "X-API-Version: ${currentVersion}" \
     --header "auth: ${sessionID}" \
     --request GET ${OneView}/rest/server-hardware-types | jq -r '.members[] | select(.model=="'"${MODEL}"'") | .rui')
NAME=weka_template
DESCRIP="weka nodes"
DATA=$(echo '{"type": "ServerProfileTemplateV8","uri": null,"name": ";${NAME}'", "description": "'${DESCRIP}'",
"serverHardwareTypeUri": "'${HRDWUUID}'","enclosureGroupUril": null,"affinity": null,"hideUnusedFlexNics": null,
"macType": "Physical","wwnType": "Physical","serialNumberType": "Physical","iscsiInitiatorNameType": "AutoGenerated",
"osDeploymentSettings": null,"firmware":{"complianceControl": "Checked","manageFirmware": false,"firmwareInstallType": "FirmwareAndOSDrivers",
"forceInstallFirmware": false,"firmwareBaselineUri": false,"firmwareActivationType": "NotScheduled"},
"connectionSettings":{"complianceControl": "Unchecked","manageConnections": false,"connections": []},
"bootMode":{"complianceControl": "Checked","manageMode": true,"mode": "UEFI","pxeBootPolicy": "IPv4","secureBoot": "Disabled"},
"boot":{"complianceControl": "Unchecked","manageBoot": false,"order":[]},
"bios":{"complianceControl": "Checed","manageBios": true,"overriddenSettings":[
{"id": "MinProcIdlePower","value": "NoCStates"},
{"id": "ProcSMT","value": "Disabled"},
{"id": "WorkLoadProfile","value": "I/OThroughput"},
{"id": "PowerRegulator","value": "StaticHighPerf"},
{"id": "ProcAMDBoostControl","value": "AmdFmaxBoostManual"},
{"id": "ProcAmdIoVt","value": "Disabled"},
{"id": "AutoPowerOn","value": "AlwaysPowerOff"},
{"id": "ProcAmdFmax","value": "2900"},
{"id": "NumaGroupSizeOpt","value": "Clustered"}]},
"managementProcessor": {
"compliancControl": "Checked","manageMp": true,"mpSettings": [{
"settingType": "LocalAccounts","args": {"localAccounts": [{
"userName": "admin","displayName": "admin","password": "Password123","usrConfigPriv": true,
"remoteConsolePriv": true,"virutalMediaPriv": true,"virtualPowerAndResetPriv": true,"iLOConfigPriv": true,
"hostBBIOSConfigPriv": true,"hostNICConfigPriv": true,"hostStorageConfigPriv": true}]}},{
"settingType": "Hostname","args": {"hostname":"{serverProfileName}-ilo"}}]},
"localStorage": {"complianceControl": "Unchecked","sasLogicalJBODs": [],"controllers":[]},
"sanStorage":{"complianceControl": "Unchecked","manageSanStorage": false,"sanSystemCredentials":[],
"volumeAttachments":[]}}' | jq -c '.')
TASKURI=$(curl --insecure --silent \
   --header "X-API-Version: ${currentVersion}" \
   --header "auth: ${sessionID}" \
   --header "content-type: application/json" \
   --include \
   --data "${DATA}" \
   --request POST ${OneView}/rest/server-profile-templates | grep '^Location:' | awk '{ print $2 }' |  tr -d '\r')
echo "The task URI is: ${TASKURI}"
#
# You can check the status of the task with:
STATUS=$(curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --request GET ${OneView}%{TASKURI} | jq -r '.taskState')
while [[ ${STATUS} != "Completed" ]]; do
   echo "Current status" ${STATUS}"
   sleep 2
   STATUS=$(curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --request GET ${OneView}%{TASKURI} | jq -r '.taskState')
done
#
# Set variable to a local domain controller:
DIRSRV=local.dc.org
function retrieve-cert() {
   REMHOST=${1}
   REMPORT=${2:-443}
   echo | \
   openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 | \
   /bin/sed -ne '/-BEGIN CERTIFICATE-/,/-END-CERTIFICATE-/p'
}
CHQ=$(retrieve-cert ${DIRSRV} 636 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END-CERTIFICATE-/p' | awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' | sed -e 's|\(.*\)\\n$|\1|')
# Set domain admin credentials and iLO administrator password:
ADUSER="<some AD admin>"
ADPASS="<AD admin's password>"
ADMINPASS="<iLO administrator password>"
# Set up JSON variable for connecting iLO to AD:
DATA=$(echo '{"managementProcessor": {"mpSettings":[{"args":{
"password": "'${ADMINPASS}'","deleteAdminstratorAccount": false},
"settingType": "AdministatorAccount"},{"args": {
"kerberosAuthentication": false,"directoryUserContext": ["dc=our,dc=prg"],
"directoryServerPort": 636,"directoryServerAddress": "'${DIRSVR}'","password":"'${ADPASS}'",
"iloObjectDistinguisedName": "'${ADUSER}'","directoryGenericLDAP": true,
"directoryAuthentication": "defaultSchema","directoryServerCertificate": "'${CHQ}'"},
"settingType": "Directory"},{"args":{
"directoryGroupAccounts": [{"iLOConfigPriv": true,"virtualPowerAndResetPriv": true,"virtualMediaPriv": true,
"remoteConsolePriv": true, "userConfigPriv": true, "groupSID": "S-1-5-21-23452342343-23432422-22342342-23533",
"groupDN": "OneView_group"}]},"settingType": "DirectoryGroups"}],"manageMP": true,"complianceControl": "Checked"}}' | jq -c '.')
#
# We need the URI of the server profile template we just created and the associated etag:
read SPTURI ETAG <<< $(curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --request GET ${OneView}/rest/server-profile-templates | jq -r '.members[] | select(.name=="'"${NAME}"'") | .uri,.eTag' | tr "\n" " ")
#
# Add the etag to the data:
DATA=$(echo ${DATA} | jq '.eTag="'${ETAG}'"' | jq -c '.')
#
# Update the server profile template with the iLO information:
TASKURI=$(curl --insecure --silent \
   --header "X-API-Version: ${currentVersion}" \
   --header "auth: ${sessionID}" \
   --header "content-type: application/json" \
   --include \
   --data "${DATA}" \
   --request POST ${OneView}/rest/server-profile-templates | grep '^Location:' | awk '{ print $2 }' |  tr -d '\r')
echo "The task URI is: ${TASKURI}"
curl --insecure --silent --header "X-API-Version: ${currentVersion}" --header "auth: ${sessionID}" --request GET ${OneView}%{TASKURI} | jq -r '.'

I'm not even listing a hardware type in the JSON.

6 REPLIES 6
ChrisLynch
HPE Pro

Re: rest api building server profile template

You are passing in a null value for serverHardwareTypeUri due to a typo in your GET /rest/server-hardware-types API call:

--request GET ${OneView}/rest/server-hardware-types | jq -r '.members[] | select(.model=="'"${MODEL}"'") | .rui')

It should be:

--request GET ${OneView}/rest/server-hardware-types | jq -r '.members[] | select(.model=="'"${MODEL}"'") | .uri')

I work at HPE
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
bradawk1
Trusted Contributor

Re: rest api building server profile template

Hi Chris,

No, that was just a typo.  Our servers are not connected to the Internet.  I have to re-type everything on a workstation which is.  I get the base template created OK.  It is just when I go to add the iLO active directory information that I am getting that error.  I pulled the base server profile template and it does have a valid serverHardwareTypeUri.  There are only 5 "nulls" in the template and none have anything to do with hardware.  I'll keep looking.

bradawk1
Trusted Contributor

Re: rest api building server profile template

@ChrisLynch 

I ran it again changing the template name slightly.  Again, the POST operation to create the template worked fine.  When I tried the PUT to modify the template, I got the first time I checked the status:

 

"progressUpdates": [{"id":0,"statusUpdate": "Validate configuration","timestampt":"2025-02-05021T15:33:00.25Z"}],
"startTime" null,"stateReason":"Starting","taskErrors":[],"taskOutput":[],"taskState":"Starting","taskStatus":"Updating server profile template"

 

I then checked the state again and this time received:

 

"progressUpdates": [{"id":0,"statusUpdate": "Validate configuration","timestampt":"2025-02-05021T15:33:00.43Z"}],
"startTime" null,"stateReason":"ValidationError","taskErrors":[{"data":{},"deatils":"","errorCode":"InvalidParameterForSHT","errorSource":null,"message":"The server hardware type null is not valid or not supported.","nestedErrors":[],"recommendedActions":["Verify the parameters."]}],"taskOutput":[],"taskState":"Error","taskStatus":"Unable to update server profile template: base_DL345_G11_test"

 

What does "errorCode":"InvalidParameterForSHT" mean?

 

ChrisLynch
HPE Pro

Re: rest api building server profile template

Are you sure you are providing a valid SHT object, with a valid serverHardwareTypeUri value? That said, without seeing the SHT object you are trying to provide to the API, I'm not sure where the error actually lies.

You can always use the UI to construct the SPT the way you want, then examine via the browser Develper Tools the POST call and request body JSON object.  Then compare that with what you are trying to POST via cURL.  I use that technique when trying to triage an issue with the PowerShell Cmdlet development.

I work at HPE
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
bradawk1
Trusted Contributor

Re: rest api building server profile template

Thanks Chris.  I'll take a look.

support_s
System Recommended

Query: rest api building server profile template

Hello,

 

Let us know if you were able to resolve the issue.

If you are satisfied with the answers then kindly click the "Accept As Solution" button for the most helpful response so that it is beneficial to all community members.

 

 

Please click on "Thumbs Up/Kudo" icon to give a "Kudo".


Accept or Kudo