summaryrefslogtreecommitdiff
path: root/redfish-core/lib/pcie.hpp
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-05-16 19:38:31 +0300
committerEd Tanous <ed@tanous.net>2024-05-21 01:42:28 +0300
commit253f11b84347de6bff7c6b624bef270fefae5f5a (patch)
tree71f8a40411f3a7482c689ea6448bc24956fc17cb /redfish-core/lib/pcie.hpp
parentfe907df460896297eb8b1fde00a18dd7cccab109 (diff)
downloadbmcweb-253f11b84347de6bff7c6b624bef270fefae5f5a.tar.xz
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>
Diffstat (limited to 'redfish-core/lib/pcie.hpp')
-rw-r--r--redfish-core/lib/pcie.hpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index af78cc8ab2..e62dc42ae8 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -115,7 +115,7 @@ static inline void handlePCIeDeviceCollectionGet(
systemName);
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);
@@ -127,8 +127,8 @@ static inline void handlePCIeDeviceCollectionGet(
"PCIeDeviceCollection.json>; rel=describedby");
asyncResp->res.jsonValue["@odata.type"] =
"#PCIeDeviceCollection.PCIeDeviceCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices";
+ asyncResp->res.jsonValue["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/PCIeDevices", BMCWEB_REDFISH_SYSTEM_URI_NAME);
asyncResp->res.jsonValue["Name"] = "PCIe Device Collection";
asyncResp->res.jsonValue["Description"] = "Collection of PCIe Devices";
@@ -494,8 +494,8 @@ inline void addPCIeDeviceProperties(
asyncResp->res.jsonValue["PCIeFunctions"]["@odata.id"] =
boost::urls::format(
- "/redfish/v1/Systems/system/PCIeDevices/{}/PCIeFunctions",
- pcieDeviceId);
+ "/redfish/v1/Systems/{}/PCIeDevices/{}/PCIeFunctions",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
}
inline void getPCIeDeviceProperties(
@@ -531,8 +531,9 @@ inline void addPCIeDeviceCommonProperties(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/PCIeDevice/PCIeDevice.json>; rel=describedby");
asyncResp->res.jsonValue["@odata.type"] = "#PCIeDevice.v1_9_0.PCIeDevice";
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/PCIeDevices/{}", pcieDeviceId);
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/Systems/{}/PCIeDevices/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
asyncResp->res.jsonValue["Name"] = "PCIe Device";
asyncResp->res.jsonValue["Id"] = pcieDeviceId;
asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
@@ -573,7 +574,7 @@ inline void
systemName);
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);
@@ -623,8 +624,9 @@ inline void addPCIeFunctionList(
nlohmann::json::object_t pcieFunction;
pcieFunction["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/PCIeDevices/{}/PCIeFunctions/{}",
- pcieDeviceId, std::to_string(functionNum));
+ "/redfish/v1/Systems/{}/PCIeDevices/{}/PCIeFunctions/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId,
+ std::to_string(functionNum));
pcieFunctionList.emplace_back(std::move(pcieFunction));
}
res.jsonValue["PCIeFunctions@odata.count"] = pcieFunctionList.size();
@@ -657,8 +659,8 @@ inline void handlePCIeFunctionCollectionGet(
asyncResp->res.jsonValue["@odata.type"] =
"#PCIeFunctionCollection.PCIeFunctionCollection";
asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/PCIeDevices/{}/PCIeFunctions",
- pcieDeviceId);
+ "/redfish/v1/Systems/{}/PCIeDevices/{}/PCIeFunctions",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
asyncResp->res.jsonValue["Name"] = "PCIe Function Collection";
asyncResp->res.jsonValue["Description"] =
"Collection of PCIe Functions for PCIe Device " + pcieDeviceId;
@@ -770,13 +772,15 @@ inline void addPCIeFunctionCommonProperties(crow::Response& resp,
"</redfish/v1/JsonSchemas/PCIeFunction/PCIeFunction.json>; rel=describedby");
resp.jsonValue["@odata.type"] = "#PCIeFunction.v1_2_3.PCIeFunction";
resp.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/PCIeDevices/{}/PCIeFunctions/{}",
- pcieDeviceId, std::to_string(pcieFunctionId));
+ "/redfish/v1/Systems/{}/PCIeDevices/{}/PCIeFunctions/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId,
+ std::to_string(pcieFunctionId));
resp.jsonValue["Name"] = "PCIe Function";
resp.jsonValue["Id"] = std::to_string(pcieFunctionId);
resp.jsonValue["FunctionId"] = pcieFunctionId;
- resp.jsonValue["Links"]["PCIeDevice"]["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/system/PCIeDevices/{}", pcieDeviceId);
+ resp.jsonValue["Links"]["PCIeDevice"]["@odata.id"] =
+ boost::urls::format("/redfish/v1/Systems/{}/PCIeDevices/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
}
inline void
@@ -797,7 +801,7 @@ inline void
systemName);
return;
}
- if (systemName != "system")
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
{
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
systemName);