summaryrefslogtreecommitdiffstats
path: root/cooling-type/cooling_type.cpp
diff options
context:
space:
mode:
authorBrandon Wyman <bjwyman@gmail.com>2017-04-06 15:05:18 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-19 16:19:06 +0000
commit59ae877171ef9a7df66c465c45fa89f2d1d89d38 (patch)
treebc1bb1f3367fc146247664fc41ba9b9044e85d45 /cooling-type/cooling_type.cpp
parentfef0295a8d87754e491dcf133ea927b5c4d56303 (diff)
downloadphosphor-fan-presence-59ae877171ef9a7df66c465c45fa89f2d1d89d38.tar.gz
phosphor-fan-presence-59ae877171ef9a7df66c465c45fa89f2d1d89d38.zip
Implement updating the inventory properties
Implement code needed to update the chassis AirCooled and WaterCooled properties. Change-Id: I9a67d1129e99f841200241e2daae08fb6119d9d3 Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Diffstat (limited to 'cooling-type/cooling_type.cpp')
-rw-r--r--cooling-type/cooling_type.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp
index 66d9ac9..b80d72d 100644
--- a/cooling-type/cooling_type.cpp
+++ b/cooling-type/cooling_type.cpp
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
+#include <utility.hpp>
#include "cooling_type.hpp"
namespace phosphor
@@ -45,11 +46,43 @@ void CoolingType::setupGpio(const std::string& gpioPath)
}
+CoolingType::ObjectMap CoolingType::getObjectMap(const std::string& objpath)
+{
+ ObjectMap invObj;
+ InterfaceMap invIntf;
+ PropertyMap invProp;
+
+ invProp.emplace("AirCooled", airCooled);
+ invProp.emplace("WaterCooled", waterCooled);
+ invIntf.emplace("xyz.openbmc_project.Inventory.Decorator.CoolingType",
+ std::move(invProp));
+ invObj.emplace(objpath, std::move(invIntf));
+
+ return invObj;
+}
+
void CoolingType::updateInventory(const std::string& objpath)
{
- //TODO
- // setProperty(bus, ..., "AirCooled");
- // setProperty(bus, ..., "WaterCooled");
+ using namespace phosphor::logging;
+
+ ObjectMap invObj = getObjectMap(objpath);
+
+ std::string invService;
+
+ invService = phosphor::fan::util::getInvService(bus);
+
+ // Update inventory
+ auto invMsg = bus.new_method_call(invService.c_str(),
+ INVENTORY_PATH,
+ INVENTORY_INTF,
+ "Notify");
+ invMsg.append(std::move(invObj));
+ auto invMgrResponseMsg = bus.call(invMsg);
+ if (invMgrResponseMsg.is_method_error())
+ {
+ throw std::runtime_error(
+ "Error in inventory manager call to update inventory");
+ }
}
}
OpenPOWER on IntegriCloud