ProLiant Servers (ML,DL,SL)
1833301 Members
2913 Online
110051 Solutions
New Discussion

Create new SNMP v3 user via Redfish API

 
SOLVED
Go to solution
BradV
Esteemed Contributor

Create new SNMP v3 user via Redfish API

I'm trying to figure out how to create a new SNMP v3 user on our iLO interfaces via the redfish API.  The github redfish reference does not seem to provide an example of how to do this.  I think this is what I need to do is :

function nextID() {
   IDs=$(curl --silent --insecure --header "X-Auth-Token: ${iLOAuth}" --request GET ${iLOSSO}/redfish/v1/Managers/1/snmpservice/snmpusers | jq -r '.Members[]' | grep 'odata.id' | tr -d '"' | cut -d/ -f8)
   for i in {1..8}; do
      if [[ ${IDs} =~ "${i}" ]]; then
         echo "${i} is in use"
      else
         j=${i}
         break
      fi
   done
}
SECNAME='newname'
AuthTp='SHA'
PrivTp='AES'
AuthP='thissecuritypassphrase'
PrivP='someothersecuritypassphrase'
DATA='{"SecurityName":"'${SECNAME}'","AuthProtocol":"'${AuthTp}'","AuthPassphrase":"'${AuthP}'","PrivacyProtocol":"'${PrivP}'","PrivacyPassphrase":"'${PrivP}'","UserEngineID":null}'
SERVER=myserver.com
# HARDW is set to a file of all extracted hardware from OneView
UUID=$(jq -r '.members[] | select(.serverName=="'${SERVER}'") | "\(.uuid)"' ${HARDW})
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|')
nextID
curl --silent --insecure --header "X-API-Token: ${iLOAuth}" --header "content-type: application/json" --data "${DATA}" --request PATCH ${iLOSSO}/redfish/v1/Managers/v1/snmpservice/snmpusers/${j}

but that gives back:

{
  "error": {
    "code": "iLO.0.10.ExtendedInfo",
    "message": "See @Message.ExtendedInfo for more information.",
    "@Message.ExtendedInfo": [
      {
        "MessageArgs": [
          "Invalid URI"
        ],
      }
    ]
  }
}

So, not quite correct.  Does anyone know the correct syntax/method to create a new SNMP v3 user?

3 REPLIES 3
support_s
System Recommended

Query: Create new SNMP v3 user via Redfish API

BradV
Esteemed Contributor
Solution

Re: Query: Create new SNMP v3 user via Redfish API

I got it to work:

SECNAME='newname'
AuthTp='SHA'
PrivTp='AES'
AuthP='thissecuritypassphrase'
PrivP='someothersecuritypassphrase'
DATA='{"SecurityName":"'${SECNAME}'","AuthProtocol":"'${AuthTp}'","AuthPassphrase":"'${AuthP}'","PrivacyProtocol":"'${PrivP}'","PrivacyPassphrase":"'${PrivP}'"}'
SERVER=myserver.com
# HARDW is set to a file of all extracted hardware from OneView
UUID=$(jq -r '.members[] | select(.serverName=="'${SERVER}'") | "\(.uuid)"' ${HARDW})
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|')
curl --silent --insecure --header "X-API-Token: ${iLOAuth}" --header "content-type: application/json" --data "${DATA}" --request POST ${iLOSSO}/redfish/v1/Managers/v1/SnmpService/SNMPUsers/ | jq -r '.'

If you want to do a group of servers, can put from UUID= on down in a for SERVER in ...  loop.

Sunitha_Mod
Honored Contributor

Re: Query: Create new SNMP v3 user via Redfish API

Hello @BradV

That's great! We are glad to know you were able to find the solution and we appreciate you for keeping us updated.