Skip to content

Commit 5ff3795

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 676ae9e commit 5ff3795

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-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/dbus_utility.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,5 +564,34 @@ inline int DisableRebootGuard() noexcept
564564
return l_rc;
565565
}
566566

567+
/**
568+
* @brief API to notify FRU VPD Collection status.
569+
*
570+
* This API uses PIM's Notify method to update the given FRU VPD collection
571+
* status on D-bus.
572+
*
573+
* @param[in] i_inventoryPath - D-bus inventory path
574+
* @param[in] i_fruCollectionStatus - FRU VPD collection status.
575+
*
576+
* @return true if update succeeds, false otherwise.
577+
*/
578+
inline bool notifyFRUCollectionStatus(const std::string& i_inventoryPath,
579+
const std::string& i_fruCollectionStatus)
580+
{
581+
types::ObjectMap l_objectMap;
582+
types::InterfaceMap l_interfaceMap;
583+
types::PropertyMap l_propertyMap;
584+
585+
l_propertyMap.emplace("CollectionStatus", i_fruCollectionStatus);
586+
l_interfaceMap.emplace(constants::vpdCollectionInterface, l_propertyMap);
587+
l_objectMap.emplace(i_inventoryPath, l_interfaceMap);
588+
589+
if (!dbusUtility::callPIM(std::move(l_objectMap)))
590+
{
591+
return false;
592+
}
593+
594+
return true;
595+
}
567596
} // namespace dbusUtility
568597
} // namespace vpd

vpd-manager/src/worker.cpp

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

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

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+
11431159
objectInterfaceMap.emplace(std::move(fruObjectPath),
11441160
std::move(interfaces));
11451161
}
@@ -1414,6 +1430,8 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
14141430
std::tuple<bool, std::string>
14151431
Worker::parseAndPublishVPD(const std::string& i_vpdFilePath)
14161432
{
1433+
std::string l_inventoryPath{};
1434+
14171435
try
14181436
{
14191437
m_semaphore.acquire();
@@ -1423,6 +1441,26 @@ std::tuple<bool, std::string>
14231441
m_activeCollectionThreadCount++;
14241442
m_mutex.unlock();
14251443

1444+
// Set CollectionStatus as InProgress. Since it's an intermediate state
1445+
// D-bus set-property call is good enough to update the status.
1446+
try
1447+
{
1448+
l_inventoryPath = jsonUtility::getInventoryObjPathFromJson(
1449+
m_parsedJson, i_vpdFilePath);
1450+
1451+
dbusUtility::writeDbusProperty(
1452+
jsonUtility::getServiceName(m_parsedJson, l_inventoryPath),
1453+
l_inventoryPath, constants::vpdCollectionInterface,
1454+
"CollectionStatus",
1455+
types::DbusVariantType{constants::vpdCollectionInProgress});
1456+
}
1457+
catch (const std::exception& e)
1458+
{
1459+
logging::logMessage(
1460+
"Unable to set CollectionStatus as InProgress for " +
1461+
i_vpdFilePath);
1462+
}
1463+
14261464
const types::VPDMapVariant& parsedVpdMap = parseVpdFile(i_vpdFilePath);
14271465

14281466
types::ObjectMap objectInterfaceMap;
@@ -1462,14 +1500,23 @@ std::tuple<bool, std::string>
14621500
logging::logMessage(ex.what());
14631501
}
14641502

1503+
// Notify FRU's VPD CollectionStatus as Failure
1504+
if (!dbusUtility::notifyFRUCollectionStatus(
1505+
l_inventoryPath, constants::vpdCollectionFailure))
1506+
{
1507+
logging::logMessage(
1508+
"Call to PIM Notify method failed to update Collection status as Failure for " +
1509+
i_vpdFilePath);
1510+
}
1511+
14651512
// TODO: Figure out a way to clear data in case of any failure at
14661513
// runtime.
14671514
// Prime the inventry for FRUs which
14681515
// are not present/processing had some error.
14691516
/* if (!primeInventory(i_vpdFilePath))
14701517
{
1471-
logging::logMessage("Priming of inventory failed for FRU " +
1472-
i_vpdFilePath);
1518+
logging::logMessage("Priming of inventory failed for FRU " +
1519+
i_vpdFilePath);
14731520
}*/
14741521
m_semaphore.release();
14751522
return std::make_tuple(false, i_vpdFilePath);

0 commit comments

Comments
 (0)