PEL: Manager: Implemented the GetPELIdFromBMCLogId dbus method
In OpenPOWER based system, the application may need to get
the PEL id (aka Entry ID (EID) which is a unique id in the PEL) by using
OpenBMC event log id so added the interface for the same.
Tested:
- Tested by below unit test cases.
- With valid OpenBMC Event Log ID
- With invalid OpenBMC Event Log ID
- Tested by using busctl command
- With valid OpenBMC Event Log ID
```
busctl call xyz.openbmc_project.Logging \
/xyz/openbmc_project/logging org.open_power.Logging.PEL \
GetPELIdFromBMCLogId u 4534
>>> u 1342211909
```
- With invalid OpenBMC Event Log ID
```
busctl call xyz.openbmc_project.Logging \
/xyz/openbmc_project/logging org.open_power.Logging.PEL \
GetPELIdFromBMCLogId u 0xFFFFFFFF
>>> Call failed: Invalid argument was given.
```
DBus interface:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/44420
Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com>
Change-Id: I60ff5b86bb82cef2c2d3ceab74c49de5b6f6f99d
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index cedb787..0aa2988 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -701,5 +701,18 @@
}
}
+uint32_t Manager::getPELIdFromBMCLogId(uint32_t bmcLogId)
+{
+ Repository::LogID id{Repository::LogID::Obmc(bmcLogId)};
+ if (auto logId = _repo.getLogID(id); !logId.has_value())
+ {
+ throw common_error::InvalidArgument();
+ }
+ else
+ {
+ return logId->pelID.id;
+ }
+}
+
} // namespace pels
} // namespace openpower