Waiting for PSUs to be available during startup
Modified the Software PSU Updater Service to wait until inventory
service available. Updated ItemUpdater::scanDirectory to search
for the installed PSU model directory. For example, the PSU model
2B1E should have a directory named /usr/share/obmc/psu/2B1E. The
firmware file and the MANIFEST reside in the model directory.
Added a new function, `onInterfacesAdded`, processes D-Bus messages
to update the internal state of PSU devices. It performs the following
steps:
- Read D-Bus message to extract the object path and interfaces.
- Check for PSU Interface.
- Retrieve all PSUs inventory paths from the D-Bus.
- Update PSU present status and model. If the PSU is present and has
valid version, process FW update to latest version.
Fixed the issue with version comparison when there is no firmware to
compare with.
Tested:
Tested the code in simulation module and verified it waits for all PSUs
to be discovered. Verified phosphor-psu-code-manager invokes psutils to
get the PSU version, compare and update.
Change-Id: Ic26e215baffd56fc070cc0cf6d3fff92fdfb914c
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index 0ff2600..61ff666 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -55,11 +55,16 @@
MatchRules::interfacesAdded() +
MatchRules::path(SOFTWARE_OBJPATH),
std::bind(std::mem_fn(&ItemUpdater::createActivation),
- this, std::placeholders::_1))
+ this, std::placeholders::_1)),
+ psuInterfaceMatch(
+ bus,
+ MatchRules::interfacesAdded() +
+ MatchRules::path("/xyz/openbmc_project/inventory") +
+ MatchRules::sender("xyz.openbmc_project.Inventory.Manager"),
+ std::bind(std::mem_fn(&ItemUpdater::onPSUInterfaceAdded), this,
+ std::placeholders::_1))
{
- processPSUImage();
- processStoredImage();
- syncToLatestImage();
+ processPSUImageAndSyncToLatest();
}
/** @brief Deletes version
@@ -179,6 +184,24 @@
/** @brief Invoke the activation via DBus */
void invokeActivation(const std::unique_ptr<Activation>& activation);
+ /** @brief Callback function for interfaces added signal.
+ *
+ * This method is called when a new interface is added. It updates the
+ * internal status map and process the new PSU if it's present.
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ */
+ void onPSUInterfaceAdded(sdbusplus::message_t& msg);
+
+ /**
+ * @brief Handles the processing of PSU images.
+ *
+ * This function responsible for invoking the sequence of processing PSU
+ * images, processing stored images, and syncing to the latest firmware
+ * image.
+ */
+ void processPSUImageAndSyncToLatest();
+
/** @brief Persistent sdbusplus D-Bus bus connection. */
sdbusplus::bus_t& bus;
@@ -219,6 +242,14 @@
* It is used to handle psu inventory changed event, that only create psu
* software object when a PSU is present and the model is retrieved */
std::map<std::string, psuStatus> psuStatusMap;
+
+ /** @brief Signal match for PSU interfaces added.
+ *
+ * This match listens for D-Bus signals indicating new interface has been
+ * added. When such a signal received, it triggers the
+ * `onInterfacesAdded` method to handle the new PSU.
+ */
+ sdbusplus::bus::match_t psuInterfaceMatch;
};
} // namespace updater