diff options
| author | Oliver Brewka <oliver.brewka@9elements.com> | 2025-07-23 17:42:24 +0300 |
|---|---|---|
| committer | Ed Tanous <ed@tanous.net> | 2025-08-26 02:34:59 +0300 |
| commit | 06c055e7fa44cecc59f7b8abc55db6e480a2c9b2 (patch) | |
| tree | cf9b38aa23b3cc406c767b2d0e46e71724acf85d | |
| parent | d43cc6bcbc8b1d6f4c8a6e8945c9a6a34a6aaca8 (diff) | |
| download | bmcweb-06c055e7fa44cecc59f7b8abc55db6e480a2c9b2.tar.xz | |
Multi-host support for POST routes in systems.hpp
Add support for multi-host POST request-handling under the
/redfish/v1/Systems/{computerSystemId}/ redfish resource.
All multi-host supported redfish URIs can be found in this listing [1].
Multi-host meson options needed:
-Dexperimental-redfish-multi-computer-system=enabled
Tested:
POST route has been manually tested in web-ui on single-host hardware.
All possible power controls worked as expected. For multi-host this
was tested manually with curl in qemu. After requesting the expected
changes have been observed on dbus.
```
curl -k -X POST 'https://localhost:4443/redfish/v1/Systems/Yosemite_4_Sentinel_Dome_T1_Slot_1/Actions/ComputerSystem.Reset' \
-H 'X-Auth-Token: '"$BMCWEB_SESSION_TOKEN"'' \
-H "Content-Type: application/json" -d '{"ResetType": "GracefulShutdown"}'
root@yosemite4:~# busctl -l introspect xyz.openbmc_project.State.Host1 /xyz/openbmc_project/state/host1
NAME TYPE SIGNATURE RESULT/VALUE
...
xyz.openbmc_project.State.Host interface - - -
.AllowedHostTransitions property as 5 "xyz.openbmc_project.State.Host.Transition.Off" "xyz.openbmc_project.State.Host.Transition.On" "xyz.openbmc_project.State.Host.Transition.Reboot" "xyz.openbmc_project.State.Host.Transition.GracefulWarmReboot" "xyz.openbmc_project.State.Host.Transition.ForceWarmReboot" const
.CurrentHostState property s "xyz.openbmc_project.State.Host.HostState.TransitioningToOff" emits-change writable
.RequestedHostTransition property s "xyz.openbmc_project.State.Host.Transition.Off"
...
```
Change-Id: I5f2511939501d88fd700bcbffcfd810776d6a5b4
Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
| -rw-r--r-- | redfish-core/lib/systems.hpp | 102 |
1 files changed, 60 insertions, 42 deletions
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 10eee6d466..b064f23a73 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -2931,44 +2931,20 @@ inline void doNMI(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) serviceName, objectPath, interfaceName, method); } -inline void handleComputerSystemResetActionPost( - crow::App& app, const crow::Request& req, - const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& systemName) +/** + * @brief process the POST request after getting the computerSystemIndex + * + * @param[in] asyncResp Shared pointer for completing asynchronous + * calls + * @param[in] resetType The requested reset action + * @param[in] computerSystemIndex Index associated with the requested system + * + * @return None + */ +inline void processComputerSystemResetActionPost( + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string& resetType, + const uint64_t computerSystemIndex) { - if (!redfish::setUpRedfishRoute(app, req, asyncResp)) - { - return; - } - - if constexpr (BMCWEB_HYPERVISOR_COMPUTER_SYSTEM) - { - if (systemName == "hypervisor") - { - handleHypervisorSystemResetPost(req, asyncResp); - return; - } - } - - if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) - { - messages::resourceNotFound(asyncResp->res, "ComputerSystem", - systemName); - return; - } - if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) - { - // Option currently returns no systems. TBD - messages::resourceNotFound(asyncResp->res, "ComputerSystem", - systemName); - return; - } - std::string resetType; - if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", resetType)) - { - return; - } - // Get the command and host vs. chassis std::string command; bool hostCommand = true; @@ -3013,23 +2989,65 @@ inline void handleComputerSystemResetActionPost( messages::actionParameterUnknown(asyncResp->res, "Reset", resetType); return; } - sdbusplus::message::object_path statePath("/xyz/openbmc_project/state"); if (hostCommand) { - setDbusProperty(asyncResp, "Reset", "xyz.openbmc_project.State.Host", - statePath / "host0", "xyz.openbmc_project.State.Host", + setDbusProperty(asyncResp, "Reset", + getHostStateServiceName(computerSystemIndex), + getHostStateObjectPath(computerSystemIndex), + "xyz.openbmc_project.State.Host", "RequestedHostTransition", command); } else { - setDbusProperty(asyncResp, "Reset", "xyz.openbmc_project.State.Chassis", - statePath / "chassis0", + setDbusProperty(asyncResp, "Reset", + getChassisStateServiceName(computerSystemIndex), + getChassisStateObjectPath(computerSystemIndex), "xyz.openbmc_project.State.Chassis", "RequestedPowerTransition", command); } } +inline void handleComputerSystemResetActionPost( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& systemName) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + + if constexpr (BMCWEB_HYPERVISOR_COMPUTER_SYSTEM) + { + if (systemName == "hypervisor") + { + handleHypervisorSystemResetPost(req, asyncResp); + return; + } + } + + if (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) + { + if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } + } + + std::string resetType; + if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", resetType)) + { + return; + } + + getComputerSystemIndex(asyncResp, systemName, + std::bind_front(processComputerSystemResetActionPost, + asyncResp, resetType)); +} + inline void handleComputerSystemHead( App& app, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
