Adding Platform specific PDR support
- Adding platform check to generate pdr based on platform type.
- Currently PDR generation is happening based on default
configuration, so this commit adds support to generate PDR's based
in the platform type.
Testing:
- Added traces and check from which path the files has been taken for
pdr generation.
- Removed power supply from default path and oem layer and identified
that power supply pdr is not generating.
Change-Id: I6bedf06be7392e02c1ad32af7a552a5a4d6d42c0
Signed-off-by: Kamalkumar Patel <kamalkumar.patel@ibm.com>
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 7587a16..70ac4bc 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -66,11 +66,15 @@
}
void Handler::generate(const pldm::utils::DBusHandler& dBusIntf,
- const std::string& dir, Repo& repo)
+ const std::vector<fs::path>& dir, Repo& repo)
{
- if (!fs::exists(dir))
+ for (const auto& directory : dir)
{
- return;
+ info("checking if : {DIR} exists", "DIR", directory);
+ if (!fs::exists(directory))
+ {
+ return;
+ }
}
// A map of PDR type to a lambda that handles creation of that PDR type.
@@ -100,50 +104,55 @@
}}};
Type pdrType{};
- for (const auto& dirEntry : fs::directory_iterator(dir))
+ for (const auto& directory : dir)
{
- try
+ for (const auto& dirEntry : fs::directory_iterator(directory))
{
- auto json = readJson(dirEntry.path().string());
- if (!json.empty())
+ try
{
- auto effecterPDRs = json.value("effecterPDRs", empty);
- for (const auto& effecter : effecterPDRs)
+ if (fs::is_regular_file(dirEntry.path().string()))
{
- pdrType = effecter.value("pdrType", 0);
- generateHandlers.at(pdrType)(dBusIntf, effecter, repo);
- }
+ auto json = readJson(dirEntry.path().string());
+ if (!json.empty())
+ {
+ auto effecterPDRs = json.value("effecterPDRs", empty);
+ for (const auto& effecter : effecterPDRs)
+ {
+ pdrType = effecter.value("pdrType", 0);
+ generateHandlers.at(pdrType)(dBusIntf, effecter,
+ repo);
+ }
- auto sensorPDRs = json.value("sensorPDRs", empty);
- for (const auto& sensor : sensorPDRs)
- {
- pdrType = sensor.value("pdrType", 0);
- generateHandlers.at(pdrType)(dBusIntf, sensor, repo);
+ auto sensorPDRs = json.value("sensorPDRs", empty);
+ for (const auto& sensor : sensorPDRs)
+ {
+ pdrType = sensor.value("pdrType", 0);
+ generateHandlers.at(pdrType)(dBusIntf, sensor,
+ repo);
+ }
+ }
}
}
- }
- catch (const InternalFailure& e)
- {
- error(
- "PDR config directory does not exist or empty, TYPE= {PDR_TYPE} PATH={DIR_PATH} ERROR={ERR_EXCEP}",
- "PDR_TYPE", pdrType, "DIR_PATH", dirEntry.path().string(),
- "ERR_EXCEP", e.what());
- }
- catch (const Json::exception& e)
- {
- error(
- "Failed parsing PDR JSON file, TYPE={PDR_TYPE} ERROR={ERR_EXCEP}",
- "PDR_TYPE", pdrType, "ERR_EXCEP", e.what());
- pldm::utils::reportError(
- "xyz.openbmc_project.bmc.pldm.InternalFailure");
- }
- catch (const std::exception& e)
- {
- error(
- "Failed parsing PDR JSON file, TYPE= {PDR_TYPE} ERROR={ERR_EXCEP}",
- "PDR_TYPE", pdrType, "ERR_EXCEP", e.what());
- pldm::utils::reportError(
- "xyz.openbmc_project.bmc.pldm.InternalFailure");
+ catch (const InternalFailure& e)
+ {
+ error(
+ "PDR config directory '{PATH}' does not exist or empty for '{TYPE}' pdr: {ERROR}",
+ "TYPE", pdrType, "PATH", dirEntry.path(), "ERROR", e);
+ }
+ catch (const Json::exception& e)
+ {
+ error("Failed parsing PDR JSON file for '{TYPE}' pdr: {ERROR}",
+ "TYPE", pdrType, "ERROR", e);
+ pldm::utils::reportError(
+ "xyz.openbmc_project.PLDM.Error.Generate.PDRJsonFileParseFail");
+ }
+ catch (const std::exception& e)
+ {
+ error("Failed parsing PDR JSON file for '{TYPE}' pdr: {ERROR}",
+ "TYPE", pdrType, "ERROR", e);
+ pldm::utils::reportError(
+ "xyz.openbmc_project.PLDM.Error.Generate.PDRJsonFileParseFail");
+ }
}
}
}
@@ -172,11 +181,25 @@
if (!pdrCreated)
{
generateTerminusLocatorPDR(pdrRepo);
- generate(*dBusIntf, pdrJsonsDir, pdrRepo);
+ if (platformConfigHandler)
+ {
+ auto systemType = platformConfigHandler->getPlatformName();
+ if (systemType.has_value())
+ {
+ // In case of normal poweron , the system type would have been
+ // already filled by entity manager when ever BMC reaches Ready
+ // state. If this is not filled by time we get a getpdr request
+ // we can assume that the entity manager service is not present
+ // on this system & continue to build the common PDR's.
+ pdrJsonsDir.push_back(pdrJsonDir / systemType.value());
+ }
+ }
+
if (oemPlatformHandler != nullptr)
{
oemPlatformHandler->buildOEMPDR(pdrRepo);
}
+ generate(*dBusIntf, pdrJsonsDir, pdrRepo);
pdrCreated = true;