Exploring the HPE G2 PDU REST API

Lately I’ve been playing around with the Redfish based REST API in the HPE G2 Metered and Switched Power Distribution Units.

Through the API you are able to pull some details about the PDU as well as different utilization data. Based on your PDUs capabilities you should also be able to control different outlets. My focus has been to pull some details about the PDUs, and to pull the load on the different segments.

As I usually do when I set out exploring an API I was looking for the documentation. Surprisingly there was nothing to be found. The only thing I found was a few lines in the PDU User guide regarding authentication.

Luckily as the API is based on the Redfish standard I was able to start exploring it through Postman.

From the user guide I learned that the API used Basic auth for GET requests. So I did a GET to the https://<mgmtIP>/redfish/v1/ , specified Basic auth in the Postman client and boom, I got the schema out

The interesting endpoints and the ones I’m exploring will be the PowerDistribution ones.

There are a few endpoints to check:

  • https://<mgmtIp>/redfish/v1/RackPower/PowerDistribution
    This will list the available PDUs:
  • https://<mgmtIp>/redfish/v1/PowerDistribution/<pduId>
    This is listing details about the specified PDU

    As you can see there’s links to both the LoadsegmentMeasurement, OutletMeasurement and OutletControl for each segment of the specified PDU.
  • https://<mgmtIp>/redfish/v1/PowerDistribution/<pduId>/PowerMeasurement/LoadsegmentMeasurement
    Here we pull the current load of each of the segments on the specified PDU
  • https://<mgmtIp>/redfish/v1/PowerDistribution/<pduId>/PowerMeasurement/Loadsegment/<segmentId>/OutletMeasurement
    Here we’re pulling measurements for each of the different outlets on the specified segment

     
  • https://<mgmtIp>/redfish/v1/PowerDistribution/<pduId>/PowerControl/Loadsegment/<segmentId>/OutletControl
    List the config on the different Outlets on the specified segment

     

As you can see there’s lots of stuff to pull from this API. The most interesting part will of course be the utilization.

As mentioned, based on the capabilities on your PDU you might not be able to pull all of this data, or you might have more info. If you have the switched version you should also be able to actually control the different outlets through the API, but this is something I haven’t been looking at.

 

Postman

To make it easier to explore the API I’ve created a Postman collection that can be imported. The collection includes the examples I’ve shown in this post.

There’s a few variables that needs to be set to correspond with your environment:

  • mgmtIp – Management IP address
  • pduId – The Id of the PDU you want to pull data from. Use the PowerDistributionList example to check the available IDs
  • segmentId – The Id of the LoadSegment you want to pull data from. Use the PowerDistributionUnit example to list the available segments.

You will also need to update the authentication credentials to match your environment.

To learn how you can work with Postman collections check out the Intro to collection in the Postman documentation
The Postman collection and more information about it can be found on Github.

Summary

Hopefully this post can help others out there struggling with getting started with the HPE PDU REST Api. Please reach out if you have any comments.

Rudi

Working with Cloud Infrastructure @ Intility, Oslo Norway. VMware vExpert. Mainly focused on automating Datacenter stuff. All posts are personal

Leave a Reply

Your email address will not be published. Required fields are marked *