HPE OneView
cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve server hardware information with serverName filter?

 
SOLVED
Go to solution
BradV
Trusted Contributor

Retrieve server hardware information with serverName filter?

Is it possible to filter on serverName in the GET server-hardware API?  I tried: 

curl --insecure \
     --header "auth: ${sessionID}" \
     --header "X-API-Version: ${currentVersion}" \
     --request GET ${OneView}/rest/server-hardware?serverName="my-host"

but I am getting much more than "my-host" in the return.  I want to retrieve the UUID associated with this server to use in conjunction with create a new server profile for it.  Just not sure of the best way to retrieve that? 

4 REPLIES 4
DaveArko
Occasional Advisor
Solution

Re: Retrieve server hardware information with serverName filter?

You seem to be missing the ?filter= part of the request.    In playing around with it just now, I found it impossible to get the quoting to go through curl correclty without transforming any special characters to the %xx equiv.  (usuing postman returns this format when you ask for a command line equiv).

In my case, the request I was entering into postman is:

    https://my-oneview/rest/server-hardware?filter="'serverName' eq 'myservername'"

Translated to a curl command ended up being:

    'https://my-oneview/rest/server-hardware?filter=%22%27serverName%27%20eq%20%27myservername%27%22'

 

BradV
Trusted Contributor

Re: Retrieve server hardware information with serverName filter?

Great!  That worked!  

curl --insecure \
     --header "auth: ${sessionID}" \
     --header "X-API-Version: ${currentVersion}" \
     --request GET ${OneView}/rest/server-hardware?filter=%22%27serverName%27%20=%20%27my-host%27%22 | jq -r '.'

Thanks! 

ChrisLynchHPE
Neighborhood Moderator

Re: Retrieve server hardware information with serverName filter?

@DaveArko is correct.  Almost every main URI supports the filter property, which is how you find an applicable resource using various object properties.  Do keep in mind that not all properties can be used to filter.  UserQuery is also another way you can find something. But UserQuery is also not fully supported by all URI's.


Accept or Kudo

BradV
Trusted Contributor

Re: Retrieve server hardware information with serverName filter?

Hi Chris,

I'm trying to get a method from having a server profile template, using the new-profile API, then retrieving the UUID for a given server to modify the returned profile object before applying that to the server. 

Regards,

Brad