Aggregation: Improve prefix fixup matching
Utilize the new array of top level collection URIs to determine if a
given URI in the response needs to have the aggregation prefix added.
This removes the need to check for specific collections like
/redfish/v1/UpdateService/FirmwareInventory which do not fit the
generic format of /redfish/v1/<collection>.
Future patches will use this same approach to improve the logic for
initially determining if and how a request should be aggregated.
This patch also adds a series of unit tests for the function
responsible for adding a prefix to a given URI. Cases covered include
valid URIs that involve a selection of aggregated resources, top level
collection URIs, other invalid URIs, and URIs with a trailing "/".
Tested:
Unit tests pass.
Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: I676983d3c77ae3126c04e9f57ad8698c51df2675
diff --git a/scripts/generate_schema_collections.py b/scripts/generate_schema_collections.py
index c9f8b59..d6efa0e 100755
--- a/scripts/generate_schema_collections.py
+++ b/scripts/generate_schema_collections.py
@@ -266,17 +266,17 @@
"\n"
"namespace redfish\n"
"{{\n"
- '// Note that each URI actually begins with "/redfish/v1/"\n'
+ '// Note that each URI actually begins with "/redfish/v1"\n'
"// They've been omitted to save space and reduce search time\n"
"constexpr std::array<std::string_view, {TOTAL}> "
"topCollections{{\n".format(WARNING=WARNING, TOTAL=TOTAL)
)
for collection in sorted(top_collections):
- # All URIs start with "/redfish/v1/". We can omit that portion to
+ # All URIs start with "/redfish/v1". We can omit that portion to
# save memory and reduce lookup time
hpp_file.write(
- ' "{}",\n'.format(collection.split("/redfish/v1/")[1])
+ ' "{}",\n'.format(collection.split("/redfish/v1")[1])
)
hpp_file.write("};\n} // namespace redfish\n")