Add Asset and StorageController interface
This makes it so we can populate the storage controller
redfish schema.
Tested: Redfish validator passed
Change-Id: Ie3f5ae7e5abf0e0fd766491ea14939c7498828c7
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/hsbp-manager/CMakeLists.txt b/hsbp-manager/CMakeLists.txt
index eeb6f0a..2d7aae2 100644
--- a/hsbp-manager/CMakeLists.txt
+++ b/hsbp-manager/CMakeLists.txt
@@ -52,7 +52,7 @@
externalproject_add (sdbusplus-project PREFIX
${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY
https://github.com/openbmc/sdbusplus.git GIT_TAG
- bed15f0cee4784acdf151cca14efdfb98cb9d397 SOURCE_DIR
+ 4212292bcf136d04b38ba5116aa568b0fa312798 SOURCE_DIR
${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR
${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND
"" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src
diff --git a/hsbp-manager/include/utils.hpp b/hsbp-manager/include/utils.hpp
index 002b1ed..c333089 100644
--- a/hsbp-manager/include/utils.hpp
+++ b/hsbp-manager/include/utils.hpp
@@ -35,6 +35,9 @@
double, int32_t, uint32_t, int16_t, uint16_t, uint8_t, bool>;
using Association = std::tuple<std::string, std::string, std::string>;
+constexpr const char* assetTag =
+ "xyz.openbmc_project.Inventory.Decorator.Asset";
+
namespace mapper
{
constexpr const char* busName = "xyz.openbmc_project.ObjectMapper";
diff --git a/hsbp-manager/src/hsbp_manager.cpp b/hsbp-manager/src/hsbp_manager.cpp
index f6a1b5f..d8df646 100644
--- a/hsbp-manager/src/hsbp_manager.cpp
+++ b/hsbp-manager/src/hsbp_manager.cpp
@@ -301,7 +301,39 @@
muxes(std::make_shared<boost::container::flat_set<Mux>>())
{
}
- void run()
+ void populateAsset(const std::string& rootPath, const std::string& busname)
+ {
+ conn->async_method_call(
+ [assetIface{assetInterface}, hsbpIface{hsbpItemIface}](
+ const boost::system::error_code ec,
+ const boost::container::flat_map<
+ std::string, std::variant<std::string>>& values) mutable {
+ if (ec)
+ {
+ std::cerr
+ << "Error getting asset tag from HSBP configuration\n";
+
+ return;
+ }
+ assetIface = objServer.add_interface(
+ hsbpIface->get_object_path(), assetTag);
+ for (const auto& [key, value] : values)
+ {
+ const std::string* ptr = std::get_if<std::string>(&value);
+ if (ptr == nullptr)
+ {
+ std::cerr << key << " Invalid type!\n";
+ continue;
+ }
+ assetIface->register_property(key, *ptr);
+ }
+ assetIface->initialize();
+ },
+ busname, rootPath, "org.freedesktop.DBus.Properties", "GetAll",
+ assetTag);
+ }
+
+ void run(const std::string& rootPath, const std::string& busname)
{
file = open(("/dev/i2c-" + std::to_string(bus)).c_str(),
O_RDWR | O_CLOEXEC);
@@ -334,6 +366,11 @@
hsbpItemIface->register_property("PrettyName", name);
hsbpItemIface->initialize();
+ storageInterface = objServer.add_interface(
+ hsbpItemIface->get_object_path(),
+ "xyz.openbmc_project.Inventory.Item.StorageController");
+ storageInterface->initialize();
+
versionIface =
objServer.add_interface(hsbpItemIface->get_object_path(),
"xyz.openbmc_project.Software.Version");
@@ -348,6 +385,8 @@
getPresence(presence);
getIFDET(ifdet);
+ populateAsset(rootPath, busname);
+
createDrives();
runTimer();
@@ -599,6 +638,8 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> hsbpItemIface;
std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> storageInterface;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> assetInterface;
std::list<Drive> drives;
std::vector<std::shared_ptr<Led>> leds;
@@ -622,8 +663,6 @@
{
static constexpr const char* nvmeType =
"xyz.openbmc_project.Inventory.Item.NVMe";
- static const std::string assetTag =
- "xyz.openbmc_project.Inventory.Decorator.Asset";
conn->async_method_call(
[](const boost::system::error_code ec, const GetSubTreeType& subtree) {
@@ -911,9 +950,9 @@
const std::string& owner = objDict.begin()->first;
conn->async_method_call(
- [path](const boost::system::error_code ec2,
- const boost::container::flat_map<
- std::string, BasicVariantType>& resp) {
+ [path, owner](const boost::system::error_code ec2,
+ const boost::container::flat_map<
+ std::string, BasicVariantType>& resp) {
if (ec2)
{
std::cerr << "Error Getting Config "
@@ -955,7 +994,7 @@
const auto& [backplane, status] = backplanes.emplace(
*name,
Backplane(*bus, *address, *backplaneIndex, *name));
- backplane->second.run();
+ backplane->second.run(parentPath, owner);
populateMuxes(backplane->second.muxes, parentPath);
},
owner, path, "org.freedesktop.DBus.Properties", "GetAll",