chassis-state-manager: Add multi-chassis support
Add multi-chassis management support, each chassis bus separates by
giving a unique chassis id.
Current code only support single chassis, and alway assume bus name is
"xyz.openbmc_project.State.Chassis".
This patch allow user to launch chassis-state-manager with a chassis id,
and chassis id is added into service bus name for identification.
Because there are many places hardcode with bus name
"xyz.openbmc_project.State.Chassis", if chassis id is 0,
chassis-state-manager will request both
"xyz.openbmc_project.State.Chassis" and
"xyz.openbmc_project.State.Chassis0" bus name to meet backwards
compatibility.
Tested on Bletchley:
root@bletchley:~# busctl tree xyz.openbmc_project.State.Chassis
`-/xyz
`-/xyz/openbmc_project
`-/xyz/openbmc_project/state
`-/xyz/openbmc_project/state/chassis0
root@bletchley:~# busctl tree xyz.openbmc_project.State.Chassis0
`-/xyz
`-/xyz/openbmc_project
`-/xyz/openbmc_project/state
`-/xyz/openbmc_project/state/chassis0
root@bletchley:~# busctl tree xyz.openbmc_project.State.Chassis1
`-/xyz
`-/xyz/openbmc_project
`-/xyz/openbmc_project/state
`-/xyz/openbmc_project/state/chassis1
......
patch dependencies:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-state-manager/+/51465
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I2ce3e9ab2c95a2688143f4e3775da164a5c33c19
diff --git a/chassis_state_manager.hpp b/chassis_state_manager.hpp
index cf59025..b48409b 100644
--- a/chassis_state_manager.hpp
+++ b/chassis_state_manager.hpp
@@ -44,8 +44,9 @@
*
* @param[in] bus - The Dbus bus object
* @param[in] objPath - The Dbus object path
+ * @param[in] id - Chassis id
*/
- Chassis(sdbusplus::bus::bus& bus, const char* objPath) :
+ Chassis(sdbusplus::bus::bus& bus, const char* objPath, size_t id) :
ChassisInherit(bus, objPath, true), bus(bus),
systemdSignals(
bus,
@@ -54,12 +55,14 @@
sdbusRule::interface("org.freedesktop.systemd1.Manager"),
std::bind(std::mem_fn(&Chassis::sysStateChange), this,
std::placeholders::_1)),
- pohTimer(sdeventplus::Event::get_default(),
- std::bind(&Chassis::pohCallback, this), std::chrono::hours{1},
- std::chrono::minutes{1})
+ id(id), pohTimer(sdeventplus::Event::get_default(),
+ std::bind(&Chassis::pohCallback, this),
+ std::chrono::hours{1}, std::chrono::minutes{1})
{
subscribeToSystemdSignals();
+ createSystemdTargetTable();
+
restoreChassisStateChangeTime();
determineInitialState();
@@ -83,6 +86,9 @@
void startPOHCounter();
private:
+ /** @brief Create systemd target instance names and mapping table */
+ void createSystemdTargetTable();
+
/** @brief Determine initial chassis state and set internally */
void determineInitialState();
@@ -137,6 +143,12 @@
/** @brief Watch for any changes to UPS properties **/
std::unique_ptr<sdbusplus::bus::match_t> uPowerPropChangeSignal;
+ /** @brief Chassis id. **/
+ const size_t id = 0;
+
+ /** @brief Transition state to systemd target mapping table. **/
+ std::map<Transition, std::string> systemdTargetTable;
+
/** @brief Used to Set value of POHCounter */
uint32_t pohCounter(uint32_t value) override;