chassis-psu: ChassisManager class to manage chassis PSUs
Introduced the ChassisManager class to detect chassis and manage power
supply devices associated with chassis using D-Bus interfaces. This
includes:
- Subscribing to Entity Manager interface changes
- Implementing timers to validate power supply presence and status
- Scan the system for new chassis; if a chassis is new, add it to the
chassis list.
- Adding event loop integration for continuous monitoring
- Analysis of power supply status and error logging.
Test:
- On simulation system, verified chassis and their power supplies are
added to the chassis list, with each power supply correctly linked
to its corresponding chassis.
- Verified the power supplies in each chassis based on analysis
performed at the specified time interval.
Note: There are some commented code indicates future implementation,
please ignore for now, as they will be implemented soon.
Change-Id: I80c271783e71f668ca1405f7aca80c8ec112f531
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/phosphor-power-supply/chassis.cpp b/phosphor-power-supply/chassis.cpp
index 505a955..85e2a88 100644
--- a/phosphor-power-supply/chassis.cpp
+++ b/phosphor-power-supply/chassis.cpp
@@ -25,9 +25,10 @@
const auto entityMgrService = "xyz.openbmc_project.EntityManager";
const auto decoratorChassisId = "xyz.openbmc_project.Inventory.Decorator.Slot";
-Chassis::Chassis(sdbusplus::bus_t& bus, const std::string& chassisPath) :
+Chassis::Chassis(sdbusplus::bus_t& bus, const std::string& chassisPath,
+ const sdeventplus::Event& e) :
bus(bus), chassisPath(chassisPath),
- chassisPathUniqueId(getChassisPathUniqueId())
+ chassisPathUniqueId(getChassisPathUniqueId(chassisPath)), eventLoop(e)
{
getPSUConfiguration();
}
@@ -149,9 +150,12 @@
lg2::debug(
"make PowerSupply bus: {I2CBUS} addr: {I2CADDR} presline: {PRESLINE}",
"I2CBUS", *i2cbus, "I2CADDR", *i2caddr, "PRESLINE", presline);
+ // auto psu = std::make_unique<PowerSupply>(
+ // bus, invpath, *i2cbus, *i2caddr, driverName, presline,
+ // std::bind(&Chassis::isPowerOn, this), chassisPath);
auto psu = std::make_unique<PowerSupply>(
bus, invpath, *i2cbus, *i2caddr, driverName, presline,
- std::bind(&Chassis::isPowerOn, this), chassisPath);
+ std::bind(&Chassis::isPowerOn, this));
psus.emplace_back(std::move(psu));
// Subscribe to power supply presence changes
@@ -300,20 +304,20 @@
[&driverName](auto& psu) { psu->setDriverName(driverName); });
}
-uint32_t Chassis::getChassisPathUniqueId()
+uint64_t Chassis::getChassisPathUniqueId(const std::string& path)
{
- uint32_t chassisId = invalidObjectPathUniqueId;
try
{
- getProperty(decoratorChassisId, chassisIdProp, chassisPath,
- INVENTORY_MGR_IFACE, bus, chassisId);
+ return getChassisInventoryUniqueId(bus, path);
}
catch (const sdbusplus::exception_t& e)
{
- lg2::error("Failed to find chassis ID - exception: {ERROR}", "ERROR",
- e);
+ lg2::error(
+ "Failed to find chassis path {CHASSIS_PATH} ID - exception: {ERROR}",
+ "CHASSIS_PATH", path, "ERROR", e);
}
- return chassisId;
+ return invalidObjectPathUniqueId;
}
+void Chassis::analyze() {}
} // namespace phosphor::power::chassis