Skip to content

Commit 4a152f1

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 4a152f1

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
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/src/worker.cpp

Lines changed: 58 additions & 3 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
}
@@ -1103,6 +1111,7 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
11031111
{
11041112
const auto& inventoryPath = aFru["inventoryPath"];
11051113
sdbusplus::message::object_path fruObjectPath(inventoryPath);
1114+
11061115
if (aFru.contains("ccin"))
11071116
{
11081117
if (!processFruWithCCIN(aFru, parsedVpdMap))
@@ -1139,6 +1148,14 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
11391148
processFunctionalProperty(inventoryPath, interfaces);
11401149
processEnabledProperty(inventoryPath, interfaces);
11411150

1151+
// Update collection status as successful
1152+
types::PropertyMap l_collectionProperty = {
1153+
{"CollectionStatus", constants::vpdCollectionSuccess}};
1154+
1155+
vpdSpecificUtility::insertOrMerge(interfaces,
1156+
constants::vpdCollectionInterface,
1157+
std::move(l_collectionProperty));
1158+
11421159
objectInterfaceMap.emplace(std::move(fruObjectPath),
11431160
std::move(interfaces));
11441161
}
@@ -1375,7 +1392,6 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
13751392

13761393
std::shared_ptr<Parser> vpdParser =
13771394
std::make_shared<Parser>(i_vpdFilePath, m_parsedJson);
1378-
13791395
types::VPDMapVariant l_parsedVpd = vpdParser->parse();
13801396

13811397
// Before returning, as collection is over, check if FRU qualifies for
@@ -1421,6 +1437,9 @@ 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+
const std::string& l_inventoryPath =
1441+
jsonUtility::getInventoryObjPathFromJson(m_parsedJson, i_vpdFilePath);
1442+
14241443
try
14251444
{
14261445
m_semaphore.acquire();
@@ -1430,6 +1449,24 @@ std::tuple<bool, std::string>
14301449
m_activeCollectionThreadCount++;
14311450
m_mutex.unlock();
14321451

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

14351472
types::ObjectMap objectInterfaceMap;
@@ -1469,14 +1506,32 @@ std::tuple<bool, std::string>
14691506
logging::logMessage(ex.what());
14701507
}
14711508

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

0 commit comments

Comments
 (0)