summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-07-07 20:14:02 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-07-19 19:54:42 +0000
commit232f5298dbc62f178b2c23aa474479ea2386b5d9 (patch)
tree3e554139861f307a5ef92a5d34bc43df1f56d660
parent2f05bb56787910da33f5ed2519fc84aed5af88d8 (diff)
downloadphosphor-host-ipmid-232f5298dbc62f178b2c23aa474479ea2386b5d9.tar.gz
phosphor-host-ipmid-232f5298dbc62f178b2c23aa474479ea2386b5d9.zip
Add API to Read the DBUS logging entry object paths
Change-Id: Ib1a9693dea5fa614fe3e4952f32778d8dde225d4 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r--selutility.cpp38
-rw-r--r--selutility.hpp16
2 files changed, 54 insertions, 0 deletions
diff --git a/selutility.cpp b/selutility.cpp
index 3f9d9ab..f52d51e 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -1,5 +1,6 @@
#include <chrono>
#include <vector>
+#include <experimental/filesystem>
#include <phosphor-logging/elog-errors.hpp>
#include "host-ipmid/ipmid-api.h"
#include "xyz/openbmc_project/Common/error.hpp"
@@ -214,6 +215,43 @@ std::chrono::seconds getEntryTimeStamp(const std::string& objPath)
return std::chrono::duration_cast<std::chrono::seconds>(chronoTimeStamp);
}
+void readLoggingObjectPaths(ObjectPaths& paths)
+{
+ sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
+ auto depth = 0;
+ paths.clear();
+
+ auto mapperCall = bus.new_method_call(mapperBusName,
+ mapperObjPath,
+ mapperIntf,
+ "GetSubTreePaths");
+ mapperCall.append(logBasePath);
+ mapperCall.append(depth);
+ mapperCall.append(ObjectPaths({logEntryIntf}));
+
+ auto reply = bus.call(mapperCall);
+ if (reply.is_method_error())
+ {
+ log<level::INFO>("Error in reading logging entry object paths");
+ }
+ else
+ {
+ reply.read(paths);
+
+ std::sort(paths.begin(), paths.end(), [](const std::string& a,
+ const std::string& b)
+ {
+ namespace fs = std::experimental::filesystem;
+ fs::path pathA(a);
+ fs::path pathB(b);
+ auto idA = std::stoul(pathA.filename().string());
+ auto idB = std::stoul(pathB.filename().string());
+
+ return idA < idB;
+ });
+ }
+}
+
} // namespace sel
} // namespace ipmi
diff --git a/selutility.hpp b/selutility.hpp
index 2cae8c3..164ebe6 100644
--- a/selutility.hpp
+++ b/selutility.hpp
@@ -20,6 +20,7 @@ static constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete";
static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
+using ObjectPaths = std::vector<std::string>;
using PropertyType = sdbusplus::message::variant<bool, uint32_t, uint64_t,
std::string, std::vector<std::string>>;
@@ -122,6 +123,21 @@ GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath);
*/
std::chrono::seconds getEntryTimeStamp(const std::string& objPath);
+/** @brief Read the logging entry object paths
+ *
+ * This API would read the logging dbus logging entry object paths and sorting
+ * the filename in the numeric order. The paths is cleared before populating
+ * the object paths.
+ *
+ * @param[in,out] paths - sorted list of logging entry object paths.
+ *
+ * @note This function is invoked when the Get SEL Info command or the Delete
+ * SEL entry command is invoked. The Get SEL Entry command is preceded
+ * typically by Get SEL Info command, so readLoggingObjectPaths is not
+ * invoked before each Get SEL entry command.
+ */
+void readLoggingObjectPaths(ObjectPaths& paths);
+
namespace internal
{
OpenPOWER on IntegriCloud