Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vpd-manager:Check for essential FRUs #524

Draft
wants to merge 1 commit into
base: 1110
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions vpd-manager/include/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ class Manager
* @param[in] i_msg - The callback message.
*/
void processAssetTagChangeCallback(sdbusplus::message_t& i_msg);

/**
* @brief API to check the presence of essential FRUs.
*
* This API is to check if the FRUs' which are essential are present on the
* system. If not present, PEL is logged.
*/
void checkEssentialFrus();
#endif

/**
Expand Down
1 change: 1 addition & 0 deletions vpd-manager/include/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,6 @@ enum ErrorType
using InventoryCalloutData = std::tuple<std::string, CalloutPriority>;
using DeviceCalloutData = std::tuple<std::string, std::string>;
using I2cBusCalloutData = std::tuple<std::string, std::string, std::string>;
using MapOfObjectsToService = std::unordered_map<std::string, std::string>;
} // namespace types
} // namespace vpd
43 changes: 43 additions & 0 deletions vpd-manager/include/utility/json_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,5 +1049,48 @@ inline std::vector<std::string>
return l_frusReplaceableAtStandby;
}

/**
* @brief API to get D-bus object paths of all essential FRUs.
*
* This API is to get the D-bus object paths of FRUs marked as "essentialFru" in
* system config JSON along with the service name in which the object paths are
* hosted.
*
* @param[in] i_sysCfgJsonObj - System config JSON object.
* @param[out] o_essentialFrus - Map to store essential FRUs object paths and
* the service.
*/
inline void
getEssentialFruObjects(const nlohmann::json& i_sysCfgJsonObj,
types::MapOfObjectsToService& o_essentialFrus)
{
if (i_sysCfgJsonObj.empty() || !i_sysCfgJsonObj.contains("frus"))
{
logging::logMessage(
"System config JSON object is empty/Missing frus section.");
return;
}

const nlohmann::json& l_fruList =
i_sysCfgJsonObj["frus"].get_ref<const nlohmann::json::object_t&>();

for (const auto& l_fru : l_fruList.items())
{
if (i_sysCfgJsonObj["frus"][l_fru.key()].at(0).contains(
"essentialFru") &&
i_sysCfgJsonObj["frus"][l_fru.key()].at(0)["essentialFru"])
{
if (i_sysCfgJsonObj["frus"][l_fru.key()].at(0).contains(
"inventoryPath") &&
i_sysCfgJsonObj["frus"][l_fru.key()].at(0).contains(
"serviceName"))
{
o_essentialFrus.emplace(
i_sysCfgJsonObj["frus"][l_fru.key()].at(0)["inventoryPath"],
i_sysCfgJsonObj["frus"][l_fru.key()].at(0)["serviceName"]);
}
}
}
}
} // namespace jsonUtility
} // namespace vpd
44 changes: 43 additions & 1 deletion vpd-manager/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ void Manager::hostStateChangeCallBack(sdbusplus::message_t& i_msg)
if (*l_hostState == "xyz.openbmc_project.State.Host.HostState."
"TransitioningToRunning")
{
// TODO: check for all the essential FRUs in the system.
// check for all the essential FRUs in the system.
checkEssentialFrus();

// Perform recollection.
performVpdRecollection();
Expand Down Expand Up @@ -853,4 +854,45 @@ void Manager::performVpdRecollection()
std::string(l_ex.what()));
}
}

void Manager::checkEssentialFrus()
{
const nlohmann::json& l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();

types::MapOfObjectsToService l_essentialFruObjects;
jsonUtility::getEssentialFruObjects(l_sysCfgJsonObj, l_essentialFruObjects);

if (l_essentialFruObjects.empty())
{
logging::logMessage("No essential FRUs found.");
return;
}

for (const auto& l_essentialFru : l_essentialFruObjects)
{
const auto& l_essentialFruObject = l_essentialFru.first;

// Read Present property to check the physical presence of the FRU
const auto l_essentialFruPresence = dbusUtility::readDbusProperty(
l_essentialFru.second, l_essentialFruObject,
constants::inventoryItemInf, "Present");

if (const auto l_present = std::get_if<bool>(&l_essentialFruPresence))
{
if (!*l_present)
{
logging::logMessage("Essential FRU " + l_essentialFruObject +
" not present.");
// TODO: Remove the log and create PEL
}
}
else
{
logging::logMessage(
"Present property is not found on D-bus for the essential FRU " +
l_essentialFruObject);
// TODO: Remove the log and create PEL
}
}
}
} // namespace vpd