libpldmresponder: create PDR when the D-Bus object path exists
On a system where this D-Bus object path does not exist, it should
not create a PDR when the D-Bus object specified here is not found.
Tested: In the PDR config files, the PDR is successfully created when
the objectPath of the D-Bus exists, otherwise, skipped the current
config and the PDR is not created.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ib59fa79cc28d5712161bfb971c37c86c363bafb0
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 88ddcf8..affe52e 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -65,7 +65,8 @@
return dbusObjMaps.at(effecterId);
}
-void Handler::generate(const std::string& dir, Repo& repo)
+void Handler::generate(const pldm::utils::DBusHandler& dBusIntf,
+ const std::string& dir, Repo& repo)
{
if (!fs::exists(dir))
{
@@ -79,14 +80,18 @@
const std::map<Type, generatePDR> generateHandlers = {
{PLDM_STATE_EFFECTER_PDR,
- [this](const auto& json, RepoInterface& repo) {
- pdr_state_effecter::generateStateEffecterPDR<Handler>(json, *this,
- repo);
+ [this](const DBusHandler& dBusIntf, const auto& json,
+ RepoInterface& repo) {
+ pdr_state_effecter::generateStateEffecterPDR<
+ pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this,
+ repo);
}},
{PLDM_NUMERIC_EFFECTER_PDR,
- [this](const auto& json, RepoInterface& repo) {
- pdr_numeric_effecter::generateNumericEffecterPDR<Handler>(
- json, *this, repo);
+ [this](const DBusHandler& dBusIntf, const auto& json,
+ RepoInterface& repo) {
+ pdr_numeric_effecter::generateNumericEffecterPDR<
+ pldm::utils::DBusHandler, Handler>(dBusIntf, json, *this,
+ repo);
}}};
Type pdrType{};
@@ -101,7 +106,7 @@
for (const auto& effecter : effecterPDRs)
{
pdrType = effecter.value("pdrType", 0);
- generateHandlers.at(pdrType)(effecter, repo);
+ generateHandlers.at(pdrType)(dBusIntf, effecter, repo);
}
}
}