From 59ae877171ef9a7df66c465c45fa89f2d1d89d38 Mon Sep 17 00:00:00 2001 From: Brandon Wyman Date: Thu, 6 Apr 2017 15:05:18 -0500 Subject: Implement updating the inventory properties Implement code needed to update the chassis AirCooled and WaterCooled properties. Change-Id: I9a67d1129e99f841200241e2daae08fb6119d9d3 Signed-off-by: Brandon Wyman --- cooling-type/cooling_type.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'cooling-type/cooling_type.cpp') 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 #include #include +#include #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"); + } } } -- cgit v1.2.1