Skip to content

Commit 6956b31

Browse files
worker::CollectionStatus for each inventory FRU
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]>
1 parent 8cc458c commit 6956b31

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed

vpd-manager/include/constants.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,18 @@ static constexpr auto systemdService = "org.freedesktop.systemd1";
192192
static constexpr auto systemdObjectPath = "/org/freedesktop/systemd1";
193193
static constexpr auto systemdManagerInterface =
194194
"org.freedesktop.systemd1.Manager";
195+
196+
static constexpr auto vpdCollectionInterface = "com.ibm.VPD.Collection";
197+
198+
// enumerated values of CollectionStatus D-bus property defined under
199+
// com.ibm.VPD.Collection interface.
200+
static constexpr auto vpdCollectionSuccess =
201+
"com.ibm.VPD.Collection.Status.Success";
202+
static constexpr auto vpdCollectionFailure =
203+
"com.ibm.VPD.Collection.Status.Failure";
204+
static constexpr auto vpdCollectionInProgress =
205+
"com.ibm.VPD.Collection.Status.InProgress";
206+
static constexpr auto vpdCollectionNotStarted =
207+
"com.ibm.VPD.Collection.Status.NotStarted";
195208
} // namespace constants
196209
} // namespace vpd

vpd-manager/include/utility/vpd_specific_utility.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,5 +552,35 @@ inline void resetDataUnderPIM(const std::string& i_objectPath,
552552
" with error: " + std::string(l_ex.what()));
553553
}
554554
}
555+
556+
/**
557+
* @brief API to notify FRU VPD Collection status.
558+
*
559+
* This API uses PIM's Notify method to update the given FRU VPD collection
560+
* status on D-bus.
561+
*
562+
* @param[in] i_inventoryPath - D-bus inventory path
563+
* @param[in] i_fruCollectionStatus - FRU VPD collection status.
564+
*
565+
* @return true if update succeeds, false otherwise.
566+
*/
567+
inline bool notifyFRUCollectionStatus(const std::string& i_inventoryPath,
568+
const std::string& i_fruCollectionStatus)
569+
{
570+
types::ObjectMap l_objectMap;
571+
types::InterfaceMap l_interfaceMap;
572+
types::PropertyMap l_propertyMap;
573+
574+
l_propertyMap.emplace("CollectionStatus", i_fruCollectionStatus);
575+
l_interfaceMap.emplace(constants::vpdCollectionInterface, l_propertyMap);
576+
l_objectMap.emplace(i_inventoryPath, l_interfaceMap);
577+
578+
if (!dbusUtility::callPIM(std::move(l_objectMap)))
579+
{
580+
return false;
581+
}
582+
583+
return true;
584+
}
555585
} // namespace vpdSpecificUtility
556586
} // namespace vpd

vpd-manager/src/worker.cpp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,14 @@ bool Worker::primeInventory(const std::string& i_vpdFilePath)
853853
processFunctionalProperty(l_Fru["inventoryPath"], l_interfaces);
854854
processEnabledProperty(l_Fru["inventoryPath"], l_interfaces);
855855

856+
// Emplace the default state of FRU VPD collection
857+
types::PropertyMap l_fruCollectionProperty = {
858+
{"CollectionStatus", constants::vpdCollectionNotStarted}};
859+
860+
vpdSpecificUtility::insertOrMerge(l_interfaces,
861+
constants::vpdCollectionInterface,
862+
std::move(l_fruCollectionProperty));
863+
856864
l_objectInterfaceMap.emplace(std::move(l_fruObjectPath),
857865
std::move(l_interfaces));
858866
}
@@ -1139,6 +1147,14 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
11391147
processFunctionalProperty(inventoryPath, interfaces);
11401148
processEnabledProperty(inventoryPath, interfaces);
11411149

1150+
// Update collection status as successful
1151+
types::PropertyMap l_collectionProperty = {
1152+
{"CollectionStatus", constants::vpdCollectionSuccess}};
1153+
1154+
vpdSpecificUtility::insertOrMerge(interfaces,
1155+
constants::vpdCollectionInterface,
1156+
std::move(l_collectionProperty));
1157+
11421158
objectInterfaceMap.emplace(std::move(fruObjectPath),
11431159
std::move(interfaces));
11441160
}
@@ -1421,6 +1437,8 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
14211437
std::tuple<bool, std::string>
14221438
Worker::parseAndPublishVPD(const std::string& i_vpdFilePath)
14231439
{
1440+
std::string l_inventoryPath{};
1441+
14241442
try
14251443
{
14261444
m_semaphore.acquire();
@@ -1430,6 +1448,27 @@ std::tuple<bool, std::string>
14301448
m_activeCollectionThreadCount++;
14311449
m_mutex.unlock();
14321450

1451+
// Set CollectionStatus as InProgress. Since it's an intermediate state
1452+
// D-bus set-property call is good enough to update the status.
1453+
try
1454+
{
1455+
l_inventoryPath = jsonUtility::getInventoryObjPathFromJson(
1456+
m_parsedJson, i_vpdFilePath);
1457+
const std::string& l_collStatusProp = "CollectionStatus";
1458+
1459+
dbusUtility::writeDbusProperty(
1460+
jsonUtility::getServiceName(m_parsedJson, l_inventoryPath),
1461+
l_inventoryPath, constants::vpdCollectionInterface,
1462+
l_collStatusProp,
1463+
types::DbusVariantType{constants::vpdCollectionInProgress});
1464+
}
1465+
catch (const std::exception& e)
1466+
{
1467+
logging::logMessage(
1468+
"Unable to set CollectionStatus as InProgress for " +
1469+
i_vpdFilePath);
1470+
}
1471+
14331472
const types::VPDMapVariant& parsedVpdMap = parseVpdFile(i_vpdFilePath);
14341473

14351474
types::ObjectMap objectInterfaceMap;
@@ -1469,14 +1508,23 @@ std::tuple<bool, std::string>
14691508
logging::logMessage(ex.what());
14701509
}
14711510

1511+
// Notify FRU's VPD CollectionStatus as Failure
1512+
if (!vpdSpecificUtility::notifyFRUCollectionStatus(
1513+
l_inventoryPath, constants::vpdCollectionFailure))
1514+
{
1515+
logging::logMessage(
1516+
"Call to PIM Notify method failed to update Collection status as Failure for " +
1517+
i_vpdFilePath);
1518+
}
1519+
14721520
// TODO: Figure out a way to clear data in case of any failure at
14731521
// runtime.
14741522
// Prime the inventry for FRUs which
14751523
// are not present/processing had some error.
14761524
/* if (!primeInventory(i_vpdFilePath))
14771525
{
1478-
logging::logMessage("Priming of inventory failed for FRU " +
1479-
i_vpdFilePath);
1526+
logging::logMessage("Priming of inventory failed for FRU " +
1527+
i_vpdFilePath);
14801528
}*/
14811529
m_semaphore.release();
14821530
return std::make_tuple(false, i_vpdFilePath);

0 commit comments

Comments
 (0)