summaryrefslogtreecommitdiffstats
path: root/cooling-type
diff options
context:
space:
mode:
Diffstat (limited to 'cooling-type')
-rw-r--r--cooling-type/Makefile.am10
-rw-r--r--cooling-type/cooling_type.cpp39
-rw-r--r--cooling-type/cooling_type.hpp27
-rw-r--r--cooling-type/main.cpp2
4 files changed, 71 insertions, 7 deletions
diff --git a/cooling-type/Makefile.am b/cooling-type/Makefile.am
index 8be1c3e..8b41812 100644
--- a/cooling-type/Makefile.am
+++ b/cooling-type/Makefile.am
@@ -1,4 +1,5 @@
AM_DEFAULT_SOURCE_EXT = .cpp
+AM_CPPFLAGS = -iquote ${top_srcdir}
sbin_PROGRAMS = \
phosphor-cooling-type
@@ -8,6 +9,13 @@ phosphor_cooling_type_SOURCES = \
argument.cpp \
cooling_type.cpp
-phosphor_cooling_type_LDADD = $(SDBUSPLUS_LIBS)
+phosphor_cooling_type_CXXFLAGS = \
+ $(SDBUSPLUS_CFLAGS) \
+ $(PHOSPHOR_LOGGING_CFLAGS)
+
+phosphor_cooling_type_LDADD = \
+ $(top_builddir)/libfan.la \
+ $(SDBUSPLUS_LIBS) \
+ $(PHOSPHOR_LOGGING_LIBS)
# vim: tabstop=8 noexpandtab
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");
+ }
}
}
diff --git a/cooling-type/cooling_type.hpp b/cooling-type/cooling_type.hpp
index e0240bd..8775a42 100644
--- a/cooling-type/cooling_type.hpp
+++ b/cooling-type/cooling_type.hpp
@@ -13,6 +13,17 @@ constexpr auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager";
class CoolingType
{
+ using Property = std::string;
+ using Value = sdbusplus::message::variant<bool>;
+ // Association between property and its value
+ using PropertyMap = std::map<Property, Value>;
+ using Interface = std::string;
+ // Association between interface and the dbus property
+ using InterfaceMap = std::map<Interface, PropertyMap>;
+ using Object = sdbusplus::message::object_path;
+ // Association between object and the interface
+ using ObjectMap = std::map<Object, InterfaceMap>;
+
public:
CoolingType() = delete;
~CoolingType() = default;
@@ -26,7 +37,7 @@ class CoolingType
*
* @param[in] bus - Dbus bus object
*/
- CoolingType(sdbusplus::bus::bus& bus)
+ CoolingType(sdbusplus::bus::bus& bus) : bus(bus)
{
}
@@ -47,15 +58,27 @@ class CoolingType
/**
* @brief Setup the GPIO device for reading cooling type.
*
- * @param[in] std::string - Path to the GPIO device file to read
+ * @param[in] - Path to object to update
*/
void setupGpio(const std::string&);
private:
+ /** @brief Connection for sdbusplus bus */
+ sdbusplus::bus::bus& bus;
// File descriptor for the GPIO file we are going to read.
phosphor::fan::util::FileDescriptor gpioFd = -1;
bool airCooled = false;
bool waterCooled = false;
+
+ /**
+ * @brief Construct the inventory object map for CoolingType.
+ *
+ * @param[in] - Path to object to update
+ *
+ * @return The inventory object map to update inventory
+ */
+ ObjectMap getObjectMap(const std::string&);
+
};
}
diff --git a/cooling-type/main.cpp b/cooling-type/main.cpp
index cddbe31..91934ea 100644
--- a/cooling-type/main.cpp
+++ b/cooling-type/main.cpp
@@ -1,5 +1,5 @@
#include <iostream>
-#include <memory> //make_unique
+#include <memory>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
#include "argument.hpp"
OpenPOWER on IntegriCloud