eBMC-based systems can be managed by using the DMTF Redfish application programming interfaces (APIs). Redfish is a Representational State Transfer (REST) API that is used for platform management and is standardized by the Distributed Management Task Force, Inc.
Chapter 2. Architecture and technical overview 79
There are multiple ways of working with Redfish. One possibility is to use the OS command curl. The following examples show how to work with curl and Redfish.
Before you can get data from the server or run systems management tasks by using Redfish, you must authenticate against the server. After you authenticate by using a user ID and password, you receive a token from the serve that you use later.
Example 2-1 show how to obtain a token.
Example 2-1 Obtaining a token from Redfish
# export eBMC=<IP>
# export USER=admin
# export PASSWORD=<PW>
# export TOKEN=`curl -k -H “Content-Type: application/json” -X POST https://${eBMC}/login -d “{\”username\” : \”${USER}\”, \”password\” : \”${PASSWORD}\”}” | grep token | awk
‘{print $2;}’ | tr -d ‘”‘`
With the token, you can get data from the server. First, request the data of the Redfish root by
using /Redfish/v1. You get data with additional branches in the Redfish tree, for example, Chassis (uppercase C). To dig deeper, use the newly discovered odata.id /Redfish/v1/Chassis, as shown in Example 2-2.
Example 2-2 Getting chassis data from Redfish
#curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/redfish/v1 {
“@odata.id”: “/redfish/v1”,
“@odata.type”: “#ServiceRoot.v1_12_0.ServiceRoot”,
“AccountService”: {
“@odata.id”: “/redfish/v1/AccountService” },
“Cables”: {
“@odata.id”: “/redfish/v1/Cables” },
“CertificateService”: {
“@odata.id”: “/redfish/v1/CertificateService” },
“Chassis”: {
“@odata.id“: “/redfish/v1/Chassis“
},
# curl -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/Redfish/v1/Chassis {
“@odata.id”: “/Redfish/v1/Chassis”,
“@odata.type”: “#ChassisCollection.ChassisCollection”,
“Members“: [
{
“@odata.id“: “/Redfish/v1/Chassis/chassis” }
],
“Members@odata.count”: 1,
“Name”: “Chassis Collection”
# curl -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/Redfish/v1/Chassis/chassis {
“@odata.id”: “/Redfish/v1/Chassis/chassis”,
“@odata.type”: “#Chassis.v1_16_0.Chassis”,
“Actions”: {
… “PCIeSlots”: {
“@odata.id“: “/Redfish/v1/Chassis/chassis/PCIeSlots” },
… “Sensors”: {
“@odata.id“: “/Redfish/v1/Chassis/chassis/Sensors“ },
…
Under Chassis (uppercase C), there is another chassis with a lowercase c. Use the tree with
both (/Redfish/c1/Chassis/chassis). After running the chassis, you can see in Example 2-2
on page 80 for example, that there are PCIeSlots and Sensors, among other resources of the server.
In Example 2-3, you can see what is under Sensors. There you can find the same sensors as
in the ASMI GUI (see Figure 2-18 on page 77). In the output, you find, for example, the
sensor total_power. When you ask for details about that sensor, as shown in Example 2-3, you can see that the server needed 1.426 watts at the time of running the command.
Example 2-3 Getting sensor data from Redfish
# curl -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/Redfish/v1/Chassis/chassis/Sensors {
“@odata.id”: “/Redfish/v1/Chassis/chassis/Sensors”,
“@odata.type”: “#SensorCollection.SensorCollection”,
“Description”: “Collection of Sensors for this Chassis”,
“Members”: [
{
“@odata.id”:
“/Redfish/v1/Chassis/chassis/Sensors/Altitude” },
{
“@odata.id”:
“/Redfish/v1/Chassis/chassis/Sensors/1V1CS_0167_p1_rail_iout” },
…
{
“@odata.id“: “/Redfish/v1/Chassis/chassis/Sensors/total_power”
},
# curl -k -H “X-Auth-Token: $TOKEN” -X GET \ https://${eBMC}/Redfish/v1/Chassis/chassis/Sensors/total_power {
“@odata.id”: “/Redfish/v1/Chassis/chassis/Sensors/total_power”, “@odata.type”: “#Sensor.v1_0_0.Sensor”,
“Id”: “total_power”,
“Name”: “total power”,
“Reading”: 1426.0,
“ReadingRangeMax”: null,
“ReadingRangeMin”: null,
“ReadingType”: “Power”,
“ReadingUnits”: “W”,
“Status”: {
“Health”: “OK”,
“State”: “Enabled”
}
Chapter 2. Architecture and technical overview 81
Some other useful strings to ask for are shown in Example 2-4.
Example 2-4 Other useful Redfish data
#Type and model of the server
# curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/Redfish/v1/Systems/system | grep Model | grep -v SubModel | grep \ -v \”\”
“Model”: “9043-MRX”,
#Serial number
# curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/redfish/v1/Systems/system | grep SerialNumber \
“SerialNumber”: “<SN>”,
#Type, model, and serial number
#curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/redfish/v1/Systems/system | grep AssetTag
“AssetTag”: “Server-9043-MRX-<SN>”,
#System indicator LED
#curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/redfish/v1/Systems/system | grep IndicatorLED
“IndicatorLED”: “Off”,
#Total memory
# curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/redfish/v1/Systems/system | grep TotalSystemMemoryGiB
“TotalSystemMemoryGiB”: 8192
#Power state
# curl -s -k -H “X-Auth-Token: $TOKEN” -X GET https://${eBMC}/redfish/v1/Systems/system | grep PowerState
“PowerState”: “On”,
It is also possible to run operations on the server by using the POST method with the Redfish
API interface. In Example 2-5, you can see the curl commands that can start or stop the server.
Example 2-5 POST command examples for Redfish
#Power on server
# curl -k -H “X-Auth-Token: $TOKEN” -X POST https://${eBMC}/redfish/v1/Systems/
system/Actions/Reset -d ‘{“ResetType”:”On”}’
#Power off server
# curl -k -H “X-Auth-Token: $TOKEN” -X POST https://${eBMC}/redfish/v1/Systems/
system/Actions/Reset -d ‘{“ResetType”:”ForceOff”}’
For more information about Redfish, see Managing the system by using DMTF Redfish APIs. For more information about how to work with Redfish in IBM Power servers, see Managing Power Systems servers by using DMTF Redfish APIs.