From 51dd1856e142d30d0d2c351f3d5eec15a11161b0 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Thu, 16 Nov 2017 15:21:13 -0600 Subject: 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 --- monitor/fan.cpp | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) (limited to 'monitor/fan.cpp') 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( + _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("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; -} - - } } } -- cgit v1.2.1