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/pdr_numeric_effecter.hpp b/libpldmresponder/pdr_numeric_effecter.hpp
index 1aa525b..402a426 100644
--- a/libpldmresponder/pdr_numeric_effecter.hpp
+++ b/libpldmresponder/pdr_numeric_effecter.hpp
@@ -24,8 +24,9 @@
* @param[out] repo - pdr::RepoInterface
*
*/
-template <class Handler>
-void generateNumericEffecterPDR(const Json& json, Handler& handler,
+template <class DBusInterface, class Handler>
+void generateNumericEffecterPDR(const DBusInterface& dBusIntf, const Json& json,
+ Handler& handler,
pdr_utils::RepoInterface& repo)
{
static const std::vector<Json> emptyList{};
@@ -164,6 +165,17 @@
auto interface = dbusEntry.value("interface", "");
auto propertyName = dbusEntry.value("property_name", "");
auto propertyType = dbusEntry.value("property_type", "");
+
+ try
+ {
+ auto service =
+ dBusIntf.getService(objectPath.c_str(), interface.c_str());
+ }
+ catch (const std::exception& e)
+ {
+ continue;
+ }
+
pldm::utils::DBusMapping dbusMapping{objectPath, interface,
propertyName, propertyType};
DbusMappings dbusMappings{};