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"
@@ -684,6 +685,49 @@ inline void requestRoutesManager(App& app)
684
685
asyncResp->res .jsonValue [" Links" ][" ManagerForServers" ] =
685
686
std::move (managerForServers);
686
687
}
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
+ }
687
731
688
732
sw_util::populateSoftwareInformation (asyncResp, sw_util::bmcPurpose,
689
733
" FirmwareVersion" , true );
@@ -697,22 +741,29 @@ inline void requestRoutesManager(App& app)
697
741
" /redfish/v1/Managers/{}/ManagerDiagnosticData" ,
698
742
BMCWEB_REDFISH_MANAGER_URI_NAME);
699
743
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
+ }
716
767
717
768
dbus::utility::getProperty<double >(
718
769
" org.freedesktop.systemd1" , " /org/freedesktop/systemd1" ,
@@ -931,8 +982,8 @@ inline void requestRoutesManagerCollection(App& app)
931
982
{
932
983
return ;
933
984
}
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
936
987
asyncResp->res .jsonValue [" @odata.id" ] = " /redfish/v1/Managers" ;
937
988
asyncResp->res .jsonValue [" @odata.type" ] =
938
989
" #ManagerCollection.ManagerCollection" ;
0 commit comments