summaryrefslogtreecommitdiff
path: root/redfish-core/lib/sensors.hpp
diff options
context:
space:
mode:
authorEddie James <eajames@linux.ibm.com>2019-05-18 00:24:36 +0300
committerEdward A. James <eajames@us.ibm.com>2019-06-05 18:57:53 +0300
commit028f7ebc6626f6b95251ce52a9ed9ed053e48a3e (patch)
tree9f41c94dc27c4d036b36a5917b11d1451ffef226 /redfish-core/lib/sensors.hpp
parent57bff08a75362a05d36354918195c5b7c82006f1 (diff)
downloadbmcweb-028f7ebc6626f6b95251ce52a9ed9ed053e48a3e.tar.xz
Add basic PowerControl and PowerLimit properties
Add code in the power-specific response handler to fetch the Power Limit value for the chassis that implements the Chassis inventory item. Add a special case to the generic sensor handling code to place the total_power value into the PowerControl PowerConsumedWatts field. curl -k https://${bmc}/redfish/v1/Chassis/chassis/Power { "@odata.context": "/redfish/v1/$metadata#Power.Power", "@odata.id": "/redfish/v1/Chassis/chassis/Power", "@odata.type": "#Power.v1_5_2.Power", "Id": "Power", "Name": "Power", "PowerControl": [ { "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/", "MemberId": "total_power", "Name": "total power", "PowerConsumedWatts": 269.0, "Status": { "Health": "OK", "State": "Enabled" } } ], "PowerLimit": [ { "LimitInWatts": null } ], Signed-off-by: Eddie James <eajames@linux.ibm.com> Change-Id: I447de59fb44a4ecbe7b47610d915ac22aef90250
Diffstat (limited to 'redfish-core/lib/sensors.hpp')
-rw-r--r--redfish-core/lib/sensors.hpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index c44ff71d8c..86e5a07986 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -32,7 +32,7 @@ using GetSubTreeType = std::vector<
std::pair<std::string,
std::vector<std::pair<std::string, std::vector<std::string>>>>>;
-using SensorVariant = std::variant<int64_t, double>;
+using SensorVariant = std::variant<int64_t, double, uint32_t, bool>;
using ManagedObjectsVectorType = std::vector<std::pair<
sdbusplus::message::object_path,
@@ -484,7 +484,11 @@ void objectInterfacesToJson(
std::string sensorNameLower =
boost::algorithm::to_lower_copy(sensorName);
- if (sensorNameLower.find("input") != std::string::npos)
+ if (!sensorName.compare("total_power"))
+ {
+ unit = "PowerConsumedWatts";
+ }
+ else if (sensorNameLower.find("input") != std::string::npos)
{
unit = "PowerInputWatts";
}
@@ -550,6 +554,7 @@ void objectInterfacesToJson(
const int64_t* int64Value = std::get_if<int64_t>(&valueVariant);
const double* doubleValue = std::get_if<double>(&valueVariant);
+ const uint32_t* uValue = std::get_if<uint32_t>(&valueVariant);
double temp = 0.0;
if (int64Value != nullptr)
{
@@ -559,6 +564,10 @@ void objectInterfacesToJson(
{
temp = *doubleValue;
}
+ else if (uValue != nullptr)
+ {
+ temp = *uValue;
+ }
else
{
BMCWEB_LOG_ERROR
@@ -920,7 +929,14 @@ void getSensorData(
}
else if (sensorType == "power")
{
- fieldName = "PowerSupplies";
+ if (!sensorName.compare("total_power"))
+ {
+ fieldName = "PowerControl";
+ }
+ else
+ {
+ fieldName = "PowerSupplies";
+ }
}
else
{