summaryrefslogtreecommitdiffstats
path: root/control
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-05-09 12:15:46 -0500
committerMatthew Barth <msbarth@linux.ibm.com>2018-05-17 17:07:59 +0000
commit803d35bce81427bc82e999c45174fc2e9b6c3871 (patch)
tree6a64382dcf895f395ae1790daf7a71f98431de0f /control
parente0f67c8b81d9b19d277e53c1c1a5c169ef54ed82 (diff)
downloadphosphor-fan-presence-803d35bce81427bc82e999c45174fc2e9b6c3871.tar.gz
phosphor-fan-presence-803d35bce81427bc82e999c45174fc2e9b6c3871.zip
Use shared getProperty function in control manager
When the manager checks a getProperty condition for fan control, it should use the shared getProperty function that now returns a DbusMethodError to better exit/restart the fan control application. Tested: Condition check functions the same Change-Id: I37f83ef4273343bd527ac149ac5eee213d0ad63d Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control')
-rw-r--r--control/manager.cpp58
1 files changed, 7 insertions, 51 deletions
diff --git a/control/manager.cpp b/control/manager.cpp
index d5f97d7..a322c10 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -21,6 +21,7 @@
#include <unistd.h>
#include "manager.hpp"
#include "utility.hpp"
+#include "sdbusplus.hpp"
namespace phosphor
{
@@ -36,50 +37,6 @@ constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
constexpr auto FAN_CONTROL_READY_TARGET = "obmc-fan-control-ready@0.target";
-constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
-constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-
-
-/**
- * Get the current value of the D-Bus property under the specified path
- * and interface.
- *
- * @param[in] bus - The D-Bus bus object
- * @param[in] path - The D-Bus path
- * @param[in] interface - The D-Bus interface
- * @param[in] propertyName - The D-Bus property
- * @param[out] value - The D-Bus property's value
- */
-template <typename T>
-void getProperty(sdbusplus::bus::bus& bus,
- const std::string& path,
- const std::string& interface,
- const std::string& propertyName,
- T& value)
-{
- sdbusplus::message::variant<T> property;
- std::string service = phosphor::fan::util::getService(path, interface, bus);
-
- auto method = bus.new_method_call(service.c_str(),
- path.c_str(),
- PROPERTY_INTERFACE,
- "Get");
-
- method.append(interface, propertyName);
- auto reply = bus.call(method);
-
- if (reply.is_method_error())
- {
- log<level::ERR>("Error in call response for retrieving property");
- elog<InternalFailure>();
- }
- reply.read(property);
- value = sdbusplus::message::variant_ns::get<T>(property);
-}
-
-
/**
* Check if a condition is true. Conditions are used to determine
* which fan zone to use.
@@ -95,17 +52,16 @@ bool checkCondition(sdbusplus::bus::bus& bus, const auto& c)
for (auto& p : properties)
{
- bool value = std::get<propertyValuePos>(p);
- bool propertyValue;
+ auto value = std::get<propertyValuePos>(p);
// TODO openbmc/openbmc#1769: Support more types than just getProperty.
if (type.compare("getProperty") == 0)
{
- getProperty(bus,
- std::get<propertyPathPos>(p),
- std::get<propertyInterfacePos>(p),
- std::get<propertyNamePos>(p),
- propertyValue);
+ auto propertyValue = util::SDBusPlus::getProperty<decltype(value)>(
+ bus,
+ std::get<propertyPathPos>(p),
+ std::get<propertyInterfacePos>(p),
+ std::get<propertyNamePos>(p));
if (value != propertyValue)
{
OpenPOWER on IntegriCloud