Allow configuring "bmc" and "system"
In the early days of bmcweb, we made two pretty critical assumptions;
First, is that a given platform would only have a single BMC instance
(represented as "bmc") and a single host instance (represented as
"system").
Second we assumed that, given that Redfish suggests against hardcoding
URIs in client implementation and leaves them freeform, clients would
code to the standard.
Our own webui-vue hardcodes Redfish URIs [1], and the documentation is
littered with examples of hardcoded curl examples of hardcoding these
URIs. That bug was filed in 2020, and the issue has only gotten worse
over time.
This patchset is an attempt to give a target that we can start solving
these issues, without trying to boil the ocean and fix all clients in
parallel.
This commit adds the meson options
redfish-manager-uri-name
and
redfish-system-uri-name
These are used to control the "name" that bmcweb places in the fixed
locations in the ManagerCollection and ComputerSystemCollection schemas.
Note, managers is added, but is not currently testable. It will be
iterated on over time.
Tested:
Changed the URL options to "edsbmc" and "edssystem" in meson options.
Redfish service validator passes.
URLs appear changed when walking the tree.
[1] https://github.com/openbmc/webui-vue/issues/43
Change-Id: I4b44685067051512bd065da8c2e3db68ae5ce23a
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 481c2a5..36acbf4 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -644,8 +644,8 @@
const std::string& dbusPath = appliedConfig->str;
nlohmann::json::object_t operatingConfig;
operatingConfig["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/Processors/{}/OperatingConfigs",
- cpuId);
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId);
json["OperatingConfigs"] = std::move(operatingConfig);
// Reuse the D-Bus config object name for the Redfish
@@ -662,8 +662,9 @@
}
nlohmann::json::object_t appliedOperatingConfig;
appliedOperatingConfig["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/Processors/{}/OperatingConfigs/{}",
- cpuId, dbusPath.substr(baseNamePos + 1));
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId,
+ dbusPath.substr(baseNamePos + 1));
json["AppliedOperatingConfig"] = std::move(appliedOperatingConfig);
// Once we found the current applied config, queue another
@@ -1034,7 +1035,8 @@
}
// Check that the config URI is a child of the cpu URI being patched.
- std::string expectedPrefix("/redfish/v1/Systems/system/Processors/");
+ std::string expectedPrefix(std::format("/redfish/v1/Systems/{}/Processors/",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME));
expectedPrefix += processorId;
expectedPrefix += "/OperatingConfigs/";
if (!appliedConfigUri.starts_with(expectedPrefix) ||
@@ -1113,7 +1115,7 @@
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);
@@ -1122,8 +1124,8 @@
asyncResp->res.jsonValue["@odata.type"] =
"#OperatingConfigCollection.OperatingConfigCollection";
asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/Processors/{}/OperatingConfigs",
- cpuName);
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName);
asyncResp->res.jsonValue["Name"] = "Operating Config Collection";
// First find the matching CPU object so we know how to
@@ -1160,8 +1162,8 @@
collection_util::getCollectionMembers(
asyncResp,
boost::urls::format(
- "/redfish/v1/Systems/system/Processors/{}/OperatingConfigs",
- cpuName),
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName),
interface, object);
return;
}
@@ -1192,7 +1194,7 @@
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);
@@ -1225,8 +1227,8 @@
nlohmann::json& json = asyncResp->res.jsonValue;
json["@odata.type"] = "#OperatingConfig.v1_0_0.OperatingConfig";
json["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/Processors/{}/OperatingConfigs/{}",
- cpuName, configName);
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName, configName);
json["Name"] = "Processor Profile";
json["Id"] = configName;
@@ -1271,7 +1273,7 @@
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);
@@ -1287,11 +1289,13 @@
asyncResp->res.jsonValue["Name"] = "Processor Collection";
asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/Processors";
+ std::format("/redfish/v1/Systems/{}/Processors",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
collection_util::getCollectionMembers(
asyncResp,
- boost::urls::url("/redfish/v1/Systems/system/Processors"),
+ boost::urls::format("/redfish/v1/Systems/{}/Processors",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME),
processorInterfaces, "/xyz/openbmc_project/inventory");
});
}
@@ -1325,7 +1329,7 @@
systemName);
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);
@@ -1337,8 +1341,9 @@
"</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
asyncResp->res.jsonValue["@odata.type"] =
"#Processor.v1_18_0.Processor";
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/Processors/{}", processorId);
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/Systems/{}/Processors/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, processorId);
getProcessorObject(
asyncResp, processorId,
@@ -1363,7 +1368,7 @@
systemName);
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);