blob: 0e0c5f083d2602672903500a649ed66604724b78 [file] [log] [blame]
Ed Tanous40e9b922024-09-10 13:50:16 -07001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright OpenBMC Authors
Sunny Srivastava31791052021-03-12 10:39:16 -06003#pragma once
4
5#include "app.hpp"
6#include "dbus_utility.hpp"
Ed Tanous539d8c62024-06-19 14:38:27 -07007#include "generated/enums/resource.hpp"
Ed Tanousa8e884f2023-01-13 17:40:03 -08008#include "query.hpp"
9#include "registries/privilege_registry.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -060010#include "utils/collection.hpp"
Lakshmi Yadlapati6177a302023-02-17 10:29:34 -060011#include "utils/dbus_utils.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -060012#include "utils/json_utils.hpp"
13
14#include <boost/system/error_code.hpp>
Ed Tanousef4c65b2023-04-24 15:28:50 -070015#include <boost/url/format.hpp>
Gunnar Millsf05e9162023-02-16 20:23:30 -060016#include <sdbusplus/asio/property.hpp>
Lakshmi Yadlapati6177a302023-02-17 10:29:34 -060017#include <sdbusplus/unpack_properties.hpp>
Sunny Srivastava31791052021-03-12 10:39:16 -060018
19#include <array>
20#include <functional>
21#include <memory>
Myung Bae78c90202024-02-19 13:39:56 -050022#include <optional>
Sunny Srivastava31791052021-03-12 10:39:16 -060023#include <string>
24#include <string_view>
25
26namespace redfish
27{
28
Ed Tanousac106bf2023-06-07 09:24:59 -070029inline void getFabricAdapterLocation(
30 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
31 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060032{
Ed Tanousdeae6a72024-11-11 21:58:57 -080033 dbus::utility::getProperty<std::string>(
34 serviceName, fabricAdapterPath,
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060035 "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
Ed Tanousac106bf2023-06-07 09:24:59 -070036 [asyncResp](const boost::system::error_code& ec,
37 const std::string& property) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040038 if (ec)
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060039 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040040 if (ec.value() != EBADR)
41 {
42 BMCWEB_LOG_ERROR("DBUS response error for Location");
43 messages::internalError(asyncResp->res);
44 }
45 return;
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060046 }
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060047
Patrick Williamsbd79bce2024-08-16 15:22:20 -040048 asyncResp->res
49 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
50 property;
51 });
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060052}
53
Patrick Williamsbd79bce2024-08-16 15:22:20 -040054inline void getFabricAdapterAsset(
55 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
56 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060057{
Ed Tanousdeae6a72024-11-11 21:58:57 -080058 dbus::utility::getAllProperties(
59 serviceName, fabricAdapterPath,
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060060 "xyz.openbmc_project.Inventory.Decorator.Asset",
Ed Tanousac106bf2023-06-07 09:24:59 -070061 [fabricAdapterPath, asyncResp{asyncResp}](
62 const boost::system::error_code& ec,
63 const dbus::utility::DBusPropertiesMap& propertiesList) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040064 if (ec)
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060065 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040066 if (ec.value() != EBADR)
67 {
68 BMCWEB_LOG_ERROR("DBUS response error for Properties");
69 messages::internalError(asyncResp->res);
70 }
71 return;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060072 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060073
Patrick Williamsbd79bce2024-08-16 15:22:20 -040074 const std::string* serialNumber = nullptr;
75 const std::string* model = nullptr;
76 const std::string* partNumber = nullptr;
77 const std::string* sparePartNumber = nullptr;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060078
Patrick Williamsbd79bce2024-08-16 15:22:20 -040079 const bool success = sdbusplus::unpackPropertiesNoThrow(
80 dbus_utils::UnpackErrorPrinter(), propertiesList,
81 "SerialNumber", serialNumber, "Model", model, "PartNumber",
82 partNumber, "SparePartNumber", sparePartNumber);
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060083
Patrick Williamsbd79bce2024-08-16 15:22:20 -040084 if (!success)
85 {
86 messages::internalError(asyncResp->res);
87 return;
88 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060089
Patrick Williamsbd79bce2024-08-16 15:22:20 -040090 if (serialNumber != nullptr)
91 {
92 asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
93 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060094
Patrick Williamsbd79bce2024-08-16 15:22:20 -040095 if (model != nullptr)
96 {
97 asyncResp->res.jsonValue["Model"] = *model;
98 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060099
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400100 if (partNumber != nullptr)
101 {
102 asyncResp->res.jsonValue["PartNumber"] = *partNumber;
103 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600104
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400105 if (sparePartNumber != nullptr && !sparePartNumber->empty())
106 {
107 asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
108 }
109 });
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600110}
111
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400112inline void getFabricAdapterState(
113 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
114 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600115{
Ed Tanousdeae6a72024-11-11 21:58:57 -0800116 dbus::utility::getProperty<bool>(
117 serviceName, fabricAdapterPath, "xyz.openbmc_project.Inventory.Item",
118 "Present",
Ed Tanousac106bf2023-06-07 09:24:59 -0700119 [asyncResp](const boost::system::error_code& ec, const bool present) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400120 if (ec)
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600121 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400122 if (ec.value() != EBADR)
123 {
124 BMCWEB_LOG_ERROR("DBUS response error for State");
125 messages::internalError(asyncResp->res);
126 }
127 return;
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600128 }
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600129
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400130 if (!present)
131 {
132 asyncResp->res.jsonValue["Status"]["State"] =
133 resource::State::Absent;
134 }
135 });
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600136}
137
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400138inline void getFabricAdapterHealth(
139 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
140 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600141{
Ed Tanousdeae6a72024-11-11 21:58:57 -0800142 dbus::utility::getProperty<bool>(
143 serviceName, fabricAdapterPath,
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600144 "xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
Ed Tanousac106bf2023-06-07 09:24:59 -0700145 [asyncResp](const boost::system::error_code& ec,
146 const bool functional) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400147 if (ec)
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600148 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400149 if (ec.value() != EBADR)
150 {
151 BMCWEB_LOG_ERROR("DBUS response error for Health");
152 messages::internalError(asyncResp->res);
153 }
154 return;
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600155 }
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600156
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400157 if (!functional)
158 {
159 asyncResp->res.jsonValue["Status"]["Health"] =
160 resource::Health::Critical;
161 }
162 });
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600163}
164
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400165inline void doAdapterGet(
166 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
167 const std::string& systemName, const std::string& adapterId,
168 const std::string& fabricAdapterPath, const std::string& serviceName)
Sunny Srivastava31791052021-03-12 10:39:16 -0600169{
Ed Tanousac106bf2023-06-07 09:24:59 -0700170 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600171 boost::beast::http::field::link,
172 "</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
Ed Tanousac106bf2023-06-07 09:24:59 -0700173 asyncResp->res.jsonValue["@odata.type"] =
174 "#FabricAdapter.v1_4_0.FabricAdapter";
175 asyncResp->res.jsonValue["Name"] = "Fabric Adapter";
176 asyncResp->res.jsonValue["Id"] = adapterId;
177 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
Ed Tanousef4c65b2023-04-24 15:28:50 -0700178 "/redfish/v1/Systems/{}/FabricAdapters/{}", systemName, adapterId);
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -0600179
Ed Tanous539d8c62024-06-19 14:38:27 -0700180 asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
181 asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600182
Ed Tanousac106bf2023-06-07 09:24:59 -0700183 getFabricAdapterLocation(asyncResp, serviceName, fabricAdapterPath);
184 getFabricAdapterAsset(asyncResp, serviceName, fabricAdapterPath);
185 getFabricAdapterState(asyncResp, serviceName, fabricAdapterPath);
186 getFabricAdapterHealth(asyncResp, serviceName, fabricAdapterPath);
Sunny Srivastava31791052021-03-12 10:39:16 -0600187}
188
Myung Bae78c90202024-02-19 13:39:56 -0500189inline void afterGetValidFabricAdapterPath(
190 const std::string& adapterId,
191 std::function<void(const boost::system::error_code&,
192 const std::string& fabricAdapterPath,
193 const std::string& serviceName)>& callback,
194 const boost::system::error_code& ec,
195 const dbus::utility::MapperGetSubTreeResponse& subtree)
Sunny Srivastava31791052021-03-12 10:39:16 -0600196{
Myung Bae78c90202024-02-19 13:39:56 -0500197 std::string fabricAdapterPath;
198 std::string serviceName;
199 if (ec)
200 {
201 callback(ec, fabricAdapterPath, serviceName);
202 return;
203 }
Sunny Srivastava31791052021-03-12 10:39:16 -0600204
Myung Bae78c90202024-02-19 13:39:56 -0500205 for (const auto& [adapterPath, serviceMap] : subtree)
206 {
207 std::string fabricAdapterName =
208 sdbusplus::message::object_path(adapterPath).filename();
209 if (fabricAdapterName == adapterId)
210 {
211 fabricAdapterPath = adapterPath;
212 serviceName = serviceMap.begin()->first;
213 break;
214 }
215 }
216 callback(ec, fabricAdapterPath, serviceName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600217}
218
219inline void getValidFabricAdapterPath(
Myung Bae78c90202024-02-19 13:39:56 -0500220 const std::string& adapterId,
221 std::function<void(const boost::system::error_code& ec,
222 const std::string& fabricAdapterPath,
Sunny Srivastava31791052021-03-12 10:39:16 -0600223 const std::string& serviceName)>&& callback)
224{
Sunny Srivastava31791052021-03-12 10:39:16 -0600225 constexpr std::array<std::string_view, 1> interfaces{
226 "xyz.openbmc_project.Inventory.Item.FabricAdapter"};
Myung Bae78c90202024-02-19 13:39:56 -0500227 dbus::utility::getSubTree("/xyz/openbmc_project/inventory", 0, interfaces,
228 std::bind_front(afterGetValidFabricAdapterPath,
229 adapterId, std::move(callback)));
230}
Sunny Srivastava31791052021-03-12 10:39:16 -0600231
Myung Bae78c90202024-02-19 13:39:56 -0500232inline void afterHandleFabricAdapterGet(
233 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
234 const std::string& systemName, const std::string& adapterId,
235 const boost::system::error_code& ec, const std::string& fabricAdapterPath,
236 const std::string& serviceName)
237{
238 if (ec)
239 {
240 if (ec.value() == boost::system::errc::io_error)
Sunny Srivastava31791052021-03-12 10:39:16 -0600241 {
Myung Bae78c90202024-02-19 13:39:56 -0500242 messages::resourceNotFound(asyncResp->res, "FabricAdapter",
243 adapterId);
Sunny Srivastava31791052021-03-12 10:39:16 -0600244 return;
245 }
Myung Bae78c90202024-02-19 13:39:56 -0500246
247 BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value());
248 messages::internalError(asyncResp->res);
249 return;
250 }
251 if (fabricAdapterPath.empty() || serviceName.empty())
252 {
Ed Tanous62598e32023-07-17 17:06:25 -0700253 BMCWEB_LOG_WARNING("Adapter not found");
Ed Tanousac106bf2023-06-07 09:24:59 -0700254 messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
Myung Bae78c90202024-02-19 13:39:56 -0500255 return;
256 }
257 doAdapterGet(asyncResp, systemName, adapterId, fabricAdapterPath,
258 serviceName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600259}
260
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400261inline void handleFabricAdapterGet(
262 App& app, const crow::Request& req,
263 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
264 const std::string& systemName, const std::string& adapterId)
Sunny Srivastava31791052021-03-12 10:39:16 -0600265{
Ed Tanousac106bf2023-06-07 09:24:59 -0700266 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600267 {
268 return;
269 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700270 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800271 {
272 // Option currently returns no systems. TBD
273 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
274 systemName);
275 return;
276 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700277 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Myung Bae78c90202024-02-19 13:39:56 -0500278 {
279 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
280 systemName);
281 return;
282 }
Sunny Srivastava31791052021-03-12 10:39:16 -0600283 getValidFabricAdapterPath(
Myung Bae78c90202024-02-19 13:39:56 -0500284 adapterId, std::bind_front(afterHandleFabricAdapterGet, asyncResp,
285 systemName, adapterId));
Sunny Srivastava31791052021-03-12 10:39:16 -0600286}
287
288inline void handleFabricAdapterCollectionGet(
289 crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700290 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600291 const std::string& systemName)
292{
Ed Tanousac106bf2023-06-07 09:24:59 -0700293 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600294 {
295 return;
296 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700297 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800298 {
299 // Option currently returns no systems. TBD
300 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
301 systemName);
302 return;
303 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700304 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Sunny Srivastava31791052021-03-12 10:39:16 -0600305 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700306 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
307 systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600308 return;
309 }
310
Ed Tanousac106bf2023-06-07 09:24:59 -0700311 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600312 boost::beast::http::field::link,
313 "</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
Ed Tanousac106bf2023-06-07 09:24:59 -0700314 asyncResp->res.jsonValue["@odata.type"] =
Sunny Srivastava31791052021-03-12 10:39:16 -0600315 "#FabricAdapterCollection.FabricAdapterCollection";
Ed Tanousac106bf2023-06-07 09:24:59 -0700316 asyncResp->res.jsonValue["Name"] = "Fabric Adapter Collection";
317 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
Ed Tanousef4c65b2023-04-24 15:28:50 -0700318 "/redfish/v1/Systems/{}/FabricAdapters", systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600319
320 constexpr std::array<std::string_view, 1> interfaces{
321 "xyz.openbmc_project.Inventory.Item.FabricAdapter"};
322 collection_util::getCollectionMembers(
Ed Tanousac106bf2023-06-07 09:24:59 -0700323 asyncResp,
Ed Tanous253f11b2024-05-16 09:38:31 -0700324 boost::urls::format("/redfish/v1/Systems/{}/FabricAdapters",
325 BMCWEB_REDFISH_SYSTEM_URI_NAME),
Lakshmi Yadlapati36b5f1e2023-09-26 23:53:28 -0500326 interfaces, "/xyz/openbmc_project/inventory");
Sunny Srivastava31791052021-03-12 10:39:16 -0600327}
328
329inline void handleFabricAdapterCollectionHead(
330 crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700331 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600332 const std::string& systemName)
333{
Ed Tanousac106bf2023-06-07 09:24:59 -0700334 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600335 {
336 return;
337 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700338 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800339 {
340 // Option currently returns no systems. TBD
341 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
342 systemName);
343 return;
344 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700345 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Sunny Srivastava31791052021-03-12 10:39:16 -0600346 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700347 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
348 systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600349 return;
350 }
Ed Tanousac106bf2023-06-07 09:24:59 -0700351 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600352 boost::beast::http::field::link,
353 "</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
354}
355
Myung Bae78c90202024-02-19 13:39:56 -0500356inline void afterHandleFabricAdapterHead(
357 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
358 const std::string& adapterId, const boost::system::error_code& ec,
359 const std::string& fabricAdapterPath, const std::string& serviceName)
360{
361 if (ec)
362 {
363 if (ec.value() == boost::system::errc::io_error)
364 {
365 messages::resourceNotFound(asyncResp->res, "FabricAdapter",
366 adapterId);
367 return;
368 }
369
370 BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value());
371 messages::internalError(asyncResp->res);
372 return;
373 }
374 if (fabricAdapterPath.empty() || serviceName.empty())
375 {
376 BMCWEB_LOG_WARNING("Adapter not found");
377 messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
378 return;
379 }
380 asyncResp->res.addHeader(
381 boost::beast::http::field::link,
382 "</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
383}
384
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400385inline void handleFabricAdapterHead(
386 crow::App& app, const crow::Request& req,
387 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
388 const std::string& systemName, const std::string& adapterId)
Sunny Srivastava31791052021-03-12 10:39:16 -0600389{
Ed Tanousac106bf2023-06-07 09:24:59 -0700390 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600391 {
392 return;
393 }
394
Ed Tanous25b54db2024-04-17 15:40:31 -0700395 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800396 {
397 // Option currently returns no systems. TBD
398 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
399 systemName);
400 return;
401 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700402 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Myung Bae78c90202024-02-19 13:39:56 -0500403 {
404 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
405 systemName);
406 return;
407 }
408 getValidFabricAdapterPath(
409 adapterId,
410 std::bind_front(afterHandleFabricAdapterHead, asyncResp, adapterId));
Sunny Srivastava31791052021-03-12 10:39:16 -0600411}
412
413inline void requestRoutesFabricAdapterCollection(App& app)
414{
415 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/")
416 .privileges(redfish::privileges::getFabricAdapterCollection)
417 .methods(boost::beast::http::verb::get)(
418 std::bind_front(handleFabricAdapterCollectionGet, std::ref(app)));
419
420 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/")
421 .privileges(redfish::privileges::headFabricAdapterCollection)
422 .methods(boost::beast::http::verb::head)(
423 std::bind_front(handleFabricAdapterCollectionHead, std::ref(app)));
424}
425
426inline void requestRoutesFabricAdapters(App& app)
427{
428 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/<str>/")
429 .privileges(redfish::privileges::getFabricAdapter)
430 .methods(boost::beast::http::verb::get)(
431 std::bind_front(handleFabricAdapterGet, std::ref(app)));
432
433 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/<str>/")
434 .privileges(redfish::privileges::headFabricAdapter)
435 .methods(boost::beast::http::verb::head)(
436 std::bind_front(handleFabricAdapterHead, std::ref(app)));
437}
438} // namespace redfish