Create a DBus notification for each LogEntry
For each log entry, a new FilePath DBus object will be created where
the FilePath.path value is the location of the JSON LogEntry file.
Tested:
Tested with unit tests and locally on a machine.
Signed-off-by: Kasun Athukorala <kasunath@google.com>
Change-Id: I5999826f7b4447bfca88b83c487d7c03a1c84a08
diff --git a/src/main.cpp b/src/main.cpp
index 0b520a9..e81150a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,6 +10,7 @@
#include <boost/asio.hpp>
#include <boost/endian/conversion.hpp>
+#include <sdbusplus/asio/object_server.hpp>
#include <stdplus/fd/create.hpp>
#include <stdplus/fd/impl.hpp>
#include <stdplus/fd/managed.hpp>
@@ -87,11 +88,16 @@
std::make_shared<BufferImpl>(std::move(pciDataHandler));
// rdeCommandHandler initialization
+ std::shared_ptr<sdbusplus::asio::connection> conn =
+ std::make_shared<sdbusplus::asio::connection>(io);
+ conn->request_name("xyz.openbmc_project.bios_bmc_smm_error_logger");
+ sdbusplus::bus::bus& bus = static_cast<sdbusplus::bus::bus&>(*conn);
+
std::unique_ptr<rde::FileHandlerInterface> fileIface =
std::make_unique<rde::ExternalStorerFileWriter>();
std::unique_ptr<rde::ExternalStorerInterface> exFileIface =
std::make_unique<rde::ExternalStorerFileInterface>(
- "/run/bmcweb", std::move(fileIface));
+ bus, "/run/bmcweb", std::move(fileIface));
std::shared_ptr<rde::RdeCommandHandler> rdeCommandHandler =
std::make_unique<rde::RdeCommandHandler>(std::move(exFileIface));
diff --git a/src/rde/external_storer_file.cpp b/src/rde/external_storer_file.cpp
index 0768134..97f2b10 100644
--- a/src/rde/external_storer_file.cpp
+++ b/src/rde/external_storer_file.cpp
@@ -44,10 +44,11 @@
}
ExternalStorerFileInterface::ExternalStorerFileInterface(
- std::string_view rootPath,
+ sdbusplus::bus::bus& bus, std::string_view rootPath,
std::unique_ptr<FileHandlerInterface> fileHandler) :
- rootPath(rootPath),
- fileHandler(std::move(fileHandler)), logServiceId("")
+ bus(bus),
+ rootPath(rootPath), fileHandler(std::move(fileHandler)), logServiceId(""),
+ cperNotifier(std::make_unique<CperFileNotifierHandler>(bus))
{}
bool ExternalStorerFileInterface::publishJson(std::string_view jsonStr)
@@ -115,8 +116,9 @@
}
std::string id = boost::uuids::to_string(randomGen());
- std::string path = "/redfish/v1/Systems/system/LogServices/" +
- logServiceId + "/Entries/" + id;
+ std::string fullPath =
+ fmt::format("{}/redfish/v1/Systems/system/LogServices/{}/Entries/{}",
+ rootPath, logServiceId, id);
// Populate the "Id" with the UUID we generated.
logEntry["Id"] = id;
@@ -124,7 +126,15 @@
// a client.
logEntry.erase("@odata.id");
- return createFile(path, logEntry);
+ if (!fileHandler->createFile(fullPath, logEntry))
+ {
+ fmt::print(stderr, "Failed to create a file for log entry path: {}\n",
+ fullPath);
+ return false;
+ }
+
+ cperNotifier->createEntry(fullPath + "/index.json");
+ return true;
}
bool ExternalStorerFileInterface::processLogService(