diff options
Diffstat (limited to 'redfish-core/lib/sensors.hpp')
-rw-r--r-- | redfish-core/lib/sensors.hpp | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index e6de44d793..002ee3fbdb 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -2637,7 +2637,7 @@ inline void setSensorsOverride( BMCWEB_LOG_INFO("setSensorsOverride for subNode{}", sensorAsyncResp->chassisSubNode); - const char* propertyValueName = nullptr; + std::string_view propertyValueName; std::unordered_map<std::string, std::pair<double, std::string>> overrideMap; std::string memberId; double value = 0.0; @@ -2669,7 +2669,8 @@ inline void setSensorsOverride( } auto getChassisSensorListCb = - [sensorAsyncResp, overrideMap]( + [sensorAsyncResp, overrideMap, + propertyValueNameStr = std::string(propertyValueName)]( const std::shared_ptr<std::set<std::string>>& sensorsList) { // Match sensor names in the PATCH request to those managed by the // chassis node @@ -2691,10 +2692,10 @@ inline void setSensorsOverride( } // Get the connection to which the memberId belongs auto getObjectsWithConnectionCb = - [sensorAsyncResp, - overrideMap](const std::set<std::string>& /*connections*/, - const std::set<std::pair<std::string, std::string>>& - objectsWithConnection) { + [sensorAsyncResp, overrideMap, propertyValueNameStr]( + const std::set<std::string>& /*connections*/, + const std::set<std::pair<std::string, std::string>>& + objectsWithConnection) { if (objectsWithConnection.size() != overrideMap.size()) { BMCWEB_LOG_INFO( @@ -2731,30 +2732,10 @@ inline void setSensorsOverride( messages::internalError(sensorAsyncResp->asyncResp->res); return; } - sdbusplus::asio::setProperty( - *crow::connections::systemBus, item.second, item.first, - "xyz.openbmc_project.Sensor.Value", "Value", - iterator->second.first, - [sensorAsyncResp](const boost::system::error_code& ec) { - if (ec) - { - if (ec.value() == - boost::system::errc::permission_denied) - { - BMCWEB_LOG_WARNING( - "Manufacturing mode is not Enabled...can't " - "Override the sensor value. "); - - messages::insufficientPrivilege( - sensorAsyncResp->asyncResp->res); - return; - } - BMCWEB_LOG_DEBUG( - "setOverrideValueStatus DBUS error: {}", ec); - messages::internalError( - sensorAsyncResp->asyncResp->res); - } - }); + setDbusProperty(sensorAsyncResp->asyncResp, item.second, + item.first, "xyz.openbmc_project.Sensor.Value", + "Value", propertyValueNameStr, + iterator->second.first); } }; // Get object with connection for the given sensor name |