Posted by on December 17, 2014

As part of a PoC i’m spending quite a bit of time pulling apart the APIs of HPs OneView application, and pulling this functionality into a Objective-C application.

oneview_dashboard_tcm245_1843105_tcm245_1843121_tcm245-1843105

HP Oneview is based upon a REST API and is interacted with directly via the https interface, this is the same API that the HTML5 web interface interacts with (more than likely in a loopback fashion). Connections require the following initial steps:

 

 

  1. Initial rest connection passing JSON containing the userName and password variables.
  2. The response is some JSON containing an id, which is comparable to a cookie when using UCS Manager.
  3. This id is then passed as an Auth: header when used to interact with various areas of the API.

 

These are a few one liners that can be used to communicate with the HP OneView interface.

 

  •  Login

curl -v -H "Content-Type: application/json" -d '{"userName":"Administrator","password":" <PASSWORD> "}' -X POST -k https:// <IP> /rest/login-sessions

  • List server profiles

curl -k -v -H "Content-Type: application/json" \
-H "Auth: <id> " \
-H "X-API-Version: 101" \
-X GET https:// <IP> /rest/server-profiles

Creating a server profile requires a little bit more work, even for a blank profile that isn’t attached to a physical server. This goes agains the examples in the API guide, so I think there is a mistake somewhere. However, two pieces of information are a requirement to create a un-attached server profile. These two pieces are a server hardware type and an enclosure group and these can be found through the following api calls:

  • List Server Hardware Types

curl -k -v -H "Content-Type: application/json" \
-H "Auth: <id> " \
-H "X-API-Version: 101" \
-X GET https:// <IP> /rest/server-hardware-types

  • List Enclosure Groups

curl -k -v -H "Content-Type: application/json" \
-H "Auth: <id> " \
-H "X-API-Version: 101" \
-X GET https:// <IP> /rest/enclosure-groups

These will result in a large amount of data being dumped, however what is being looked for is the URI of the enclosure groups or the particular server hardware type that your profile is being attached to. With these URIs you can construct a simple one liner to create a blank Server profile as show below:

curl -k -v -H "Content-Type: application/json" \
-H "Auth: <id> " \
-H "X-API-Version: 101" \
-d '{"type":"ServerProfileV4","name":"blankProfile01","serverHardwareTypeUri":"/rest/server-hardware-types/XXXXX","enclosureGroupUri":"/rest/enclosure-groups/XXXXX"}' -X POST -k https:// <IP> /rest/server-profiles

Posted in: Computers

Comments

  1. Avneesh Jain
    October 18, 2016

    Hi, I am not getting any reponse while logging in to the device.

Leave a Reply


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*