Remove checkAndDoSensorsOverride function
Remove checkAndDoSensorsOverride function, this will be handled via dbus-sensor when the user set-value from external.
This is unlikely to break any users because the Intel special mode function is no change, only move to dbus-sensor to handle, "busctl" command also belongs to the external setting, so move to dbus-sensor is more suitable, this will including users to set value use busctl command and Redfish from external.
Dbus-sensor needs to be merged at the same time.
Dbus-sensor changes are pushed to Gerrit:
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/42453
The mailing list discussion links:
https://lists.ozlabs.org/pipermail/openbmc/2021-March/025597.html
Signed-off-by: Bruce Lee <Bruce_Lee@quantatw.com>
Change-Id: I74356f2b65e41cc0e9d8947c160f313334b78331
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 3cc0224..349c1f5 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -349,7 +349,7 @@
allCollections;
allCollections.emplace("Voltages",
*std::move(voltageCollections));
- checkAndDoSensorsOverride(sensorAsyncResp, allCollections);
+ setSensorsOverride(sensorAsyncResp, allCollections);
}
});
}
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 0fc7e70..b476d32 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2938,136 +2938,6 @@
getChassis(sensorAsyncResp, std::move(getChassisSensorListCb));
}
-inline bool isOverridingAllowed(const std::string& manufacturingModeStatus)
-{
- if (manufacturingModeStatus ==
- "xyz.openbmc_project.Control.Security.SpecialMode.Modes.Manufacturing")
- {
- return true;
- }
-
-#ifdef BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE
- if (manufacturingModeStatus == "xyz.openbmc_project.Control.Security."
- "SpecialMode.Modes.ValidationUnsecure")
- {
- return true;
- }
-
-#endif
-
- return false;
-}
-
-/**
- * @brief Entry point for Checking the manufacturing mode before doing sensor
- * override values of given sensor
- *
- * @param sensorAsyncResp response object
- * @param allCollections Collections extract from sensors' request patch info
- * @param chassisSubNode Chassis Node for which the query has to happen
- */
-inline void checkAndDoSensorsOverride(
- const std::shared_ptr<SensorsAsyncResp>& sensorAsyncResp,
- std::unordered_map<std::string, std::vector<nlohmann::json>>&
- allCollections)
-{
- BMCWEB_LOG_INFO << "checkAndDoSensorsOverride for subnode"
- << sensorAsyncResp->chassisSubNode << "\n";
-
- const std::array<std::string, 1> interfaces = {
- "xyz.openbmc_project.Security.SpecialMode"};
-
- crow::connections::systemBus->async_method_call(
- [sensorAsyncResp, allCollections](const boost::system::error_code ec2,
- const GetSubTreeType& resp) mutable {
- if (ec2)
- {
- BMCWEB_LOG_DEBUG
- << "Error in querying GetSubTree with Object Mapper. "
- << ec2;
- messages::internalError(sensorAsyncResp->asyncResp->res);
- return;
- }
-#ifdef BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE
- // Proceed with sensor override
- setSensorsOverride(sensorAsyncResp, allCollections);
- return;
-#endif
-
- if (resp.size() != 1)
- {
- BMCWEB_LOG_WARNING
- << "Overriding sensor value is not allowed - Internal "
- "error in querying SpecialMode property.";
- messages::internalError(sensorAsyncResp->asyncResp->res);
- return;
- }
- const std::string& path = resp[0].first;
- const std::string& serviceName = resp[0].second.begin()->first;
-
- if (path.empty() || serviceName.empty())
- {
- BMCWEB_LOG_DEBUG
- << "Path or service name is returned as empty. ";
- messages::internalError(sensorAsyncResp->asyncResp->res);
- return;
- }
-
- // Sensor override is allowed only in manufacturing mode or
- // validation unsecure mode .
- crow::connections::systemBus->async_method_call(
- [sensorAsyncResp, allCollections,
- path](const boost::system::error_code ec,
- std::variant<std::string>& getManufactMode) mutable {
- if (ec)
- {
- BMCWEB_LOG_DEBUG
- << "Error in querying Special mode property " << ec;
- messages::internalError(
- sensorAsyncResp->asyncResp->res);
- return;
- }
-
- const std::string* manufacturingModeStatus =
- std::get_if<std::string>(&getManufactMode);
-
- if (nullptr == manufacturingModeStatus)
- {
- BMCWEB_LOG_DEBUG << "Sensor override mode is not "
- "Enabled. Returning ... ";
- messages::internalError(
- sensorAsyncResp->asyncResp->res);
- return;
- }
-
- if (isOverridingAllowed(*manufacturingModeStatus))
- {
- BMCWEB_LOG_INFO << "Manufacturing mode is Enabled. "
- "Proceeding further... ";
- setSensorsOverride(sensorAsyncResp, allCollections);
- }
- else
- {
- BMCWEB_LOG_WARNING
- << "Manufacturing mode is not Enabled...can't "
- "Override the sensor value. ";
-
- messages::actionNotSupported(
- sensorAsyncResp->asyncResp->res,
- "Overriding of Sensor Value for non "
- "manufacturing mode");
- return;
- }
- },
- serviceName, path, "org.freedesktop.DBus.Properties", "Get",
- "xyz.openbmc_project.Security.SpecialMode", "SpecialMode");
- },
-
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 5, interfaces);
-}
-
/**
* @brief Retrieves mapping of Redfish URIs to sensor value property to D-Bus
* path of the sensor.
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index 078da9c..ff1bc95 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -92,7 +92,7 @@
{
allCollections.emplace("Fans", *std::move(fanCollections));
}
- checkAndDoSensorsOverride(sensorsAsyncResp, allCollections);
+ setSensorsOverride(sensorsAsyncResp, allCollections);
});
}