Skip to content

Commit

Permalink
worker::CollectionStatus for each inventory FRU
Browse files Browse the repository at this point in the history
This commit implements CollectionStatus D-bus property
under com.ibm.VPD.Collection D-bus interface for each
inventory D-bus object path which represents a FRU.

The property tells the current status of VPD collection
for a given FRU's D-bus object path.

The property takes the below enum values:

>>>com.ibm.VPD.Collection.Status.Success
-------------------------------------
This value is assigned when VPD collection is successful.

>>>com.ibm.VPD.Collection.Status.Failure
-------------------------------------
VPD collection failure due to VPD exceptions.

>>>com.ibm.VPD.Collection.Status.InProgress
----------------------------------------
This value is assigned when VPD collection starts
for the given FRU.

>>>com.ibm.VPD.Collection.Status.NotStarted
----------------------------------------
This default value is assigned when we hit prime inventory path.

Test:
1. VPD parsing failed for /sys/bus/i2c/drivers/at24/0-0051/eeprom due to error: Unable to determine VPD format

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.NotStarted"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.InProgress"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.Failure"

2. FRU not found

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.NotStarted"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.InProgress"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.Failure"

3. Successful collection of VPD

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.Success"

Change-Id: Ia5010a181f720454bb51538d6fcf308daf6b75ca
Signed-off-by: Priyanga Ramasamy <[email protected]>
  • Loading branch information
PriyangaRamasamy committed Jan 13, 2025
1 parent 8cc458c commit 4a152f1
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
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
61 changes: 58 additions & 3 deletions vpd-manager/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,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 @@ -1103,6 +1111,7 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
{
const auto& inventoryPath = aFru["inventoryPath"];
sdbusplus::message::object_path fruObjectPath(inventoryPath);

if (aFru.contains("ccin"))
{
if (!processFruWithCCIN(aFru, parsedVpdMap))
Expand Down Expand Up @@ -1139,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 @@ -1375,7 +1392,6 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)

std::shared_ptr<Parser> vpdParser =
std::make_shared<Parser>(i_vpdFilePath, m_parsedJson);

types::VPDMapVariant l_parsedVpd = vpdParser->parse();

// Before returning, as collection is over, check if FRU qualifies for
Expand Down Expand Up @@ -1421,6 +1437,9 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
std::tuple<bool, std::string>
Worker::parseAndPublishVPD(const std::string& i_vpdFilePath)
{
const std::string& l_inventoryPath =
jsonUtility::getInventoryObjPathFromJson(m_parsedJson, i_vpdFilePath);

try
{
m_semaphore.acquire();
Expand All @@ -1430,6 +1449,24 @@ 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
{
const std::string& l_collStatusProp = "CollectionStatus";
dbusUtility::writeDbusProperty(
jsonUtility::getServiceName(m_parsedJson, l_inventoryPath),
l_inventoryPath, constants::vpdCollectionInterface,
l_collStatusProp,
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 @@ -1469,14 +1506,32 @@ std::tuple<bool, std::string>
logging::logMessage(ex.what());
}

// update CollectionStatus as Failure
types::ObjectMap l_objectMap;
types::InterfaceMap l_interfaceMap;
types::PropertyMap l_propertyMap;

l_propertyMap.emplace("CollectionStatus",
constants::vpdCollectionFailure);
l_interfaceMap.emplace(constants::vpdCollectionInterface,
l_propertyMap);
l_objectMap.emplace(l_inventoryPath, l_interfaceMap);

if (!dbusUtility::callPIM(std::move(l_objectMap)))
{
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

0 comments on commit 4a152f1

Please sign in to comment.