blob: acd6d8f95e30e9b3f89c4c6c1b5cd528cd513a9d [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
Ed Tanousd7857202025-01-28 15:32:26 -08005#include "bmcweb_config.h"
6
Sunny Srivastava31791052021-03-12 10:39:16 -06007#include "app.hpp"
Ed Tanousd7857202025-01-28 15:32:26 -08008#include "async_resp.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -06009#include "dbus_utility.hpp"
Ed Tanousd7857202025-01-28 15:32:26 -080010#include "error_messages.hpp"
Ed Tanous539d8c62024-06-19 14:38:27 -070011#include "generated/enums/resource.hpp"
Ed Tanousd7857202025-01-28 15:32:26 -080012#include "http_request.hpp"
13#include "logging.hpp"
Ed Tanousa8e884f2023-01-13 17:40:03 -080014#include "query.hpp"
15#include "registries/privilege_registry.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -060016#include "utils/collection.hpp"
Lakshmi Yadlapati6177a302023-02-17 10:29:34 -060017#include "utils/dbus_utils.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -060018
Ed Tanousd7857202025-01-28 15:32:26 -080019#include <asm-generic/errno.h>
20
21#include <boost/beast/http/field.hpp>
22#include <boost/beast/http/verb.hpp>
Sunny Srivastava31791052021-03-12 10:39:16 -060023#include <boost/system/error_code.hpp>
Ed Tanousef4c65b2023-04-24 15:28:50 -070024#include <boost/url/format.hpp>
Lakshmi Yadlapati6177a302023-02-17 10:29:34 -060025#include <sdbusplus/unpack_properties.hpp>
Sunny Srivastava31791052021-03-12 10:39:16 -060026
27#include <array>
28#include <functional>
29#include <memory>
30#include <string>
31#include <string_view>
Ed Tanousd7857202025-01-28 15:32:26 -080032#include <utility>
Sunny Srivastava31791052021-03-12 10:39:16 -060033
34namespace redfish
35{
36
Ed Tanousac106bf2023-06-07 09:24:59 -070037inline void getFabricAdapterLocation(
38 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
39 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060040{
Ed Tanousdeae6a72024-11-11 21:58:57 -080041 dbus::utility::getProperty<std::string>(
42 serviceName, fabricAdapterPath,
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060043 "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
Ed Tanousac106bf2023-06-07 09:24:59 -070044 [asyncResp](const boost::system::error_code& ec,
45 const std::string& property) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040046 if (ec)
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060047 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040048 if (ec.value() != EBADR)
49 {
50 BMCWEB_LOG_ERROR("DBUS response error for Location");
51 messages::internalError(asyncResp->res);
52 }
53 return;
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060054 }
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060055
Patrick Williamsbd79bce2024-08-16 15:22:20 -040056 asyncResp->res
57 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
58 property;
59 });
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060060}
61
Patrick Williamsbd79bce2024-08-16 15:22:20 -040062inline void getFabricAdapterAsset(
63 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
64 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060065{
Ed Tanousdeae6a72024-11-11 21:58:57 -080066 dbus::utility::getAllProperties(
67 serviceName, fabricAdapterPath,
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060068 "xyz.openbmc_project.Inventory.Decorator.Asset",
Ed Tanousac106bf2023-06-07 09:24:59 -070069 [fabricAdapterPath, asyncResp{asyncResp}](
70 const boost::system::error_code& ec,
71 const dbus::utility::DBusPropertiesMap& propertiesList) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040072 if (ec)
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060073 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -040074 if (ec.value() != EBADR)
75 {
76 BMCWEB_LOG_ERROR("DBUS response error for Properties");
77 messages::internalError(asyncResp->res);
78 }
79 return;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060080 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060081
Patrick Williamsbd79bce2024-08-16 15:22:20 -040082 const std::string* serialNumber = nullptr;
83 const std::string* model = nullptr;
84 const std::string* partNumber = nullptr;
85 const std::string* sparePartNumber = nullptr;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060086
Patrick Williamsbd79bce2024-08-16 15:22:20 -040087 const bool success = sdbusplus::unpackPropertiesNoThrow(
88 dbus_utils::UnpackErrorPrinter(), propertiesList,
89 "SerialNumber", serialNumber, "Model", model, "PartNumber",
90 partNumber, "SparePartNumber", sparePartNumber);
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060091
Patrick Williamsbd79bce2024-08-16 15:22:20 -040092 if (!success)
93 {
94 messages::internalError(asyncResp->res);
95 return;
96 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060097
Patrick Williamsbd79bce2024-08-16 15:22:20 -040098 if (serialNumber != nullptr)
99 {
100 asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
101 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600102
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400103 if (model != nullptr)
104 {
105 asyncResp->res.jsonValue["Model"] = *model;
106 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600107
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400108 if (partNumber != nullptr)
109 {
110 asyncResp->res.jsonValue["PartNumber"] = *partNumber;
111 }
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600112
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400113 if (sparePartNumber != nullptr && !sparePartNumber->empty())
114 {
115 asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
116 }
117 });
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600118}
119
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400120inline void getFabricAdapterState(
121 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
122 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600123{
Ed Tanousdeae6a72024-11-11 21:58:57 -0800124 dbus::utility::getProperty<bool>(
125 serviceName, fabricAdapterPath, "xyz.openbmc_project.Inventory.Item",
126 "Present",
Ed Tanousac106bf2023-06-07 09:24:59 -0700127 [asyncResp](const boost::system::error_code& ec, const bool present) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400128 if (ec)
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600129 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400130 if (ec.value() != EBADR)
131 {
132 BMCWEB_LOG_ERROR("DBUS response error for State");
133 messages::internalError(asyncResp->res);
134 }
135 return;
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600136 }
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600137
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400138 if (!present)
139 {
140 asyncResp->res.jsonValue["Status"]["State"] =
141 resource::State::Absent;
142 }
143 });
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600144}
145
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400146inline void getFabricAdapterHealth(
147 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
148 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600149{
Ed Tanousdeae6a72024-11-11 21:58:57 -0800150 dbus::utility::getProperty<bool>(
151 serviceName, fabricAdapterPath,
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600152 "xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
Ed Tanousac106bf2023-06-07 09:24:59 -0700153 [asyncResp](const boost::system::error_code& ec,
154 const bool functional) {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400155 if (ec)
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600156 {
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400157 if (ec.value() != EBADR)
158 {
159 BMCWEB_LOG_ERROR("DBUS response error for Health");
160 messages::internalError(asyncResp->res);
161 }
162 return;
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600163 }
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600164
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400165 if (!functional)
166 {
167 asyncResp->res.jsonValue["Status"]["Health"] =
168 resource::Health::Critical;
169 }
170 });
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600171}
172
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400173inline void doAdapterGet(
174 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
175 const std::string& systemName, const std::string& adapterId,
176 const std::string& fabricAdapterPath, const std::string& serviceName)
Sunny Srivastava31791052021-03-12 10:39:16 -0600177{
Ed Tanousac106bf2023-06-07 09:24:59 -0700178 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600179 boost::beast::http::field::link,
180 "</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
Ed Tanousac106bf2023-06-07 09:24:59 -0700181 asyncResp->res.jsonValue["@odata.type"] =
182 "#FabricAdapter.v1_4_0.FabricAdapter";
183 asyncResp->res.jsonValue["Name"] = "Fabric Adapter";
184 asyncResp->res.jsonValue["Id"] = adapterId;
185 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
Ed Tanousef4c65b2023-04-24 15:28:50 -0700186 "/redfish/v1/Systems/{}/FabricAdapters/{}", systemName, adapterId);
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -0600187
Ed Tanous539d8c62024-06-19 14:38:27 -0700188 asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
189 asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600190
Ed Tanousac106bf2023-06-07 09:24:59 -0700191 getFabricAdapterLocation(asyncResp, serviceName, fabricAdapterPath);
192 getFabricAdapterAsset(asyncResp, serviceName, fabricAdapterPath);
193 getFabricAdapterState(asyncResp, serviceName, fabricAdapterPath);
194 getFabricAdapterHealth(asyncResp, serviceName, fabricAdapterPath);
Sunny Srivastava31791052021-03-12 10:39:16 -0600195}
196
Myung Bae78c90202024-02-19 13:39:56 -0500197inline void afterGetValidFabricAdapterPath(
198 const std::string& adapterId,
199 std::function<void(const boost::system::error_code&,
200 const std::string& fabricAdapterPath,
201 const std::string& serviceName)>& callback,
202 const boost::system::error_code& ec,
203 const dbus::utility::MapperGetSubTreeResponse& subtree)
Sunny Srivastava31791052021-03-12 10:39:16 -0600204{
Myung Bae78c90202024-02-19 13:39:56 -0500205 std::string fabricAdapterPath;
206 std::string serviceName;
207 if (ec)
208 {
209 callback(ec, fabricAdapterPath, serviceName);
210 return;
211 }
Sunny Srivastava31791052021-03-12 10:39:16 -0600212
Myung Bae78c90202024-02-19 13:39:56 -0500213 for (const auto& [adapterPath, serviceMap] : subtree)
214 {
215 std::string fabricAdapterName =
216 sdbusplus::message::object_path(adapterPath).filename();
217 if (fabricAdapterName == adapterId)
218 {
219 fabricAdapterPath = adapterPath;
220 serviceName = serviceMap.begin()->first;
221 break;
222 }
223 }
224 callback(ec, fabricAdapterPath, serviceName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600225}
226
227inline void getValidFabricAdapterPath(
Myung Bae78c90202024-02-19 13:39:56 -0500228 const std::string& adapterId,
229 std::function<void(const boost::system::error_code& ec,
230 const std::string& fabricAdapterPath,
Sunny Srivastava31791052021-03-12 10:39:16 -0600231 const std::string& serviceName)>&& callback)
232{
Sunny Srivastava31791052021-03-12 10:39:16 -0600233 constexpr std::array<std::string_view, 1> interfaces{
234 "xyz.openbmc_project.Inventory.Item.FabricAdapter"};
Myung Bae78c90202024-02-19 13:39:56 -0500235 dbus::utility::getSubTree("/xyz/openbmc_project/inventory", 0, interfaces,
236 std::bind_front(afterGetValidFabricAdapterPath,
237 adapterId, std::move(callback)));
238}
Sunny Srivastava31791052021-03-12 10:39:16 -0600239
Myung Bae78c90202024-02-19 13:39:56 -0500240inline void afterHandleFabricAdapterGet(
241 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
242 const std::string& systemName, const std::string& adapterId,
243 const boost::system::error_code& ec, const std::string& fabricAdapterPath,
244 const std::string& serviceName)
245{
246 if (ec)
247 {
248 if (ec.value() == boost::system::errc::io_error)
Sunny Srivastava31791052021-03-12 10:39:16 -0600249 {
Myung Bae78c90202024-02-19 13:39:56 -0500250 messages::resourceNotFound(asyncResp->res, "FabricAdapter",
251 adapterId);
Sunny Srivastava31791052021-03-12 10:39:16 -0600252 return;
253 }
Myung Bae78c90202024-02-19 13:39:56 -0500254
255 BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value());
256 messages::internalError(asyncResp->res);
257 return;
258 }
259 if (fabricAdapterPath.empty() || serviceName.empty())
260 {
Ed Tanous62598e32023-07-17 17:06:25 -0700261 BMCWEB_LOG_WARNING("Adapter not found");
Ed Tanousac106bf2023-06-07 09:24:59 -0700262 messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
Myung Bae78c90202024-02-19 13:39:56 -0500263 return;
264 }
265 doAdapterGet(asyncResp, systemName, adapterId, fabricAdapterPath,
266 serviceName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600267}
268
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400269inline void handleFabricAdapterGet(
270 App& app, const crow::Request& req,
271 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
272 const std::string& systemName, const std::string& adapterId)
Sunny Srivastava31791052021-03-12 10:39:16 -0600273{
Ed Tanousac106bf2023-06-07 09:24:59 -0700274 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600275 {
276 return;
277 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700278 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800279 {
280 // Option currently returns no systems. TBD
281 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
282 systemName);
283 return;
284 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700285 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Myung Bae78c90202024-02-19 13:39:56 -0500286 {
287 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
288 systemName);
289 return;
290 }
Sunny Srivastava31791052021-03-12 10:39:16 -0600291 getValidFabricAdapterPath(
Myung Bae78c90202024-02-19 13:39:56 -0500292 adapterId, std::bind_front(afterHandleFabricAdapterGet, asyncResp,
293 systemName, adapterId));
Sunny Srivastava31791052021-03-12 10:39:16 -0600294}
295
296inline void handleFabricAdapterCollectionGet(
297 crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700298 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600299 const std::string& systemName)
300{
Ed Tanousac106bf2023-06-07 09:24:59 -0700301 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600302 {
303 return;
304 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700305 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800306 {
307 // Option currently returns no systems. TBD
308 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
309 systemName);
310 return;
311 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700312 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Sunny Srivastava31791052021-03-12 10:39:16 -0600313 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700314 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
315 systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600316 return;
317 }
318
Ed Tanousac106bf2023-06-07 09:24:59 -0700319 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600320 boost::beast::http::field::link,
321 "</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
Ed Tanousac106bf2023-06-07 09:24:59 -0700322 asyncResp->res.jsonValue["@odata.type"] =
Sunny Srivastava31791052021-03-12 10:39:16 -0600323 "#FabricAdapterCollection.FabricAdapterCollection";
Ed Tanousac106bf2023-06-07 09:24:59 -0700324 asyncResp->res.jsonValue["Name"] = "Fabric Adapter Collection";
325 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
Ed Tanousef4c65b2023-04-24 15:28:50 -0700326 "/redfish/v1/Systems/{}/FabricAdapters", systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600327
328 constexpr std::array<std::string_view, 1> interfaces{
329 "xyz.openbmc_project.Inventory.Item.FabricAdapter"};
330 collection_util::getCollectionMembers(
Ed Tanousac106bf2023-06-07 09:24:59 -0700331 asyncResp,
Ed Tanous253f11b2024-05-16 09:38:31 -0700332 boost::urls::format("/redfish/v1/Systems/{}/FabricAdapters",
333 BMCWEB_REDFISH_SYSTEM_URI_NAME),
Lakshmi Yadlapati36b5f1e2023-09-26 23:53:28 -0500334 interfaces, "/xyz/openbmc_project/inventory");
Sunny Srivastava31791052021-03-12 10:39:16 -0600335}
336
337inline void handleFabricAdapterCollectionHead(
338 crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700339 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600340 const std::string& systemName)
341{
Ed Tanousac106bf2023-06-07 09:24:59 -0700342 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600343 {
344 return;
345 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700346 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800347 {
348 // Option currently returns no systems. TBD
349 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
350 systemName);
351 return;
352 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700353 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Sunny Srivastava31791052021-03-12 10:39:16 -0600354 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700355 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
356 systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600357 return;
358 }
Ed Tanousac106bf2023-06-07 09:24:59 -0700359 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600360 boost::beast::http::field::link,
361 "</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
362}
363
Myung Bae78c90202024-02-19 13:39:56 -0500364inline void afterHandleFabricAdapterHead(
365 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
366 const std::string& adapterId, const boost::system::error_code& ec,
367 const std::string& fabricAdapterPath, const std::string& serviceName)
368{
369 if (ec)
370 {
371 if (ec.value() == boost::system::errc::io_error)
372 {
373 messages::resourceNotFound(asyncResp->res, "FabricAdapter",
374 adapterId);
375 return;
376 }
377
378 BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value());
379 messages::internalError(asyncResp->res);
380 return;
381 }
382 if (fabricAdapterPath.empty() || serviceName.empty())
383 {
384 BMCWEB_LOG_WARNING("Adapter not found");
385 messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
386 return;
387 }
388 asyncResp->res.addHeader(
389 boost::beast::http::field::link,
390 "</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
391}
392
Patrick Williamsbd79bce2024-08-16 15:22:20 -0400393inline void handleFabricAdapterHead(
394 crow::App& app, const crow::Request& req,
395 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
396 const std::string& systemName, const std::string& adapterId)
Sunny Srivastava31791052021-03-12 10:39:16 -0600397{
Ed Tanousac106bf2023-06-07 09:24:59 -0700398 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600399 {
400 return;
401 }
402
Ed Tanous25b54db2024-04-17 15:40:31 -0700403 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800404 {
405 // Option currently returns no systems. TBD
406 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
407 systemName);
408 return;
409 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700410 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Myung Bae78c90202024-02-19 13:39:56 -0500411 {
412 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
413 systemName);
414 return;
415 }
416 getValidFabricAdapterPath(
417 adapterId,
418 std::bind_front(afterHandleFabricAdapterHead, asyncResp, adapterId));
Sunny Srivastava31791052021-03-12 10:39:16 -0600419}
420
421inline void requestRoutesFabricAdapterCollection(App& app)
422{
423 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/")
424 .privileges(redfish::privileges::getFabricAdapterCollection)
425 .methods(boost::beast::http::verb::get)(
426 std::bind_front(handleFabricAdapterCollectionGet, std::ref(app)));
427
428 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/")
429 .privileges(redfish::privileges::headFabricAdapterCollection)
430 .methods(boost::beast::http::verb::head)(
431 std::bind_front(handleFabricAdapterCollectionHead, std::ref(app)));
432}
433
434inline void requestRoutesFabricAdapters(App& app)
435{
436 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/<str>/")
437 .privileges(redfish::privileges::getFabricAdapter)
438 .methods(boost::beast::http::verb::get)(
439 std::bind_front(handleFabricAdapterGet, std::ref(app)));
440
441 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/<str>/")
442 .privileges(redfish::privileges::headFabricAdapter)
443 .methods(boost::beast::http::verb::head)(
444 std::bind_front(handleFabricAdapterHead, std::ref(app)));
445}
446} // namespace redfish