HPE OneView
1753447 Members
5196 Online
108794 Solutions
New Discussion

Re: Retrieve server hardware information with serverName filter?

 
SOLVED
Go to solution
BradV
Esteemed 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? 

5 REPLIES 5
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
Esteemed 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! 

ChrisLynch
HPE Pro

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.


I am an HPE employee

Accept or Kudo

BradV
Esteemed 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

BradV
Esteemed Contributor

Re: Retrieve server hardware information with serverName filter?

Did anything change in version 7 that might affect this?  Our OneViews are at 7.00.00-0460837.  When I run the above command (which used to work), I get back:

{
  "type: "server-hardware-list-12",
  "category": "server-hardware",
  "count": 0,
  "created": "<a date>",
  "eTag": "16594505347",
  "members": [],
  "modified": "<another date>",
  "nextPageUri": null,
  "prevPageUri": null,
  "start": 0,
  "total": 0,
  "uri": "/rest/server-hardware?filter=%22%27serverName%27%20=%20%27my-host%27%22&start=0&count=32"
}