Skip to content

Commit 24cdfd2

Browse files
Implement 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 ------------------------------------- This value is assigned when we hit prime inventory path on VPD collection failure due to VPD exceptions and also when single FRU VPD collection fails. >>>com.ibm.VPD.Collection.Status.InProgress ---------------------------------------- This value is assigned before single FRU VPD collection starts for the given FRU. >>>com.ibm.VPD.Collection.Status.NotStarted ---------------------------------------- This value is assigned when we hit prime inventory path when the VPD collection is not started as the FRU itself is not present. Test: 1. busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard NAME TYPE SIGNATURE RESULT/VALUE FLAGS com.ibm.VPD.Collection interface - - - .CollectionStatus property s "com.ibm.VPD.Collection.Status.Success" emits-change writable 2. busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 NAME TYPE SIGNATURE RESULT/VALUE FLAGS com.ibm.VPD.Collection interface - - - .CollectionStatus property s "com.ibm.VPD.Collection.Status.NotSta... emits-change writable 3. busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson NAME TYPE SIGNATURE RESULT/VALUE FLAGS com.ibm.VPD.Collection interface - - - .CollectionStatus property s "com.ibm.VPD.Collection.Status.Failure" emits-change writable 4. Previous state is Failure && perform singleFRUVPDCollect 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" root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson root@testhostname2:~# 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" 5. Previous state is Success && perform singleFRUVPDCollect busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/lcd_op_panel_hill com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Success" root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/inventory/system/chassis/motherboard/lcd_op_panel_hill root@testhostname2:~# busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/lcd_op_panel_hill com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Success" 6. Previous state is NotStarted && perform singleFRUVPDCollect busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.NotStarted" root@testhostname2:~# busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 root@testhostname2:~# busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.NotStarted" Change-Id: Ia5010a181f720454bb51538d6fcf308daf6b75ca Signed-off-by: Priyanga Ramasamy <[email protected]>
1 parent 5028d9d commit 24cdfd2

File tree

5 files changed

+111
-8
lines changed

5 files changed

+111
-8
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/include/utility/dbus_utility.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,5 +454,31 @@ inline bool isBMCReady()
454454

455455
return false;
456456
}
457+
458+
/**
459+
* @brief API to set status of FRU VPD collection on D-bus.
460+
*
461+
* This API is to set value of CollectionStatus property hosted under
462+
* com.ibm.VPD.Collection interface for the given FRU's inventory object.
463+
*
464+
* @param[in] i_invObjPath - D-bus inventory object path.
465+
* @param[in] i_fruVpdCollectionStatus - FRU VPD collection status.
466+
*
467+
* @return true if given status is set successfully, false otherwise.
468+
*/
469+
inline bool
470+
setFruVpdCollectionStatus(const std::string& i_invObjPath,
471+
const std::string& i_fruVpdCollectionStatus)
472+
{
473+
types::ObjectMap l_objectMap;
474+
types::InterfaceMap l_interfaceMap;
475+
types::PropertyMap l_propertyMap;
476+
477+
l_propertyMap.emplace("CollectionStatus", i_fruVpdCollectionStatus);
478+
l_interfaceMap.emplace(constants::vpdCollectionInterface, l_propertyMap);
479+
l_objectMap.emplace(i_invObjPath, l_interfaceMap);
480+
481+
return callPIM(std::move(l_objectMap));
482+
}
457483
} // namespace dbusUtility
458484
} // namespace vpd

vpd-manager/include/worker.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,19 @@ class Worker
469469
void processEnabledProperty(const std::string& i_inventoryObjPath,
470470
types::InterfaceMap& io_interfaces);
471471

