Skip to content
Open
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
13 changes: 13 additions & 0 deletions vpd-manager/include/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,18 @@ static constexpr auto systemdService = "org.freedesktop.systemd1";
static constexpr auto systemdObjectPath = "/org/freedesktop/systemd1";
static constexpr auto systemdManagerInterface =
"org.freedesktop.systemd1.Manager";

static constexpr auto vpdCollectionInterface = "com.ibm.VPD.Collection";

// enumerated values of CollectionStatus D-bus property defined under
// com.ibm.VPD.Collection interface.
static constexpr auto vpdCollectionSuccess =
"com.ibm.VPD.Collection.Status.Success";
static constexpr auto vpdCollectionFailure =
"com.ibm.VPD.Collection.Status.Failure";
static constexpr auto vpdCollectionInProgress =
"com.ibm.VPD.Collection.Status.InProgress";
static constexpr auto vpdCollectionNotStarted =
"com.ibm.VPD.Collection.Status.NotStarted";
} // namespace constants
} // namespace vpd
29 changes: 29 additions & 0 deletions vpd-manager/include/utility/dbus_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,5 +564,34 @@ inline int DisableRebootGuard() noexcept
return l_rc;
}

/**
* @brief API to notify FRU VPD Collection status.
*
* This API uses PIM's Notify method to update the given FRU VPD collection
* status on D-bus.
*
* @param[in] i_inventoryPath - D-bus inventory path
* @param[in] i_fruCollectionStatus - FRU VPD collection status.
*
* @return true if update succeeds, false otherwise.
*/
inline bool notifyFRUCollectionStatus(const std::string& i_inventoryPath,
const std::string& i_fruCollectionStatus)
{
types::ObjectMap l_objectMap;
types::InterfaceMap l_interfaceMap;
types::PropertyMap l_propertyMap;

l_propertyMap.emplace("CollectionStatus", i_fruCollectionStatus);
l_interfaceMap.emplace(constants::vpdCollectionInterface, l_propertyMap);
l_objectMap.emplace(i_inventoryPath, l_interfaceMap);

if (!dbusUtility::callPIM(std::move(l_objectMap)))
{
return false;
}

return true;
}
} // namespace dbusUtility
} // namespace vpd
51 changes: 49 additions & 2 deletions vpd-manager/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,14 @@ bool Worker::primeInventory(const std::string& i_vpdFilePath)
processFunctionalProperty(l_Fru["inventoryPath"], l_interfaces);
processEnabledProperty(l_Fru["inventoryPath"], l_interfaces);

// Emplace the default state of FRU VPD collection
types::PropertyMap l_fruCollectionProperty = {
{"CollectionStatus", constants::vpdCollectionNotStarted}};

vpdSpecificUtility::insertOrMerge(l_interfaces,
constants::vpdCollectionInterface,
std::move(l_fruCollectionProperty));

l_objectInterfaceMap.emplace(std::move(l_fruObjectPath),
std::move(l_interfaces));
}
Expand Down Expand Up @@ -1140,6 +1148,14 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
processFunctionalProperty(inventoryPath, interfaces);
processEnabledProperty(inventoryPath, interfaces);

// Update collection status as successful
types::PropertyMap l_collectionProperty = {
{"CollectionStatus", constants::vpdCollectionSuccess}};

vpdSpecificUtility::insertOrMerge(interfaces,
constants::vpdCollectionInterface,
std::move(l_collectionProperty));

objectInterfaceMap.emplace(std::move(fruObjectPath),
std::move(interfaces));
}
Expand Down Expand Up @@ -1414,6 +1430,8 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
std::tuple<bool, std::string>
Worker::parseAndPublishVPD(const std::string& i_vpdFilePath)
{
std::string l_inventoryPath{};

try
{
m_semaphore.acquire();
Expand All @@ -1423,6 +1441,26 @@ std::tuple<bool, std::string>
m_activeCollectionThreadCount++;
m_mutex.unlock();

// Set CollectionStatus as InProgress. Since it's an intermediate state
// D-bus set-property call is good enough to update the status.
try
{
l_inventoryPath = jsonUtility::getInventoryObjPathFromJson(
m_parsedJson, i_vpdFilePath);

dbusUtility::writeDbusProperty(
jsonUtility::getServiceName(m_parsedJson, l_inventoryPath),
l_inventoryPath, constants::vpdCollectionInterface,
"CollectionStatus",
types::DbusVariantType{constants::vpdCollectionInProgress});
}
catch (const std::exception& e)
{
logging::logMessage(
"Unable to set CollectionStatus as InProgress for " +
i_vpdFilePath);
}

const types::VPDMapVariant& parsedVpdMap = parseVpdFile(i_vpdFilePath);

types::ObjectMap objectInterfaceMap;
Expand Down Expand Up @@ -1462,14 +1500,23 @@ std::tuple<bool, std::string>
logging::logMessage(ex.what());
}

// Notify FRU's VPD CollectionStatus as Failure
if (!dbusUtility::notifyFRUCollectionStatus(
l_inventoryPath, constants::vpdCollectionFailure))
{
logging::logMessage(
"Call to PIM Notify method failed to update Collection status as Failure for " +
i_vpdFilePath);
}

// TODO: Figure out a way to clear data in case of any failure at
// runtime.
// Prime the inventry for FRUs which
// are not present/processing had some error.
/* if (!primeInventory(i_vpdFilePath))
{
logging::logMessage("Priming of inventory failed for FRU " +
i_vpdFilePath);
logging::logMessage("Priming of inventory failed for FRU " +
i_vpdFilePath);
}*/
m_semaphore.release();
return std::make_tuple(false, i_vpdFilePath);
Expand Down