Aggregation: Prepare for routing requests

We do not want to allow a HW config to set its own prefix since that
results in HW choosing and hardcoding resource URIs.  Removes using
"Name" from the satellite config as the config's prefix.

For now assume there will be no more than one satellite bmc.  We will
always assign that config to be "aggregated0".  If more than one
config is present then we will not attempt to forward any requests.
In a future patch we will add support for aggregating multiple
satellite BMCs.  The aggregator will be responsible for assigning the
prefixes to each satellite.

When we receive a request we parse the resource ID to see if it
begins with "aggregated" and thus should be forwarded to a satellite
BMC.  In those cases we should not locally handle the request.  We
return a 500 error, but in a future patch that will be replaced by
the actual code to forward the request to the appropriate satellite.

Requests for resource collections need to be both handled locally and
forwarded.  Place holders are added for where the forwarding will
occur.  A future patch will add that functionality.

Tested:
Exposed two configs in an entity-manager json:
"Exposes": [
{
  "Hostname": "127.0.0.1",
  "Port": "443",
  "Name": "Sat1",
  "Type": "SatelliteController",
  "AuthType": "None"
},
{
  "Hostname": "127.0.0.1",
  "Port": "444",
  "Name": "Sat2",
  "Type": "SatelliteController",
  "AuthType": "None"
},

It produced an error that only one satellite is supported and as a
result both configs were ignored.  I removed the second config and
that resulted in the first (and only) config being added as
"aggregated0".

Requests for local resources were ignored by the aggregation code.
Requests for collections hit the forward collection endpoints and
return local results.

500 returned for satellite resources such as:
/redfish/v1/Chassis/aggregated0_Fake
/redfish/v1/UpdateService/FirmwareInventory/aggregated0_Fake
/redfish/v1/UpdateService/SoftwareInventory/aggregated0_Fake

Change-Id: I5c860c01534e7d5b1a37c95f75be5b3c1f695816
Signed-off-by: Carson Labrado <clabrado@google.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp
index fd5d189..007b262 100644
--- a/redfish-core/include/query.hpp
+++ b/redfish-core/include/query.hpp
@@ -27,6 +27,8 @@
 // IWYU pragma: no_include <boost/url/impl/params_view.hpp>
 // IWYU pragma: no_include <boost/url/impl/url_view.hpp>
 
+#include <redfish_aggregator.hpp>
+
 namespace redfish
 {
 
@@ -62,10 +64,20 @@
         return false;
     }
 
+    bool needToCallHandlers = true;
+
+#ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION
+    needToCallHandlers = RedfishAggregator::getInstance().beginAggregation(
+                             req, asyncResp) == Result::LocalHandle;
+
+    // If the request should be forwarded to a satellite BMC then we don't want
+    // to write anything to the asyncResp since it will get overwritten later.
+#endif
+
     // If this isn't a get, no need to do anything with parameters
     if (req.method() != boost::beast::http::verb::get)
     {
-        return true;
+        return needToCallHandlers;
     }
 
     delegated = query_param::delegate(queryCapabilities, *queryOpt);
@@ -78,7 +90,7 @@
         processAllParams(app, query, handler, resIn);
     });
 
-    return true;
+    return needToCallHandlers;
 }
 
 // Sets up the Redfish Route. All parameters are handled by the default handler.