Skip to content

Commit 675637f

Browse files
committed
WIP: managers.hpp - support for multi-host
This change adds multi-host support in manager.hpp. Mainly returning all valid redfish links for the ManagerForServers array. In addition we opt out of calling getMainChassisId when on multi-host. Needs more clarification what exactly should be returned for that, if anything. Testing: TBD Change-Id: Ia73cabc23cd87128a59df5c7b16af0bf87462925 Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
1 parent 8c71e7d commit 675637f

File tree

1 file changed

+69
-18
lines changed

1 file changed

+69
-18
lines changed

redfish-core/lib/managers.hpp

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "redfish.hpp"
2121
#include "redfish_util.hpp"
2222
#include "registries/privilege_registry.hpp"
23+
#include "utility.hpp"
2324
#include "utils/dbus_utils.hpp"
2425
#include "utils/json_utils.hpp"
2526
#include "utils/sw_utils.hpp"
@@ -684,6 +685,49 @@ inline void requestRoutesManager(App& app)
684685
asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
685686
std::move(managerForServers);
686687
}
688+
else
689+
{
690+
// multi-host bmc manages multiple hosts
691+
constexpr std::array<std::string_view, 1> interfaces{
692+
"xyz.openbmc_project.Inventory.Decorator.ManagedHost"};
693+
dbus::utility::getSubTree(
694+
"/xyz/openbmc_project/inventory", 0, interfaces,
695+
[asyncResp](const boost::system::error_code& ec,
696+
const dbus::utility::MapperGetSubTreeResponse&
697+
subtree) {
698+
if (ec)
699+
{
700+
if (ec.value() == boost::system::errc::io_error)
701+
{
702+
// TODO 03/07/25-15:45 olek: proper error
703+
// return
704+
return;
705+
}
706+
707+
BMCWEB_LOG_ERROR(
708+
"DBus method call failed with error {}",
709+
ec.value());
710+
messages::internalError(asyncResp->res);
711+
return;
712+
}
713+
714+
nlohmann::json::array_t managerForServers;
715+
for (const auto& [path, serviceMap] : subtree)
716+
{
717+
boost::urls::url url("/redfish/v1/Systems");
718+
std::string systemId =
719+
sdbusplus::message::object_path(path)
720+
.filename();
721+
crow::utility::appendUrlPieces(url, systemId);
722+
BMCWEB_LOG_DEBUG("Got url: {}", url);
723+
nlohmann::json::object_t member;
724+
member["@odata.id"] = std::move(url);
725+
managerForServers.emplace_back(member);
726+
}
727+
asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
728+
std::move(managerForServers);
729+
});
730+
}
687731

688732
sw_util::populateSoftwareInformation(asyncResp, sw_util::bmcPurpose,
689733
"FirmwareVersion", true);
@@ -697,22 +741,29 @@ inline void requestRoutesManager(App& app)
697741
"/redfish/v1/Managers/{}/ManagerDiagnosticData",
698742
BMCWEB_REDFISH_MANAGER_URI_NAME);
699743

700-
getMainChassisId(asyncResp, [](const std::string& chassisId,
701-
const std::shared_ptr<
702-
bmcweb::AsyncResp>& aRsp) {
703-
aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] =
704-
1;
705-
nlohmann::json::array_t managerForChassis;
706-
nlohmann::json::object_t managerObj;
707-
boost::urls::url chassiUrl =
708-
boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
709-
managerObj["@odata.id"] = chassiUrl;
710-
managerForChassis.emplace_back(std::move(managerObj));
711-
aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
712-
std::move(managerForChassis);
713-
aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
714-
chassiUrl;
715-
});
744+
// Chassis is currently not supported on multi-host. Excluded here
745+
// for Redfish Service Validator to pass. TBD
746+
if constexpr (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
747+
{
748+
getMainChassisId(
749+
asyncResp,
750+
[](const std::string& chassisId,
751+
const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
752+
aRsp->res.jsonValue["Links"]
753+
["ManagerForChassis@odata.count"] =
754+
1;
755+
nlohmann::json::array_t managerForChassis;
756+
nlohmann::json::object_t managerObj;
757+
boost::urls::url chassiUrl = boost::urls::format(
758+
"/redfish/v1/Chassis/{}", chassisId);
759+
managerObj["@odata.id"] = chassiUrl;
760+
managerForChassis.emplace_back(std::move(managerObj));
761+
aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
762+
std::move(managerForChassis);
763+
aRsp->res.jsonValue["Links"]["ManagerInChassis"]
764+
["@odata.id"] = chassiUrl;
765+
});
766+
}
716767

717768
dbus::utility::getProperty<double>(
718769
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
@@ -931,8 +982,8 @@ inline void requestRoutesManagerCollection(App& app)
931982
{
932983
return;
933984
}
934-
// Collections don't include the static data added by SubRoute
935-
// because it has a duplicate entry for members
985+
// Collections don't include the static data added by
986+
// SubRoute because it has a duplicate entry for members
936987
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
937988
asyncResp->res.jsonValue["@odata.type"] =
938989
"#ManagerCollection.ManagerCollection";

0 commit comments

Comments
 (0)