472+
/**
473+
* @brief API to process FRU VPD Collection status.
474+
*
475+
* This API sets the given FRU VPD collection status to the given interface
476+
* map.
477+
*
478+
* @param[in,out] io_interfaces - Map which holds FRU's interfaces and its
479+
* properties.
480+
* @param[in] i_fruCollectionStatus - FRU VPD collection status.
481+
*/
482+
void processFRUCollectionStatus(types::InterfaceMap& io_interfaces,
483+
const std::string& i_fruCollectionStatus);
484+
472485
/**
473486
* @brief API to form asset tag string for the system.
474487
*

vpd-manager/src/manager.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ types::DbusVariantType
387387
void Manager::collectSingleFruVpd(
388388
const sdbusplus::message::object_path& i_dbusObjPath)
389389
{
390+
std::string l_fruPath{};
390391
try
391392
{
392393
if (m_vpdCollectionStatus != "Completed")
@@ -413,8 +414,8 @@ void Manager::collectSingleFruVpd(
413414
}
414415

415416
// Get FRU path for the given D-bus object path from JSON
416-
const std::string& l_fruPath =
417-
jsonUtility::getFruPathFromJson(l_sysCfgJsonObj, i_dbusObjPath);
417+
l_fruPath = jsonUtility::getFruPathFromJson(l_sysCfgJsonObj,
418+
i_dbusObjPath);
418419

419420
if (l_fruPath.empty())
420421
{
@@ -447,6 +448,16 @@ void Manager::collectSingleFruVpd(
447448
}
448449
}
449450

451+
// Set CollectionStatus as InProgress before performing single FRU VPD
452+
// collection
453+
if (!dbusUtility::setFruVpdCollectionStatus(
454+
i_dbusObjPath, constants::vpdCollectionInProgress))
455+
{
456+
logging::logMessage(
457+
"Unable to set CollectionStatus as InProgress for " +
458+
std::string(i_dbusObjPath) + ". Continue collecting VPD.");
459+
}
460+
450461
// Parse VPD
451462
types::VPDMapVariant l_parsedVpd = m_worker->parseVpdFile(l_fruPath);
452463

@@ -480,6 +491,21 @@ void Manager::collectSingleFruVpd(
480491
{
481492
// TODO: Log PEL
482493
logging::logMessage(std::string(l_error.what()));
494+
495+
std::string l_collectionStatus = constants::vpdCollectionFailure;
496+
497+
if (!std::filesystem::exists(l_fruPath))
498+
{
499+
l_collectionStatus = constants::vpdCollectionNotStarted;
500+
}
501+
502+
if (!dbusUtility::setFruVpdCollectionStatus(i_dbusObjPath,
503+
l_collectionStatus))
504+
{
505+
logging::logMessage("Unable to set CollectionStatus as " +
506+
l_collectionStatus + " for " +
507+
std::string(i_dbusObjPath));
508+
}
483509
}
484510
}
485511

vpd-manager/src/worker.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,20 @@ bool Worker::primeInventory(const std::string& i_vpdFilePath)
833833

834834
types::PropertyMap l_propertyValueMap;
835835
l_propertyValueMap.emplace("Present", false);
836+
836837
if (std::filesystem::exists(i_vpdFilePath))
837838
{
838839
l_propertyValueMap["Present"] = true;
840+
841+
// FRU exist and if we hit prime inventory path
842+
processFRUCollectionStatus(l_interfaces,
843+
constants::vpdCollectionFailure);
844+
}
845+
else
846+
{
847+
// FRU doesn't exist and if we hit prime inventory path
848+
processFRUCollectionStatus(l_interfaces,
849+
constants::vpdCollectionNotStarted);
839850
}
840851

841852
vpdSpecificUtility::insertOrMerge(l_interfaces,
@@ -1138,6 +1149,10 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
11381149
processFunctionalProperty(inventoryPath, interfaces);
11391150
processEnabledProperty(inventoryPath, interfaces);
11401151

1152+
// FRU VPD collection is successful
1153+
processFRUCollectionStatus(interfaces,
1154+
constants::vpdCollectionSuccess);
1155+
11411156
objectInterfaceMap.emplace(std::move(fruObjectPath),
11421157
std::move(interfaces));
11431158
}
@@ -1470,13 +1485,13 @@ std::tuple<bool, std::string>
14701485

14711486
// TODO: Figure out a way to clear data in case of any failure at
14721487
// runtime.
1473-
// Prime the inventry for FRUs which
1488+
// Prime the inventory for FRUs which
14741489
// are not present/processing had some error.
1475-
/* if (!primeInventory(i_vpdFilePath))
1476-
{
1477-
logging::logMessage("Priming of inventory failed for FRU " +
1478-
i_vpdFilePath);
1479-
}*/
1490+
if (!primeInventory(i_vpdFilePath))
1491+
{
1492+
logging::logMessage("Priming of inventory failed for FRU " +
1493+
i_vpdFilePath);
1494+
}
14801495
m_semaphore.release();
14811496
return std::make_tuple(false, i_vpdFilePath);
14821497
}
@@ -1683,4 +1698,15 @@ void Worker::deleteFruVpd(const std::string& i_dbusObjPath)
16831698
" error: " + std::string(l_ex.what()));
16841699
}
16851700
}
1701+
1702+
void Worker::processFRUCollectionStatus(
1703+
types::InterfaceMap& io_interfaces,
1704+
const std::string& i_fruCollectionStatus)
1705+
{
1706+
types::PropertyMap l_fruCollectionProperty = {
1707+
{"CollectionStatus", i_fruCollectionStatus}};
1708+
vpdSpecificUtility::insertOrMerge(io_interfaces,
1709+
constants::vpdCollectionInterface,
1710+
std::move(l_fruCollectionProperty));
1711+
}
16861712
} // namespace vpd

0 commit comments

Comments
 (0)