Redfish Aggregation: Aggregate Collections
Adds aggregation support for resource collections that take the form
of "/redfish/v1/<resource collection>". Collection URIs are
identified by the precense of a "Members" array in the response.
Resources from satellite BMCs are added to the "Members" array of
the response and the "Members@odata.count" value is updated to
denote the new array size.
These satellite resource URIs that are added also include the
prefix associated with that satellite.
Note that as a first step this patch assumes a single satellite BMC.
There are some potential race conditions that could occur for setups
with multiple satellite BMCs. This has been commented in the code
and is better left to its own patch.
Tested:
Queried various collection URIs and the aggregated resources
appeared in the response's "Members" array.
Querying 'localhost:80/redfish/v1/Chassis?$expand=.($levels=1)'
resulted in $expand correctly returning the outputs from querying
the URIs of all local and satellite Chassis resources. This would
have failed if the satellite Chassis resources were omitted from the
"Members" array or the satellite's prefix was not correctly added to
the URI.
Also queried a collection URI that only existed on the satellite BMC.
The AsyncResp was completely overwritten by the response from the
satellite BMC.
Queries to non-collection URIs resulted in no attempts to add
satellite responses to the AsyncResp.
Signed-off-by: Carson Labrado <clabrado@google.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I3b379cd57e5a121eb4a344d88fc8e43170ca78a6
diff --git a/http/utility.hpp b/http/utility.hpp
index d4b9b67..7857016 100644
--- a/http/utility.hpp
+++ b/http/utility.hpp
@@ -660,6 +660,13 @@
}
it++;
}
+
+ // There will be an empty segment at the end if the URI ends with a "/"
+ // e.g. /redfish/v1/Chassis/
+ if ((it != end) && urlSegments.back().empty())
+ {
+ it++;
+ }
return it == end;
}