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.

Note! Update 2024-04-02: This blog post was created over three years ago. I have been getting some comments on the API calls in this post is obsolete and that things have changed on the PDU APIs. Please refer to the latest documentation for your hardware to get updated information about how to work with your units

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

 1    {
 2        "@odata.context": "/redfish/v1/$metadata#ServiceRoot",
 3        "AccountService": {
 4            "@odata.id": "href/redfish/v1/AccountService"
 5        },
 6        "@odata.type": "#ServiceRoot.1.0.0.ServiceRoot",
 7        "@odata.id": "/redfish/v1",
 8        "Name": "Redfish Root Service",
 9        "PowerDistribution": {
10            "@odata.id": "/redfish/v1/RackPower/PowerDistribution"
11        },
12        "links": {
13            "Session": {
14                "@odata.id": "/redfish/v1/SessionService/Sessions"
15            }
16        },
17        "EventService": {
18            "@odata.id": "href/redfish/v1/EventService"
19        },
20        "Manager": {
21            "@odata.id": "/redfish/v1/Managers"
22        },
23        "SessionService": {
24            "@odata.id": "/redfish/v1/SessionService"
25        },
26        "JsonSchemas": {
27            "@odata.id": "/redfish/v1/Schemas"
28        },
29        "Id": "v1",
30        "RedfishVersion": "1.0.0"
31    }

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

