Create objects for existing logs on startup
Use getManagedObjects to find the existing error log
entries, and grab their Logging.Entry property map
to pass to the create function.
Change-Id: I798f13422483fdeea16a5acf54d31919f1c7c096
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/configure.ac b/configure.ac
index 6c88d68..cf833f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,8 @@
[The xyz log manager DBus object path])
AC_DEFINE(LOGGING_IFACE, "xyz.openbmc_project.Logging.Entry",
[The xyz log entry interface])
+AC_DEFINE(LOGGING_BUSNAME, "xyz.openbmc_project.Logging",
+ [The xyz logging busname])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/manager.cpp b/manager.cpp
index 73d77ed..773ef08 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -36,7 +36,38 @@
std::bind(std::mem_fn(&Manager::interfaceRemoved),
this, std::placeholders::_1))
{
- //TODO: createAll();
+ createAll();
+}
+
+void Manager::createAll()
+{
+ auto objects = getManagedObjects(
+ bus, LOGGING_BUSNAME, LOGGING_PATH);
+
+ for (const auto& object : objects)
+ {
+ const auto& interfaces = object.second;
+
+ auto propertyMap = std::find_if(
+ interfaces.begin(),
+ interfaces.end(),
+ [](const auto& i)
+ {
+ return i.first == LOGGING_IFACE;
+ });
+
+ if (propertyMap != interfaces.end())
+ {
+ create(object.first, propertyMap->second);
+ }
+ }
+}
+
+void Manager::create(
+ const std::string& objectPath,
+ const DbusPropertyMap& properties)
+{
+ //TODO
}
void Manager::interfaceAdded(sdbusplus::message::message& msg)
@@ -58,7 +89,7 @@
if (propertyMap != interfaces.end())
{
- //TODO: create(path, propertyMap->second);
+ create(path, propertyMap->second);
}
}
diff --git a/manager.hpp b/manager.hpp
index f779939..53441e6 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -63,6 +63,23 @@
void interfaceRemoved(sdbusplus::message::message& msg);
/**
+ * Creates the IBM interfaces for all existing error log
+ * entries.
+ */
+ void createAll();
+
+ /**
+ * Creates the IBM interface(s) for a single error log.
+ *
+ * @param[in] objectPath - object path of the error log
+ * @param[in] properties - the xyz.openbmc_project.Logging.Entry
+ * properties
+ */
+ void create(
+ const std::string& objectPath,
+ const DbusPropertyMap& properties);
+
+ /**
* Returns the entry ID for a log
*
* @param[in] objectPath - the object path of the log