Refactor chassisInterfaces into chassis_utils
Some (e.g. IBM) do not use the
`xyz.openbmc_project.Inventory.Item.Board` interface for chassis
objects. To handle the use pattern easier, this refactors the Chassis
interface into one location and it is referenced from the needed places
(e.g. `getValidChassisPath()`).
Moreover, this part is repeated many times, which goes against best
practices.
Tested:
- GET Chassis related API and check they are the same as before
- Redfish Service Validator passes
Change-Id: Id4a51986262892c5dc81b1a3bc46fa5be7c0e9da
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index aa0d861..0b10a1b 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -8,13 +8,13 @@
#include "dbus_utility.hpp"
#include "error_messages.hpp"
#include "logging.hpp"
+#include "utils/chassis_utils.hpp"
#include <boost/system/errc.hpp>
#include <boost/system/error_code.hpp>
#include <sdbusplus/message/native_types.hpp>
#include <algorithm>
-#include <array>
#include <charconv>
#include <cstddef>
#include <cstdint>
@@ -64,11 +64,8 @@
CallbackFunc&& callback)
{
// Find managed chassis
- constexpr std::array<std::string_view, 2> interfaces = {
- "xyz.openbmc_project.Inventory.Item.Board",
- "xyz.openbmc_project.Inventory.Item.Chassis"};
dbus::utility::getSubTree(
- "/xyz/openbmc_project/inventory", 0, interfaces,
+ "/xyz/openbmc_project/inventory", 0, chassisInterfaces,
[callback = std::forward<CallbackFunc>(callback),
asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {