|
Adds FanSpeedsPercent information according to the Redfish
EnvironmentMetrics schema [1]. The schema only allows fans of
ReadingType Percent to be included in the FanSpeedsPercent array.
The Redfish Uri supports retrieval of the metrics for a specific
chassis:
```
/redfish/v1/Chassis/<chassisId>/EnvironmentMetrics
```
The fan sensors connected to the chassis are found by:
1) Find all fans associated to the chassis using the 'cooled_by'
endpoint. [3].
2) Find all sensors associated to each fan using the 'sensors'
endpoint. [4]
3) Retrieve the sensor excerpt data for each sensor.
A similar approach to retrieving the sensor data is used here as
for the proposed implementation for ThermalSubsystem/Fans [2].
[1] https://redfish.dmtf.org/schemas/v1/EnvironmentMetrics.v1_3_2.json
[2] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/57657
[3] https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/58300
[4] https://github.com/openbmc/docs/blob/master/architecture/sensor-architecture.md#association-type-2-linking-a-low-level-hardware-item-to-its-sensors
Implementation notes:
- The utility function objectExcerptToJson() is used to populate the
SensorFanArrayExcerpt.
- Altered the objectExcerptToJson() function to take a
sensor::ReadingType value for the optional expected sensor type.
Tested: (using hardware simulator)
- Redfish Validator passes.
- With redfish-allow-rotational-fans disabled:
(Note fans that percent cannot be computed have null for Reading
property.)
```
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Chassis/chassis/EnvironmentMetrics
{
"@odata.id": "/redfish/v1/Chassis/chassis/EnvironmentMetrics",
"@odata.type": "#EnvironmentMetrics.v1_3_0.EnvironmentMetrics",
"FanSpeedsPercent": [
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_0",
"Reading": 100,
"SpeedRPM": 18000.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_1",
"Reading": 60,
"SpeedRPM": 12036.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan1_0",
"Reading": 50,
"SpeedRPM": 18000.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan1_1",
"Reading": 32,
"SpeedRPM": 12036.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan2_0",
"Reading": 50,
"SpeedRPM": 18000.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan2_1",
"Reading": 25,
"SpeedRPM": 12036.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan3_0",
"Reading": null,
"SpeedRPM": 18000.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan3_1",
"Reading": null,
"SpeedRPM": 12036.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan4_0",
"Reading": null,
"SpeedRPM": 18000.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan4_1",
"Reading": null,
"SpeedRPM": 12036.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan5_0",
"Reading": null,
"SpeedRPM": 18000.0
},
{
"DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan5_1",
"Reading": null,
"SpeedRPM": 12036.0
}
],
"FanSpeedsPercent@odata.count": 12,
"Id": "EnvironmentMetrics",
"Name": "Chassis Environment Metrics"
}
```
- Can see DataSourceUri match Sensors fan paths of ReadingType Percent:
```
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Chassis/chassis/Sensors | grep fan
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_0"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_1"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan1_0"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan1_1"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan2_0"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan2_1"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan3_0"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan3_1"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan4_0"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan4_1"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan5_0"
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan5_1"
// E.g.
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_0
{
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_0",
"@odata.type": "#Sensor.v1_11_1.Sensor",
"Id": "fantach_fan0_0",
...
"ReadingType": "Percent",
...
```
- With redfish-allow-rotational-fans enabled the only fans are not
Percent ReadingType so are not added to the FanSpeedsPercent array :
```
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Chassis/chassis/EnvironmentMetrics
{
"@odata.id": "/redfish/v1/Chassis/chassis/EnvironmentMetrics",
"@odata.type": "#EnvironmentMetrics.v1_3_0.EnvironmentMetrics",
"FanSpeedsPercent": [],
"FanSpeedsPercent@odata.count": 0,
"Id": "EnvironmentMetrics",
"Name": "Chassis Environment Metrics"
}
// E.g.
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_0
{
"@odata.id": "/redfish/v1/Chassis/chassis/Sensors/fantach_fan0_0",
"@odata.type": "#Sensor.v1_11_1.Sensor",
"Id": "fantach_fan0_0",
...
"ReadingType": "Rotational",
...
```
Signed-off-by: George Liu <liuxiwei@inspur.com>
Signed-off-by: Janet Adkins <janeta@us.ibm.com>
Change-Id: I4cfc0aa28d68e7e0fa947251363deb6f06e36225
|