monitor: Read fan state from dbus inventory upon starting
tach sensors previously defaulted to functional. Now they default to the
inventory state. For counter-based sensors, nonfunctional state forces
the count to exceed the threshold.
Fan's functional state now depends on the number of functional sensors.
test plan:
1) power-off chassis, stop phosphor-fan-monitor service
2) use busctl to make a fan's tach sensor nonfunctional
3) start fan-monitor
4) verify the fan's state == nonfunctional
5) poweron chassis, verify that fan-monitor updates _sensor_ to
functional
6) fan should remain nonfunctional
7) set Fan to non-present, then to present again (simulate
replacement)
8) observe the fans functional state is now true in inventory
Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Change-Id: I0a109a1d85390c0201f8a54942efcd2fb21a2b65
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 1f2839f..73af8b0 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -253,20 +253,27 @@
return mapperResp;
}
- /** @brief Get service from the mapper. */
- static auto getService(sdbusplus::bus::bus& bus, const std::string& path,
- const std::string& interface)
+ /** @brief Get service from the mapper without checking response. */
+ static auto getServiceRaw(sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface)
{
using namespace std::literals::string_literals;
using GetObject = std::map<std::string, std::vector<std::string>>;
+ return callMethodAndRead<GetObject>(
+ bus, "xyz.openbmc_project.ObjectMapper"s,
+ "/xyz/openbmc_project/object_mapper"s,
+ "xyz.openbmc_project.ObjectMapper"s, "GetObject"s, path,
+ GetObject::mapped_type{interface});
+ }
+
+ /** @brief Get service from the mapper. */
+ static auto getService(sdbusplus::bus::bus& bus, const std::string& path,
+ const std::string& interface)
+ {
try
{
- auto mapperResp = callMethodAndRead<GetObject>(
- bus, "xyz.openbmc_project.ObjectMapper"s,
- "/xyz/openbmc_project/object_mapper"s,
- "xyz.openbmc_project.ObjectMapper"s, "GetObject"s, path,
- GetObject::mapped_type{interface});
+ auto mapperResp = getServiceRaw(bus, path, interface);
if (mapperResp.empty())
{