entity-manager: use PDI constants for inventory
Use PDI constants to create inventory interfaces, where possible. This
helps to make the code more readable and guarantees the interfaces which
are directly created from a PDI constant actually exist.
Also use the decorator asset interface PDI definition to query asset
information.
Tested: on Tyan S8030
Inventory interfaces are created as before
```
busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard
```
output
```
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
xyz.openbmc_project.Inventory.Decorator.Asset
...
xyz.openbmc_project.Inventory.Item.Board
...
```
Asset information is queried as before
```
Sep 12 14:31:41 s8030-bmc-30303035c0c1 entity-manager[19121]: Inventory Added: Supermicro PWS 920P SQ 0
Sep 12 14:31:41 s8030-bmc-30303035c0c1 entity-manager[19121]: Inventory Added: Supermicro PWS 920P SQ 1
Sep 12 14:31:41 s8030-bmc-30303035c0c1 entity-manager[19121]: Inventory Added: Tyan S8030 Baseboard
Sep 12 14:31:41 s8030-bmc-30303035c0c1 entity-manager[19121]: Inventory Added: MBX 1.57 Chassis
```
Change-Id: I28e22f986686238caf4213aaa1334004c8dd721c
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 f9560f3..796f6e7 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -23,6 +23,10 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
+#include <xyz/openbmc_project/Association/Definitions/common.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Bmc/common.hpp>
+#include <xyz/openbmc_project/Inventory/Item/System/common.hpp>
+#include <xyz/openbmc_project/Inventory/Item/common.hpp>
#include <filesystem>
#include <fstream>
@@ -92,7 +96,9 @@
}
auto ifacePtr = dbus_interface.createInterface(
- assocPath, "xyz.openbmc_project.Association.Definitions",
+ assocPath,
+ sdbusplus::common::xyz::openbmc_project::association::Definitions::
+ interface,
findBoard->second);
ifacePtr->register_property("Associations", assocPropValue);
@@ -131,12 +137,17 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> inventoryIface =
dbus_interface.createInterface(
- boardPath, "xyz.openbmc_project.Inventory.Item", boardName);
+ boardPath,
+ sdbusplus::common::xyz::openbmc_project::inventory::Item::interface,
+ boardName);
+
+ const std::string invItemIntf = std::format(
+ "{}.{}",
+ sdbusplus::common::xyz::openbmc_project::inventory::Item::interface,
+ boardType);
std::shared_ptr<sdbusplus::asio::dbus_interface> boardIface =
- dbus_interface.createInterface(
- boardPath, "xyz.openbmc_project.Inventory.Item." + boardType,
- boardNameOrig);
+ dbus_interface.createInterface(boardPath, invItemIntf, boardNameOrig);
dbus_interface.createAddObjectMethod(jsonPointerPath, boardPath,
systemConfiguration, boardNameOrig);
@@ -228,7 +239,9 @@
{
std::shared_ptr<sdbusplus::asio::dbus_interface> bmcIface =
dbus_interface.createInterface(
- ifacePath, "xyz.openbmc_project.Inventory.Item.Bmc",
+ ifacePath,
+ sdbusplus::common::xyz::openbmc_project::inventory::item::Bmc::
+ interface,
boardNameOrig);
dbus_interface.populateInterfaceFromJson(
systemConfiguration, jsonPointerPath, bmcIface, item,
@@ -238,7 +251,9 @@
{
std::shared_ptr<sdbusplus::asio::dbus_interface> systemIface =
dbus_interface.createInterface(
- ifacePath, "xyz.openbmc_project.Inventory.Item.System",
+ ifacePath,
+ sdbusplus::common::xyz::openbmc_project::inventory::item::
+ System::interface,
boardNameOrig);
dbus_interface.populateInterfaceFromJson(
systemConfiguration, jsonPointerPath, systemIface, item,
diff --git a/src/entity_manager/log_device_inventory.cpp b/src/entity_manager/log_device_inventory.cpp
index 5dd97d1..9662c97 100644
--- a/src/entity_manager/log_device_inventory.cpp
+++ b/src/entity_manager/log_device_inventory.cpp
@@ -4,6 +4,7 @@
#include <boost/container/flat_map.hpp>
#include <nlohmann/json.hpp>
+#include <xyz/openbmc_project/Inventory/Decorator/Asset/common.hpp>
#include <string>
@@ -18,8 +19,8 @@
static InvAddRemoveInfo queryInvInfo(const nlohmann::json& record)
{
auto findType = record.find("Type");
- auto findAsset =
- record.find("xyz.openbmc_project.Inventory.Decorator.Asset");
+ auto findAsset = record.find(sdbusplus::common::xyz::openbmc_project::
+ inventory::decorator::Asset::interface);
std::string model = "Unknown";
std::string type = "Unknown";