Skip to content

Commit

Permalink
Implement CollectionStatus for each inventory FRU
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
PriyangaRamasamy committed Dec 18, 2024
1 parent 5028d9d commit 24cdfd2
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 8 deletions.
12 changes: 12 additions & 0 deletions vpd-manager/include/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,17 @@ static constexpr auto eventLoggingServiceName = "xyz.openbmc_project.Logging";
static constexpr auto eventLoggingObjectPath = "/xyz/openbmc_project/logging";
static constexpr auto eventLoggingInterface =
"xyz.openbmc_project.Logging.Create";
static constexpr auto vpdCollectionInterface = "com.ibm.VPD.Collection";

// enumerated values of CollectionStatus D-bus property defined under
// com.ibm.VPD.Collection interface.
static constexpr auto vpdCollectionSuccess =
"com.ibm.VPD.Collection.Status.Success";
static constexpr auto vpdCollectionFailure =
"com.ibm.VPD.Collection.Status.Failure";
static constexpr auto vpdCollectionInProgress =
"com.ibm.VPD.Collection.Status.InProgress";
static constexpr auto vpdCollectionNotStarted =
"com.ibm.VPD.Collection.Status.NotStarted";
} // namespace constants
} // namespace vpd
26 changes: 26 additions & 0 deletions vpd-manager/include/utility/dbus_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,31 @@ inline bool isBMCReady()

return false;
}

/**
* @brief API to set status of FRU VPD collection on D-bus.
*
* This API is to set value of CollectionStatus property hosted under
* com.ibm.VPD.Collection interface for the given FRU's inventory object.
*
* @param[in] i_invObjPath - D-bus inventory object path.
* @param[in] i_fruVpdCollectionStatus - FRU VPD collection status.
*
* @return true if given status is set successfully, false otherwise.
*/
inline bool
setFruVpdCollectionStatus(const std::string& i_invObjPath,
const std::string& i_fruVpdCollectionStatus)
{
types::ObjectMap l_objectMap;
types::InterfaceMap l_interfaceMap;
types::PropertyMap l_propertyMap;

l_propertyMap.emplace("CollectionStatus", i_fruVpdCollectionStatus);
l_interfaceMap.emplace(constants::vpdCollectionInterface, l_propertyMap);
l_objectMap.emplace(i_invObjPath, l_interfaceMap);

return callPIM(std::move(l_objectMap));
}
} // namespace dbusUtility
} // namespace vpd
13 changes: 13 additions & 0 deletions vpd-manager/include/worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,19 @@ class Worker
void processEnabledProperty(const std::string& i_inventoryObjPath,
types::InterfaceMap& io_interfaces);

/**
* @brief API to process FRU VPD Collection status.
*
* This API sets the given FRU VPD collection status to the given interface
* map.
*
* @param[in,out] io_interfaces - Map which holds FRU's interfaces and its
* properties.
* @param[in] i_fruCollectionStatus - FRU VPD collection status.
*/
void processFRUCollectionStatus(types::InterfaceMap& io_interfaces,
const std::string& i_fruCollectionStatus);

/**
* @brief API to form asset tag string for the system.
*
Expand Down
30 changes: 28 additions & 2 deletions vpd-manager/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ types::DbusVariantType
void Manager::collectSingleFruVpd(
const sdbusplus::message::object_path& i_dbusObjPath)
{
std::string l_fruPath{};
try
{
if (m_vpdCollectionStatus != "Completed")
Expand All @@ -413,8 +414,8 @@ void Manager::collectSingleFruVpd(
}

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

if (l_fruPath.empty())
{
Expand Down Expand Up @@ -447,6 +448,16 @@ void Manager::collectSingleFruVpd(
}
}

// Set CollectionStatus as InProgress before performing single FRU VPD
// collection
if (!dbusUtility::setFruVpdCollectionStatus(
i_dbusObjPath, constants::vpdCollectionInProgress))
{
logging::logMessage(
"Unable to set CollectionStatus as InProgress for " +
std::string(i_dbusObjPath) + ". Continue collecting VPD.");
}

// Parse VPD
types::VPDMapVariant l_parsedVpd = m_worker->parseVpdFile(l_fruPath);

Expand Down Expand Up @@ -480,6 +491,21 @@ void Manager::collectSingleFruVpd(
{
// TODO: Log PEL
logging::logMessage(std::string(l_error.what()));

std::string l_collectionStatus = constants::vpdCollectionFailure;

if (!std::filesystem::exists(l_fruPath))
{
l_collectionStatus = constants::vpdCollectionNotStarted;
}

if (!dbusUtility::setFruVpdCollectionStatus(i_dbusObjPath,
l_collectionStatus))
{
logging::logMessage("Unable to set CollectionStatus as " +
l_collectionStatus + " for " +
std::string(i_dbusObjPath));
}
}
}

Expand Down
38 changes: 32 additions & 6 deletions vpd-manager/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,9 +833,20 @@ bool Worker::primeInventory(const std::string& i_vpdFilePath)

types::PropertyMap l_propertyValueMap;
l_propertyValueMap.emplace("Present", false);

if (std::filesystem::exists(i_vpdFilePath))
{
l_propertyValueMap["Present"] = true;

// FRU exist and if we hit prime inventory path
processFRUCollectionStatus(l_interfaces,
constants::vpdCollectionFailure);
}
else
{
// FRU doesn't exist and if we hit prime inventory path
processFRUCollectionStatus(l_interfaces,
constants::vpdCollectionNotStarted);
}

vpdSpecificUtility::insertOrMerge(l_interfaces,
Expand Down Expand Up @@ -1138,6 +1149,10 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
processFunctionalProperty(inventoryPath, interfaces);
processEnabledProperty(inventoryPath, interfaces);

// FRU VPD collection is successful
processFRUCollectionStatus(interfaces,
constants::vpdCollectionSuccess);

objectInterfaceMap.emplace(std::move(fruObjectPath),
std::move(interfaces));
}
Expand Down Expand Up @@ -1470,13 +1485,13 @@ std::tuple<bool, std::string>

// TODO: Figure out a way to clear data in case of any failure at
// runtime.
// Prime the inventry for FRUs which
// Prime the inventory for FRUs which
// are not present/processing had some error.
/* if (!primeInventory(i_vpdFilePath))
{
logging::logMessage("Priming of inventory failed for FRU " +
i_vpdFilePath);
}*/
if (!primeInventory(i_vpdFilePath))
{
logging::logMessage("Priming of inventory failed for FRU " +
i_vpdFilePath);
}
m_semaphore.release();
return std::make_tuple(false, i_vpdFilePath);
}
Expand Down Expand Up @@ -1683,4 +1698,15 @@ void Worker::deleteFruVpd(const std::string& i_dbusObjPath)
" error: " + std::string(l_ex.what()));
}
}

void Worker::processFRUCollectionStatus(
types::InterfaceMap& io_interfaces,
const std::string& i_fruCollectionStatus)
{
types::PropertyMap l_fruCollectionProperty = {
{"CollectionStatus", i_fruCollectionStatus}};
vpdSpecificUtility::insertOrMerge(io_interfaces,
constants::vpdCollectionInterface,
std::move(l_fruCollectionProperty));
}
} // namespace vpd

0 comments on commit 24cdfd2

Please sign in to comment.