There are a few endpoints to check (I've abbreviated the urls and removed https://mgmtIp/redfish/v1):

  • /RackPower/PowerDistribution

This will list the available PDUs:

 1{
 2    "Members@odata.count": 4,
 3    "@odata.context": "/redfish/v1/$metadata#PowerDistribution",
 4    "@odata.type": "#PowerDistributionCollection.1.0.0.PowerDistributionCollection",
 5    "@odata.id": "/redfish/v1/RackPower/PowerDistribution/",
 6    "Description": "Power Distribution Details",
 7    "Name": "PowerDistribution",
 8    "Members": [
 9        {
10            "@odata.id": "/redfish/v1/PowerDistribution/1"
11        },
12        {
13            "@odata.id": "/redfish/v1/PowerDistribution/2"
14        },
15        {
16            "@odata.id": "/redfish/v1/PowerDistribution/3"
17        },
18        {
19            "@odata.id": "/redfish/v1/PowerDistribution/4"
20        }
21    ]
22}
  • /PowerDistribution/"pduId"

This is listing details about the specified PDU

 1{
 2    "Core_location": "",
 3    "@odata.context": "/redfish/v1/$metadata#PowerDistribution",
 4    "BreakerRating": 0,
 5    "InputRating": 16,
 6    "Model": "230V, 16A, 11.0kVA, 50/60Hz",
 7    "LoadsegmentMeasurement": [
 8        {
 9            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/LoadsegmentMeasurement"
10        }
11    ],
12    "Core_u_position": "",
13    "@odata.type": "#PowerDistribution.1.0.0.PowerDistribution",
14    "Panel_name": "",
15    "@odata.id": "/redfish/v1/PowerDistribution/1",
16    "OutletMeasurement": [
17        {
18            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/Loadsegment/1/OutletMeasurement"
19        },
20        {
21            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/Loadsegment/2/OutletMeasurement"
22        },
23        {
24            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/Loadsegment/3/OutletMeasurement"
25        },
26        {
27            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/Loadsegment/4/OutletMeasurement"
28        },
29        {
30            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/Loadsegment/5/OutletMeasurement"
31        },
32        {
33            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerMeasurement/Loadsegment/6/OutletMeasurement"
34        }
35    ],
36    "Firmware_version": "2.0.0.C",
37    "Serial": "xxxxxx",
38    "Id": 1,
39    "PartNumber": "P9S20A",
40    "DeviceType": "PowerDistributionUnit",
41    "PowerDistributionNumber": 1,
42    "Boot_version": "2.25",
43    "Hardware_version": "HPE",
44    "Voltage": 240,
45    "KVARating": 11,
46    "Power_rating": 11,
47    "OutletControl": [
48        {
49            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerControl/Loadsegment/1/OutletControl"
50        },
51        {
52            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerControl/Loadsegment/2/OutletControl"
53        },
54        {
55            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerControl/Loadsegment/3/OutletControl"
56        },
57        {
58            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerControl/Loadsegment/4/OutletControl"
59        },
60        {
61            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerControl/Loadsegment/5/OutletControl"
62        },
63        {
64            "@odata.id": "/redfish/v1/PowerDistribution/1/PowerControl/Loadsegment/6/OutletControl"
65        }
66    ]
67}

As you can see there's links to both the LoadsegmentMeasurement, OutletMeasurement and OutletControl for each segment of the specified PDU.

  • /PowerDistribution/"pduId"/PowerMeasurement/LoadsegmentMeasurement

Here we pull the current load of each of the segments on the specified PDU

 1{
 2    "@odata.context": "/redfish/v1/$metadata#PowerDistributionUnit",
 3    "@odata.type": "#PowerMeasurement.1.0.0.PowerMeasurement",
 4    "@odata.id": "/redfish/v1/PowerDistribution/PowerMeasurement/LoadsegmentMeasurement",
 5    "Description": "Power Measurement details for the loadsegment",
 6    "Name": "LoadsegmentMeasurement",
 7    "PduId": 1,
 8    "LoadSegment@odata.count": 6,
 9    "Loadsegments": [
10        {
11            "Current": 0,
12            "LoadSegmentId": 1,
13            "BreakerStatus": "Normal",
14            "AppearantPower": 0,
15            "RatedCurrent": 0,
16            "voltage": 0,
17            "ActivePower": 0,
18            "RealPower": 0,
19            "PowerFactor": 1,
20            "Energy": 0
21        },
22        {
23            "Current": 1,
24            "LoadSegmentId": 2,
25            "BreakerStatus": "Normal",
26            "AppearantPower": 399,
27            "RatedCurrent": 0,
28            "voltage": 226,
29            "ActivePower": 386,
30            "RealPower": 46557,
31            "PowerFactor": 0,
32            "Energy": 0
33        },
34        {
35            "Current": 0,
36            "LoadSegmentId": 3,
37            "BreakerStatus": "Normal",
38            "AppearantPower": 79,
39            "RatedCurrent": 0,
40            "voltage": 226,
41            "ActivePower": 22,
42            "RealPower": 38039,
43            "PowerFactor": 0,
44            "Energy": 0
45        },
46        {
47            "Current": 0,
48            "LoadSegmentId": 4,
49            "BreakerStatus": "Normal",
50            "AppearantPower": 0,
51            "RatedCurrent": 0,
52            "voltage": 227,
53            "ActivePower": 0,
54            "RealPower": 0,
55            "PowerFactor": 1,
56            "Energy": 0
57        },
58        {
59            "Current": 0,
60            "LoadSegmentId": 5,
61            "BreakerStatus": "Normal",
62            "AppearantPower": 0,
63            "RatedCurrent": 0,
64            "voltage": 227,
65            "ActivePower": 0,
66            "RealPower": 0,
67            "PowerFactor": 1,
68            "Energy": 0
69        },
70        {
71            "Current": 0,
72            "LoadSegmentId": 6,
73            "BreakerStatus": "Normal",
74            "AppearantPower": 0,
75            "RatedCurrent": 0,
76            "voltage": 230,
77            "ActivePower": 0,
78            "RealPower": 0,
79            "PowerFactor": 1,
80            "Energy": 0
81        }
82    ]
83}
  • /PowerDistribution/"pduId"/PowerMeasurement/Loadsegment/"segmentId"/OutletMeasurement

Here we're pulling measurements for each of the different outlets on the specified segment

 1{
 2    "@odata.context": "/redfish/v1/$metadata#PowerDistribution",
 3    "@odata.type": "#OutletMeasurement.1.0.0.OutletMeasurement",
 4    "@odata.id": "/redfish/v1/PowerDistribution/PowerMeasurement/loadsegment/OutletMeasurement/",
 5    "Description": "Mesurement details for the Outlet per loadsegment",
 6    "Name": "OutletMeasurement",
 7    "PduId": 1,
 8    "Outlet@odata.count": 4,
 9    "LoadsegmentNumber": 1,
10    "Outlets": [
11        {
12            "AlarmStatus": "Normal",
13            "OutletNumber": 1,
14            "EnergyConsumedWattHour": 860869,
15            "ConsumedCurrent": 0,
16            "PowerFactor": 0,
17            "OutputVoltage": 226,
18            "LoadPercentage": 0,
19            "PowerConsumedVoltageAmphere": 154920792,
20            "OutletStatus": "ON",
21            "PowerConsumedWatts": 147
22        },
23        {
24            "AlarmStatus": "Normal",
25            "OutletNumber": 2,
26            "EnergyConsumedWattHour": 140982,
27            "ConsumedCurrent": 0,
28            "PowerFactor": 0,
29            "OutputVoltage": 226,
30            "LoadPercentage": 0,
31            "PowerConsumedVoltageAmphere": 39179829,
32            "OutletStatus": "ON",
33            "PowerConsumedWatts": 18
34        },
35        {
36            "AlarmStatus": "Normal",
37            "OutletNumber": 3,
38            "EnergyConsumedWattHour": 94229,
39            "ConsumedCurrent": 0,
40            "PowerFactor": 0,
41            "OutputVoltage": 226,
42            "LoadPercentage": 0,
43            "PowerConsumedVoltageAmphere": 222622959,
44            "OutletStatus": "ON",
45            "PowerConsumedWatts": 218
46        },
47        {
48            "AlarmStatus": "Normal",
49            "OutletNumber": 4,
50            "EnergyConsumedWattHour": 666750,
51            "ConsumedCurrent": 0,
52            "PowerFactor": 0,
53            "OutputVoltage": 226,
54            "LoadPercentage": 0,
55            "PowerConsumedVoltageAmphere": 41444559,
56            "OutletStatus": "ON",
57            "PowerConsumedWatts": 3
58        }
59    ]
60}
  • /PowerDistribution/"pduId"/PowerControl/Loadsegment/"segmentId"/OutletControl

List the config on the different Outlets on the specified segment

 1{
 2    "@odata.context": "/redfish/v1/$metadata#PowerDistribution",
 3    "@odata.type": "#OutletControl.1.0.0.OutletControl",
 4    "@odata.id": "/redfish/v1/PowerDistribution/PowerControl/Loadsegment/OutletControl",
 5    "Description": "Control the Outlet",
 6    "Name": "OutletControl",
 7    "PduId": 1,
 8    "Outlet@odata.count": 4,
 9    "LoadsegmentNumber": 1,
10    "Outlets": [
11        {
12            "OutletNumber": 2,
13            "StartupState": "on",
14            "OutletName": "OUTLET 2",
15            "OnDelay": 0,
16            "OffDelay": 0,
17            "RebootDelay": 5,
18            "OutletStatus": "on"
19        },
20        {
21            "OutletNumber": 3,
22            "StartupState": "on",
23            "OutletName": "OUTLET 3",
24            "OnDelay": 0,
25            "OffDelay": 0,
26            "RebootDelay": 5,
27            "OutletStatus": "on"
28        },
29        {
30            "OutletNumber": 4,
31            "StartupState": "on",
32            "OutletName": "OUTLET 4",
33            "OnDelay": 0,
34            "OffDelay": 0,
35            "RebootDelay": 5,
36            "OutletStatus": "on"
37        },
38        {
39            "OutletNumber": 5,
40            "StartupState": "on",
41            "OutletName": "OUTLET 5",
42            "OnDelay": 0,
43            "OffDelay": 0,
44            "RebootDelay": 5,
45            "OutletStatus": "on"
46        }
47    ]
48}

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.

This page was modified on April 2, 2024: Added note on new api