entity-manager: not pass through io, objServer
Pass
`boost::asio::io_context& io`
and
`sdbusplus::asio::object_server& objServer`
into constructor for class EMDBusInterface.
Since these are just references, nothing exciting should happen here.
The change reduces the number of parameters and makes the code more
easily readable.
Tested: on Tyan S8030
clean log
```
Sep 22 16:00:47 s8030-bmc-30303035c0c1 systemd[1]: Started Entity Manager.
Sep 22 16:00:57 s8030-bmc-30303035c0c1 entity-manager[10392]: Inventory Added: Supermicro PWS 920P SQ 0
Sep 22 16:00:57 s8030-bmc-30303035c0c1 entity-manager[10392]: Inventory Added: Supermicro PWS 920P SQ 1
Sep 22 16:00:57 s8030-bmc-30303035c0c1 entity-manager[10392]: Inventory Added: Tyan S8030 Baseboard
Sep 22 16:00:57 s8030-bmc-30303035c0c1 entity-manager[10392]: Inventory Added: MBX 1.57 Chassis
```
and clean `busctl tree`
```
busctl tree xyz.openbmc_project.EntityManager
`- /xyz
`- /xyz/openbmc_project
|- /xyz/openbmc_project/EntityManager
`- /xyz/openbmc_project/inventory
`- /xyz/openbmc_project/inventory/system
|- /xyz/openbmc_project/inventory/system/board
| `- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/CPU0_Power_Consumption
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/CPU0_Temp
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/GARBO_SENSOR
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/HostSPIFlash
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_18_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_CORE_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_MEM_ABCD
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_MEM_EFGH
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_SOC_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VBAT_33
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_12_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_33_DUAL
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_33_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_5_DUAL
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_5_RUN
| `- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/X550
|- /xyz/openbmc_project/inventory/system/chassis
| `- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/Fan_Control
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/GenericContainPort
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_1_Ignore
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_2_Ignore
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_FRU_1
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_FRU_2
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/SYS_FAN_1
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/SYS_FAN_2
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/SYS_FAN_3
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/Temperature_Control
| `- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/Zone0
`- /xyz/openbmc_project/inventory/system/powersupply
|- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0
| |- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0/PSU0
| |- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0/PSU0_ADDR
| `- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0/PSU0_FRU
`- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1
|- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1/PSU1
|- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1/PSU1_ADDR
`- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1/PSU1_FRU
```
Change-Id: Id292bf86a72c9b6e707b2cec71b77c63ed5077a2
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index e5e8b23..3835cc1 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -58,7 +58,8 @@
objServer(sdbusplus::asio::object_server(systemBus, /*skipManager=*/true)),
lastJson(nlohmann::json::object()),
systemConfiguration(nlohmann::json::object()), io(io),
- powerStatus(*systemBus), propertiesChangedTimer(io)
+ dbus_interface(io, objServer), powerStatus(*systemBus),
+ propertiesChangedTimer(io)
{
// All other objects that EntityManager currently support are under the
// inventory subtree.
@@ -96,7 +97,7 @@
}
auto ifacePtr = dbus_interface.createInterface(
- objServer, assocPath, "xyz.openbmc_project.Association.Definitions",
+ assocPath, "xyz.openbmc_project.Association.Definitions",
findBoard->second);
ifacePtr->register_property("Associations", assocPropValue);
@@ -134,22 +135,19 @@
em_utils::buildInventorySystemPath(boardName, boardType);
std::shared_ptr<sdbusplus::asio::dbus_interface> inventoryIface =
- dbus_interface.createInterface(objServer, boardPath,
- "xyz.openbmc_project.Inventory.Item",
- boardName);
+ dbus_interface.createInterface(
+ boardPath, "xyz.openbmc_project.Inventory.Item", boardName);
std::shared_ptr<sdbusplus::asio::dbus_interface> boardIface =
dbus_interface.createInterface(
- objServer, boardPath,
- "xyz.openbmc_project.Inventory.Item." + boardType, boardNameOrig);
+ boardPath, "xyz.openbmc_project.Inventory.Item." + boardType,
+ boardNameOrig);
- dbus_interface.createAddObjectMethod(
- io, jsonPointerPath, boardPath, systemConfiguration, objServer,
- boardNameOrig);
+ dbus_interface.createAddObjectMethod(jsonPointerPath, boardPath,
+ systemConfiguration, boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration, jsonPointerPath, boardIface, boardValues,
- objServer);
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration, jsonPointerPath, boardIface, boardValues);
jsonPointerPath += "/";
// iterate through board properties
for (const auto& [propName, propValue] : boardValues.items())
@@ -157,12 +155,12 @@
if (propValue.type() == nlohmann::json::value_t::object)
{
std::shared_ptr<sdbusplus::asio::dbus_interface> iface =
- dbus_interface.createInterface(objServer, boardPath, propName,
+ dbus_interface.createInterface(boardPath, propName,
boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration, jsonPointerPath + propName, iface,
- propValue, objServer);
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration, jsonPointerPath + propName, iface,
+ propValue);
}
}
@@ -235,21 +233,21 @@
{
std::shared_ptr<sdbusplus::asio::dbus_interface> bmcIface =
dbus_interface.createInterface(
- objServer, ifacePath, "xyz.openbmc_project.Inventory.Item.Bmc",
+ ifacePath, "xyz.openbmc_project.Inventory.Item.Bmc",
boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration, jsonPointerPath, bmcIface, item, objServer,
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration, jsonPointerPath, bmcIface, item,
getPermission(itemType));
}
else if (itemType == "System")
{
std::shared_ptr<sdbusplus::asio::dbus_interface> systemIface =
dbus_interface.createInterface(
- objServer, ifacePath,
- "xyz.openbmc_project.Inventory.Item.System", boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration, jsonPointerPath, systemIface, item,
- objServer, getPermission(itemType));
+ ifacePath, "xyz.openbmc_project.Inventory.Item.System",
+ boardNameOrig);
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration, jsonPointerPath, systemIface, item,
+ getPermission(itemType));
}
for (const auto& [name, config] : item.items())
@@ -268,11 +266,11 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> itemIface =
dbus_interface.createInterface(
- objServer, ifacePath,
- "xyz.openbmc_project.Configuration." + itemType, boardNameOrig);
+ ifacePath, "xyz.openbmc_project.Configuration." + itemType,
+ boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration, jsonPointerPath, itemIface, item, objServer,
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration, jsonPointerPath, itemIface, item,
getPermission(itemType));
topology.addBoard(boardPath, boardType, boardNameOrig, item);
@@ -289,12 +287,11 @@
ifaceName.append(itemType).append(".").append(name);
std::shared_ptr<sdbusplus::asio::dbus_interface> objectIface =
- dbus_interface.createInterface(objServer, ifacePath, ifaceName,
- boardNameOrig);
+ dbus_interface.createInterface(ifacePath, ifaceName, boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration, jsonPointerPath, objectIface, config,
- objServer, getPermission(name));
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration, jsonPointerPath, objectIface, config,
+ getPermission(name));
}
else if (config.type() == nlohmann::json::value_t::array)
{
@@ -332,13 +329,13 @@
ifaceName.append(std::to_string(index));
std::shared_ptr<sdbusplus::asio::dbus_interface> objectIface =
- dbus_interface.createInterface(objServer, ifacePath, ifaceName,
+ dbus_interface.createInterface(ifacePath, ifaceName,
boardNameOrig);
- dbus_interface::populateInterfaceFromJson(
- io, systemConfiguration,
+ dbus_interface.populateInterfaceFromJson(
+ systemConfiguration,
jsonPointerPath + "/" + std::to_string(index), objectIface,
- arrayItem, objServer, getPermission(name));
+ arrayItem, getPermission(name));
index++;
}
}