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>
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 10eee6d..b064f23 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -2931,44 +2931,20 @@
         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 @@
         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,