20
20
#include " redfish.hpp"
21
21
#include " redfish_util.hpp"
22
22
#include " registries/privilege_registry.hpp"
23
+ #include " utility.hpp"
23
24
#include " utils/dbus_utils.hpp"
24
25
#include " utils/json_utils.hpp"
25
26
#include " utils/sw_utils.hpp"
@@ -695,6 +696,49 @@ inline void requestRoutesManager(App& app)
695
696
asyncResp->res .jsonValue [" Links" ][" ManagerForServers" ] =
696
697
std::move (managerForServers);
697
698
}
699
+ else
700
+ {
701
+ // multi-host bmc manages multiple hosts
702
+ constexpr std::array<std::string_view, 1 > interfaces{
703
+ " xyz.openbmc_project.Inventory.Decorator.ManagedHost" };
704
+ dbus::utility::getSubTree (
705
+ " /xyz/openbmc_project/inventory" , 0 , interfaces,
706
+ [asyncResp](const boost::system ::error_code& ec,
707
+ const dbus::utility::MapperGetSubTreeResponse&
708
+ subtree) {
709
+ if (ec)
710
+ {
711
+ if (ec.value () == boost::system ::errc::io_error)
712
+ {
713
+ // TODO 03/07/25-15:45 olek: proper error
714
+ // return
715
+ return ;
716
+ }
717
+
718
+ BMCWEB_LOG_ERROR (
719
+ " DBus method call failed with error {}" ,
720
+ ec.value ());
721
+ messages::internalError (asyncResp->res );
722
+ return ;
723
+ }
724
+
725
+ nlohmann::json::array_t managerForServers;
726
+ for (const auto & [path, serviceMap] : subtree)
727
+ {
728
+ boost::urls::url url (" /redfish/v1/Systems" );
729
+ std::string systemId =
730
+ sdbusplus::message::object_path (path)
731
+ .filename ();
732
+ crow::utility::appendUrlPieces (url, systemId);
733
+ BMCWEB_LOG_DEBUG (" Got url: {}" , url);
734
+ nlohmann::json::object_t member;
735
+ member[" @odata.id" ] = std::move (url);
736
+ managerForServers.emplace_back (member);
737
+ }
738
+ asyncResp->res .jsonValue [" Links" ][" ManagerForServers" ] =
739
+ std::move (managerForServers);
740
+ });
741
+ }
698
742
699
743
sw_util::populateSoftwareInformation (asyncResp, sw_util::bmcPurpose,
700
744
" FirmwareVersion" , true );
@@ -708,22 +752,29 @@ inline void requestRoutesManager(App& app)
708
752
" /redfish/v1/Managers/{}/ManagerDiagnosticData" ,
709
753
BMCWEB_REDFISH_MANAGER_URI_NAME);
710
754
711
- getMainChassisId (asyncResp, [](const std::string& chassisId,
712
- const std::shared_ptr<
713
- bmcweb::AsyncResp>& aRsp) {
714
- aRsp->res .jsonValue [" Links" ][" ManagerForChassis@odata.count" ] =
715
- 1 ;
716
- nlohmann::json::array_t managerForChassis;
717
- nlohmann::json::object_t managerObj;
718
- boost::urls::url chassiUrl =
719
- boost::urls::format (" /redfish/v1/Chassis/{}" , chassisId);
720
- managerObj[" @odata.id" ] = chassiUrl;
721
- managerForChassis.emplace_back (std::move (managerObj));
722
- aRsp->res .jsonValue [" Links" ][" ManagerForChassis" ] =
723
- std::move (managerForChassis);
724
- aRsp->res .jsonValue [" Links" ][" ManagerInChassis" ][" @odata.id" ] =
725
- chassiUrl;
726
- });
755
+ // Chassis is currently not supported on multi-host. Excluded here
756
+ // for Redfish Service Validator to pass. TBD
757
+ if constexpr (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
758
+ {
759
+ getMainChassisId (
760
+ asyncResp,
761
+ [](const std::string& chassisId,
762
+ const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
763
+ aRsp->res .jsonValue [" Links" ]
764
+ [" ManagerForChassis@odata.count" ] =
765
+ 1 ;
766
+ nlohmann::json::array_t managerForChassis;
767
+ nlohmann::json::object_t managerObj;
768
+ boost::urls::url chassiUrl = boost::urls::format (
769
+ " /redfish/v1/Chassis/{}" , chassisId);
770
+ managerObj[" @odata.id" ] = chassiUrl;
771
+ managerForChassis.emplace_back (std::move (managerObj));
772
+ aRsp->res .jsonValue [" Links" ][" ManagerForChassis" ] =
773
+ std::move (managerForChassis);
774
+ aRsp->res .jsonValue [" Links" ][" ManagerInChassis" ]
775
+ [" @odata.id" ] = chassiUrl;
776
+ });
777
+ }
727
778
728
779
dbus::utility::getProperty<double >(
729
780
" org.freedesktop.systemd1" , " /org/freedesktop/systemd1" ,
@@ -942,8 +993,8 @@ inline void requestRoutesManagerCollection(App& app)
942
993
{
943
994
return ;
944
995
}
945
- // Collections don't include the static data added by SubRoute
946
- // because it has a duplicate entry for members
996
+ // Collections don't include the static data added by
997
+ // SubRoute because it has a duplicate entry for members
947
998
asyncResp->res .jsonValue [" @odata.id" ] = " /redfish/v1/Managers" ;
948
999
asyncResp->res .jsonValue [" @odata.type" ] =
949
1000
" #ManagerCollection.ManagerCollection" ;
0 commit comments