Skip to content

Commit 274baa5

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 5028d9d commit 274baa5

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

vpd-manager/include/constants.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,17 @@ static constexpr auto eventLoggingServiceName = "xyz.openbmc_project.Logging";
187187
static constexpr auto eventLoggingObjectPath = "/xyz/openbmc_project/logging";
188188
static constexpr auto eventLoggingInterface =
189189
"xyz.openbmc_project.Logging.Create";
190+
static constexpr auto vpdCollectionInterface = "com.ibm.VPD.Collection";
191+
192+
// enumerated values of CollectionStatus D-bus property defined under
193+
// com.ibm.VPD.Collection interface.
194+
static constexpr auto vpdCollectionSuccess =
195+
"com.ibm.VPD.Collection.Status.Success";
196+
static constexpr auto vpdCollectionFailure =
197+
"com.ibm.VPD.Collection.Status.Failure";
198+
static constexpr auto vpdCollectionInProgress =
199+
"com.ibm.VPD.Collection.Status.InProgress";
200+
static constexpr auto vpdCollectionNotStarted =
201+
"com.ibm.VPD.Collection.Status.NotStarted";
190202
} // namespace constants
191203
} // namespace vpd

vpd-manager/src/worker.cpp

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

855+
// Emplace the default state of FRU VPD collection
856+
types::PropertyMap l_fruCollectionProperty = {
857+
{"CollectionStatus", constants::vpdCollectionNotStarted}};
858+
859+
vpdSpecificUtility::insertOrMerge(l_interfaces,
860+
constants::vpdCollectionInterface,
861+
std::move(l_fruCollectionProperty));
862+
855863
l_objectInterfaceMap.emplace(std::move(l_fruObjectPath),
856864
std::move(l_interfaces));
857865
}
@@ -1102,6 +1110,7 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
11021110
{
11031111
const auto& inventoryPath = aFru["inventoryPath"];
11041112
sdbusplus::message::object_path fruObjectPath(inventoryPath);
1113+
11051114
if (aFru.contains("ccin"))
11061115
{
11071116
if (!processFruWithCCIN(aFru, parsedVpdMap))
@@ -1138,6 +1147,14 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
11381147
processFunctionalProperty(inventoryPath, interfaces);
11391148
processEnabledProperty(inventoryPath, interfaces);
11401149

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+
11411158
objectInterfaceMap.emplace(std::move(fruObjectPath),
11421159
std::move(interfaces));
11431160
}
@@ -1374,7 +1391,6 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
13741391

13751392
std::shared_ptr<Parser> vpdParser =
13761393
std::make_shared<Parser>(i_vpdFilePath, m_parsedJson);
1377-
13781394
types::VPDMapVariant l_parsedVpd = vpdParser->parse();
13791395

13801396
// Before returning, as collection is over, check if FRU qualifies for
@@ -1420,6 +1436,9 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
14201436
std::tuple<bool, std::string>
14211437
Worker::parseAndPublishVPD(const std::string& i_vpdFilePath)
14221438
{
1439+
const std::string& l_inventoryPath =
1440+
jsonUtility::getInventoryObjPathFromJson(m_parsedJson, i_vpdFilePath);
1441+
14231442
try
14241443
{
14251444
m_semaphore.acquire();
@@ -1429,6 +1448,24 @@ std::tuple<bool, std::string>
14291448
m_activeCollectionThreadCount++;
14301449
m_mutex.unlock();
14311450

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+
const std::string& l_collStatusProp = "CollectionStatus";
1456+
dbusUtility::writeDbusProperty(
1457+
jsonUtility::getServiceName(m_parsedJson, l_inventoryPath),
1458+
l_inventoryPath, constants::vpdCollectionInterface,
1459+
l_collStatusProp,
1460+
types::DbusVariantType{constants::vpdCollectionInProgress});
1461+
}
1462+
catch (const std::exception& e)
1463+
{
1464+
logging::logMessage(
1465+
"Unable to set CollectionStatus as InProgress for " +
1466+
i_vpdFilePath);
1467+
}
1468+
14321469
const types::VPDMapVariant& parsedVpdMap = parseVpdFile(i_vpdFilePath);
14331470

14341471
types::ObjectMap objectInterfaceMap;
@@ -1468,14 +1505,32 @@ std::tuple<bool, std::string>
14681505
logging::logMessage(ex.what());
14691506
}
14701507

1508+
// update CollectionStatus as Failure
1509+
types::ObjectMap l_objectMap;
1510+
types::InterfaceMap l_interfaceMap;
1511+
types::PropertyMap l_propertyMap;
1512+
1513+
l_propertyMap.emplace("CollectionStatus",
1514+
constants::vpdCollectionFailure);
1515+
l_interfaceMap.emplace(constants::vpdCollectionInterface,
1516+
l_propertyMap);
1517+
l_objectMap.emplace(l_inventoryPath, l_interfaceMap);
1518+
1519+
if (!dbusUtility::callPIM(std::move(l_objectMap)))
1520+
{
1521+
logging::logMessage(
1522+
"Call to PIM Notify method failed to update Collection status as Failure for " +
1523+
i_vpdFilePath);
1524+
}
1525+
14711526
// TODO: Figure out a way to clear data in case of any failure at
14721527
// runtime.
14731528
// Prime the inventry for FRUs which
14741529
// are not present/processing had some error.
14751530
/* if (!primeInventory(i_vpdFilePath))
14761531
{
1477-
logging::logMessage("Priming of inventory failed for FRU " +
1478-
i_vpdFilePath);
1532+
logging::logMessage("Priming of inventory failed for FRU " +
1533+
i_vpdFilePath);
14791534
}*/
14801535
m_semaphore.release();
14811536
return std::make_tuple(false, i_vpdFilePath);

0 commit comments

Comments
 (0)