Google RoT: remove global constant strings
These variables are replaced by local string literals, which has
better readability.
Tested: tested on real hardware.
GET: /google/v1/RootOfTrustCollection
{
"@odata.id": "/google/v1/RootOfTrustCollection",
"@odata.type": "#RootOfTrustCollection.RootOfTrustCollection",
"Members": [
{
"@odata.id": "/google/v1/RootOfTrustCollection/Hoth"
}
],
"Members@odata.count": 1
}
GET /google/v1/RootOfTrustCollection/Hoth
{
"@odata.id": "/google/v1/RootOfTrustCollection/Hoth",
"@odata.type": "#RootOfTrust.v1_0_0.RootOfTrust",
"Actions": {
"#RootOfTrust.SendCommand": {
"target": "/google/v1/RootOfTrustCollection/Hoth/Actions/RootOfTrust.SendCommand"
}
},
"Description": "Google Root Of Trust",
"Id": "Hoth",
"Location": {
"PartLocation": {
"LocationType": "Embedded",
"ServiceLabel": "Hoth"
}
},
"Name": "Hoth",
"Status": {
"State": "Enabled"
}
}
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I4c21eeb6a521b657bd9a8eb7394e7748d000ad52
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp
index 578ed8c..2d43146 100644
--- a/include/google/google_service_root.hpp
+++ b/include/google/google_service_root.hpp
@@ -15,9 +15,6 @@
{
namespace google_api
{
-constexpr const char* hothSearchPath = "/xyz/openbmc_project";
-constexpr const char* hothInterface = "xyz.openbmc_project.Control.Hoth";
-constexpr const char* rotCollectionPrefix = "/google/v1/RootOfTrustCollection";
inline void
handleGoogleV1Get(const crow::Request& /*req*/,
@@ -30,19 +27,19 @@
asyncResp->res.jsonValue["Name"] = "Google Service Root";
asyncResp->res.jsonValue["Version"] = "1.0.0";
asyncResp->res.jsonValue["RootOfTrustCollection"]["@odata.id"] =
- rotCollectionPrefix;
+ "/google/v1/RootOfTrustCollection";
}
inline void handleRootOfTrustCollectionGet(
const crow::Request& /*req*/,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- asyncResp->res.jsonValue["@odata.id"] = rotCollectionPrefix;
+ asyncResp->res.jsonValue["@odata.id"] = "/google/v1/RootOfTrustCollection";
asyncResp->res.jsonValue["@odata.type"] =
"#RootOfTrustCollection.RootOfTrustCollection";
redfish::collection_util::getCollectionMembers(
- asyncResp, rotCollectionPrefix, std::vector<const char*>{hothInterface},
- hothSearchPath);
+ asyncResp, "/google/v1/RootOfTrustCollection",
+ {"xyz.openbmc_project.Control.Hoth"}, "/xyz/openbmc_project");
}
// Helper struct to identify a resolved D-Bus object interface
@@ -82,10 +79,11 @@
continue;
}
- ResolvedEntity resolvedEntity = {.id = rotId,
- .service = object.second[0].first,
- .object = object.first,
- .interface = hothInterface};
+ ResolvedEntity resolvedEntity = {
+ .id = rotId,
+ .service = object.second[0].first,
+ .object = object.first,
+ .interface = "xyz.openbmc_project.Control.Hoth"};
entityHandler(command, asyncResp, resolvedEntity);
return;
}
@@ -101,7 +99,8 @@
ResolvedEntityHandler&& entityHandler)
{
- std::array<std::string, 1> hothIfaces = {hothInterface};
+ std::array<std::string, 1> hothIfaces = {
+ "xyz.openbmc_project.Control.Hoth"};
crow::connections::systemBus->async_method_call(
[command, asyncResp, rotId,
entityHandler{std::forward<ResolvedEntityHandler>(entityHandler)}](
@@ -112,7 +111,8 @@
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree", hothSearchPath,
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree",
+ "/xyz/openbmc_project",
/*depth=*/0, hothIfaces);
}