Fix - RedFish response for non-manufacturing mode
Issue: If system is not in manufacturing mode, RedFish response is
success but sensor value is not updated
Fix: If the system is not in manufacturing mode, return proper error as
actionNotSupported.
Tested:
1. Redfish validator - passed for this new change
2. Verified RedFish response when system in not manufacturing mode.
Patch: https://<BMC-IP>/redfish/v1/Chassis/<Baseboard>/Thermal
Body:
{
"Temperatures": [
{
"MemberId": "BMC_Temp",
"ReadingCelsius": 34.313
}]
}
Response:
{
"@odata.id": "/redfish/v1/Chassis/<Baseboard>/Thermal",
"@odata.type": "#Thermal.v1_4_0.Thermal",
"Fans": [],
"Id": "Thermal",
"Name": "Thermal",
"Temperatures": [],
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "There are insufficient privileges for the
account or credentials associated with the current
session to perform the requested operation.",
"MessageArgs": [],
"MessageId": "Base.1.8.1.InsufficientPrivilege",
"MessageSeverity": "Critical",
"Resolution": "Either abandon the operation or change the
associated access rights and resubmit the request if the
operation failed."
}
],
"code": "Base.1.8.1.InsufficientPrivilege",
"message": "There are insufficient privileges for the account or
credentials associated with the current session to perform the
requested operation."
}
}
Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: I3c6bfc9d37e1e8648ad0ff713929ad3fd06f437b
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 6257dce..eba0652 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2881,64 +2881,70 @@
}
}
// Get the connection to which the memberId belongs
- auto getObjectsWithConnectionCb =
- [sensorAsyncResp, overrideMap](
- const boost::container::flat_set<std::string>& /*connections*/,
- const std::set<std::pair<std::string, std::string>>&
- objectsWithConnection) {
- if (objectsWithConnection.size() != overrideMap.size())
+ auto getObjectsWithConnectionCb = [sensorAsyncResp, overrideMap](
+ const boost::container::flat_set<
+ std::string>& /*connections*/,
+ const std::set<std::pair<
+ std::string, std::string>>&
+ objectsWithConnection) {
+ if (objectsWithConnection.size() != overrideMap.size())
+ {
+ BMCWEB_LOG_INFO
+ << "Unable to find all objects with proper connection "
+ << objectsWithConnection.size() << " requested "
+ << overrideMap.size() << "\n";
+ messages::resourceNotFound(sensorAsyncResp->asyncResp->res,
+ sensorAsyncResp->chassisSubNode ==
+ sensors::node::thermal
+ ? "Temperatures"
+ : "Voltages",
+ "Count");
+ return;
+ }
+ for (const auto& item : objectsWithConnection)
+ {
+ sdbusplus::message::object_path path(item.first);
+ std::string sensorName = path.filename();
+ if (sensorName.empty())
{
- BMCWEB_LOG_INFO
- << "Unable to find all objects with proper connection "
- << objectsWithConnection.size() << " requested "
- << overrideMap.size() << "\n";
- messages::resourceNotFound(
- sensorAsyncResp->asyncResp->res,
- sensorAsyncResp->chassisSubNode ==
- sensors::node::thermal
- ? "Temperatures"
- : "Voltages",
- "Count");
+ messages::internalError(sensorAsyncResp->asyncResp->res);
return;
}
- for (const auto& item : objectsWithConnection)
- {
- sdbusplus::message::object_path path(item.first);
- std::string sensorName = path.filename();
- if (sensorName.empty())
- {
- messages::internalError(
- sensorAsyncResp->asyncResp->res);
- return;
- }
- const auto& iterator = overrideMap.find(sensorName);
- if (iterator == overrideMap.end())
- {
- BMCWEB_LOG_INFO << "Unable to find sensor object"
- << item.first << "\n";
- messages::internalError(
- sensorAsyncResp->asyncResp->res);
- return;
- }
- crow::connections::systemBus->async_method_call(
- [sensorAsyncResp](const boost::system::error_code ec) {
- if (ec)
+ const auto& iterator = overrideMap.find(sensorName);
+ if (iterator == overrideMap.end())
+ {
+ BMCWEB_LOG_INFO << "Unable to find sensor object"
+ << item.first << "\n";
+ messages::internalError(sensorAsyncResp->asyncResp->res);
+ return;
+ }
+ crow::connections::systemBus->async_method_call(
+ [sensorAsyncResp](const boost::system::error_code ec) {
+ if (ec)
+ {
+ if (ec.value() ==
+ boost::system::errc::permission_denied)
{
- BMCWEB_LOG_DEBUG
- << "setOverrideValueStatus DBUS error: "
- << ec;
- messages::internalError(
+ BMCWEB_LOG_WARNING
+ << "Manufacturing mode is not Enabled...can't "
+ "Override the sensor value. ";
+
+ messages::insufficientPrivilege(
sensorAsyncResp->asyncResp->res);
return;
}
- },
- item.second, item.first,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Sensor.Value", "Value",
- std::variant<double>(iterator->second.first));
- }
- };
+ BMCWEB_LOG_DEBUG
+ << "setOverrideValueStatus DBUS error: " << ec;
+ messages::internalError(
+ sensorAsyncResp->asyncResp->res);
+ }
+ },
+ item.second, item.first, "org.freedesktop.DBus.Properties",
+ "Set", "xyz.openbmc_project.Sensor.Value", "Value",
+ std::variant<double>(iterator->second.first));
+ }
+ };
// Get object with connection for the given sensor name
getObjectsWithConnection(sensorAsyncResp, sensorNames,
std::move(getObjectsWithConnectionCb));