Patch support for sensor overrride
Support added for overriding sensor, which can be
used for validation / ad-hoc debugging. This provides
option to make PATCH call to redfish/v1/<chassisId>/Thermal
or power id. Based on schema, will accept Temperatures /
Voltages collection with properties MemberId and
ReadingCelsius / ReadingVolts.
TODO:
1. Need to make a dynamic way of enabling / disbaling this command.
Unit-Test:
1. Verified sensor values are getting updated by doing PATCH
method to a known sensor. Verified the value got updated
using ipmitool sensor list.
2. Verified negative cases of making PATCH call on invalid
chasisId, Invalid MemberId etc.
Testedeby:
Used Postman tool to issue the PATCH call to the
1. https://xx.xx.xx.xx/redfish/v1/Chassis/XXYYZZ/Thermal with
content
{
"Temperatures": [
{
"MemberId" : "SensorNameXX",
"ReadingCelsius" : valueXX
}
]
}
2. https://xx.xx.xx.xx/redfish/v1/Chassis/XXYYZZ/Power with
content
{
"Voltages": [
{
"MemberId" : "SensorNameXX",
"ReadingVolts" : valueXX
}
]
}
Change-Id: Idf2d891ac0d10b5d20f78c386232cae8a6896f1a
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index d0fbccf..4b2a0a4 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -37,6 +37,10 @@
}
private:
+ std::initializer_list<const char*> typeList = {
+ "/xyz/openbmc_project/sensors/fan",
+ "/xyz/openbmc_project/sensors/temperature",
+ "/xyz/openbmc_project/sensors/fan_pwm"};
void doGet(crow::Response& res, const crow::Request& req,
const std::vector<std::string>& params) override
{
@@ -58,16 +62,16 @@
"/redfish/v1/Chassis/" + chassisName + "/Thermal";
auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
- res, chassisName,
- std::initializer_list<const char*>{
- "/xyz/openbmc_project/sensors/fan",
- "/xyz/openbmc_project/sensors/temperature",
- "/xyz/openbmc_project/sensors/fan_pwm"},
- "Thermal");
+ res, chassisName, typeList, "Thermal");
// TODO Need to get Chassis Redundancy information.
getChassisData(sensorAsyncResp);
}
+ void doPatch(crow::Response& res, const crow::Request& req,
+ const std::vector<std::string>& params) override
+ {
+ setSensorOverride(res, req, params, typeList, "Thermal");
+ }
};
} // namespace redfish