diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-11-16 15:21:13 -0600 |
---|---|---|
committer | Matthew Barth <msbarth@linux.vnet.ibm.com> | 2017-12-05 16:11:12 +0000 |
commit | 51dd1856e142d30d0d2c351f3d5eec15a11161b0 (patch) | |
tree | 7b177e113d782242c5d1ffaf46119a8e42337c3f /monitor/fan.cpp | |
parent | d5cfdbe0240f9a5cb0d29fa6e384ad19b2b32cf3 (diff) | |
download | phosphor-fan-presence-51dd1856e142d30d0d2c351f3d5eec15a11161b0.tar.gz phosphor-fan-presence-51dd1856e142d30d0d2c351f3d5eec15a11161b0.zip |
Update fan inventory method
Use the methods provided within sdbusplus.hpp to update fan inventory
along with prepping inventory to be updated for each fan rotor sensor's
functional state.
Change-Id: I7d3026d289b1dd22cd4e7b4457c4d4396309c0b5
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'monitor/fan.cpp')
-rw-r--r-- | monitor/fan.cpp | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp index ba0744a..a6af74a 100644 --- a/monitor/fan.cpp +++ b/monitor/fan.cpp @@ -18,6 +18,7 @@ #include "fan.hpp" #include "types.hpp" #include "utility.hpp" +#include "sdbusplus.hpp" namespace phosphor { @@ -28,14 +29,6 @@ namespace monitor using namespace phosphor::logging; -constexpr auto INVENTORY_PATH = "/xyz/openbmc_project/inventory"; -constexpr auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager"; - -constexpr auto FUNCTIONAL_PROPERTY = "Functional"; -constexpr auto OPERATIONAL_STATUS_INTF = - "xyz.openbmc_project.State.Decorator.OperationalStatus"; - - Fan::Fan(Mode mode, sdbusplus::bus::bus& bus, phosphor::fan::event::EventPtr& events, @@ -221,18 +214,17 @@ void Fan::timerExpired(TachSensor& sensor) void Fan::updateInventory(bool functional) { - ObjectMap objectMap = getObjectMap(functional); - std::string service; - - service = phosphor::fan::util::getInvService(_bus); - - auto msg = _bus.new_method_call(service.c_str(), - INVENTORY_PATH, - INVENTORY_INTF, - "Notify"); - - msg.append(std::move(objectMap)); - auto response = _bus.call(msg); + auto objectMap = util::getObjMap<bool>( + _name, + util::OPERATIONAL_STATUS_INTF, + util::FUNCTIONAL_PROPERTY, + functional); + auto response = util::SDBusPlus::lookupAndCallMethod( + _bus, + util::INVENTORY_PATH, + util::INVENTORY_INTF, + "Notify", + objectMap); if (response.is_method_error()) { log<level::ERR>("Error in Notify call to update inventory"); @@ -243,21 +235,6 @@ void Fan::updateInventory(bool functional) _functional = functional; } - -Fan::ObjectMap Fan::getObjectMap(bool functional) -{ - ObjectMap objectMap; - InterfaceMap interfaceMap; - PropertyMap propertyMap; - - propertyMap.emplace(FUNCTIONAL_PROPERTY, functional); - interfaceMap.emplace(OPERATIONAL_STATUS_INTF, std::move(propertyMap)); - objectMap.emplace(_name, std::move(interfaceMap)); - - return objectMap; -} - - } } } |