Now that HP OneView evolves (1.10 was released with 3PAR support) I want to highlight also some other features which I think they will become more and more important in the near future.
One of them is scripting. For that HP enables the use of REST API’s aka “REpresentational State Transfer Application Programming Interface”.
It is an architectural style defined by Roy Fielding, principal author of the HTTP specification, that describes the characteristics and constraints of a well-designed Web application.
It is a client/server based interface that uses URI’s (Uniform Resource Identifier) to represent any physical devices or logical constructs within OneView.
The REST API uses a relatively simple Create, Read, Update and Delete operations by using HTTP POST, GET, PUT and DELETE commands.
So a possible basic process would look like this:
– Retrieve the current resource: GET /rest/servers/<server-id>to get resource data
– Set the desired state of the resource: “Server.powerState”:”On”
– Update the resource with the new state: PUT /rest/servers/<server-id> to apply the change
Further it operates in a complete stateless mode of operation. This means that no client context is stored on the server between requests which enhances server reliability and scalability.
Know also about the existence of API versioning control. Most HP OneView releases introduce a new “API version” supporting new functionality delivered in that release. For instance OneView 1.10 the API version is 101, initial OneView version 1.0 and 1.01 had API version 3 and 1.05 has API version 4.
It is obvious that newer versions of HP OneView support the older versions of API’s as well.
Although I am a true Windows user, I was curious for the additional functionality of all this.
So let’s get started with the basics.
1 – Install the REST client
I will use the REST client plug-in in Mozilla Firefox since a plug-in for IE does not exist at this moment. Also for Chrome is a REST client available.
Find the plug-in here: https://addons.mozilla.org/en-US/firefox/addon/restclient/
You can confirm by clicking Install Now
2 – Obtain the required HTTP headers
First you have to define some HTTP headers before connecting to HP OneView. Do this by starting the REST client by clicking on the red square at the upper right corner of your browser.
Select in the menu to create a Custom Header
Create a header to set the API version to 101
Create another header to set the Content Type to JSON
3 – Connect to HP OneView using the REST client
First obtain a Session ID when connecting to the OneView appliance
Know that the BODY text is case sensitive and 10.110.232.21 is the IP address of my OneView appliance.
By clicking SEND you should get a similar response
Status Code should be 200 OK, if not some data entry mistake was made. Like I said watch out for case-sensitive commands.
Copy&Paste the obtained Session ID and add it as an additional header in the REST client
Your Headers section should be similar like this. The AUTH values will be different of course.
4 – Retrieve Resource Information using the REST client
To retrieve the HP OneView appliance version, use following command
By clicking SEND you should get a response similar like displayed below
5 – Create a Resource using the REST client
By using following instruction you can create quite easily an Ethernet Network resource in HP OneView
In the HP OneView console it will look like this
Cool, rather easy! Now you just have to get familiar with all the possible REST instructions. The list is long and will get longer with every new API version…
Be sure to check out the REST API reference which can be found (with plenty of other interesting documents) on