blob: c7bdbb75f90b88a474370f90d6d7ed050c1f8bd0 [file] [log] [blame]
Sunny Srivastava31791052021-03-12 10:39:16 -06001#pragma once
2
3#include "app.hpp"
4#include "dbus_utility.hpp"
Ed Tanous539d8c62024-06-19 14:38:27 -07005#include "generated/enums/resource.hpp"
Ed Tanousa8e884f2023-01-13 17:40:03 -08006#include "query.hpp"
7#include "registries/privilege_registry.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -06008#include "utils/collection.hpp"
Lakshmi Yadlapati6177a302023-02-17 10:29:34 -06009#include "utils/dbus_utils.hpp"
Sunny Srivastava31791052021-03-12 10:39:16 -060010#include "utils/json_utils.hpp"
11
12#include <boost/system/error_code.hpp>
Ed Tanousef4c65b2023-04-24 15:28:50 -070013#include <boost/url/format.hpp>
Gunnar Millsf05e9162023-02-16 20:23:30 -060014#include <sdbusplus/asio/property.hpp>
Lakshmi Yadlapati6177a302023-02-17 10:29:34 -060015#include <sdbusplus/unpack_properties.hpp>
Sunny Srivastava31791052021-03-12 10:39:16 -060016
17#include <array>
18#include <functional>
19#include <memory>
Myung Bae78c90202024-02-19 13:39:56 -050020#include <optional>
Sunny Srivastava31791052021-03-12 10:39:16 -060021#include <string>
22#include <string_view>
23
24namespace redfish
25{
26
Ed Tanousac106bf2023-06-07 09:24:59 -070027inline void getFabricAdapterLocation(
28 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
29 const std::string& serviceName, const std::string& fabricAdapterPath)
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060030{
31 sdbusplus::asio::getProperty<std::string>(
32 *crow::connections::systemBus, serviceName, fabricAdapterPath,
33 "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
Ed Tanousac106bf2023-06-07 09:24:59 -070034 [asyncResp](const boost::system::error_code& ec,
35 const std::string& property) {
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060036 if (ec)
37 {
38 if (ec.value() != EBADR)
39 {
Ed Tanous62598e32023-07-17 17:06:25 -070040 BMCWEB_LOG_ERROR("DBUS response error for Location");
Ed Tanousac106bf2023-06-07 09:24:59 -070041 messages::internalError(asyncResp->res);
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060042 }
43 return;
44 }
45
Ed Tanousac106bf2023-06-07 09:24:59 -070046 asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060047 property;
Patrick Williams5a39f772023-10-20 11:20:21 -050048 });
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -060049}
50
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060051inline void
Ed Tanousac106bf2023-06-07 09:24:59 -070052 getFabricAdapterAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060053 const std::string& serviceName,
54 const std::string& fabricAdapterPath)
55{
56 sdbusplus::asio::getAllProperties(
57 *crow::connections::systemBus, serviceName, fabricAdapterPath,
58 "xyz.openbmc_project.Inventory.Decorator.Asset",
Ed Tanousac106bf2023-06-07 09:24:59 -070059 [fabricAdapterPath, asyncResp{asyncResp}](
60 const boost::system::error_code& ec,
61 const dbus::utility::DBusPropertiesMap& propertiesList) {
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060062 if (ec)
63 {
64 if (ec.value() != EBADR)
65 {
Ed Tanous62598e32023-07-17 17:06:25 -070066 BMCWEB_LOG_ERROR("DBUS response error for Properties");
Ed Tanousac106bf2023-06-07 09:24:59 -070067 messages::internalError(asyncResp->res);
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060068 }
69 return;
70 }
71
72 const std::string* serialNumber = nullptr;
73 const std::string* model = nullptr;
74 const std::string* partNumber = nullptr;
75 const std::string* sparePartNumber = nullptr;
76
77 const bool success = sdbusplus::unpackPropertiesNoThrow(
78 dbus_utils::UnpackErrorPrinter(), propertiesList, "SerialNumber",
79 serialNumber, "Model", model, "PartNumber", partNumber,
80 "SparePartNumber", sparePartNumber);
81
82 if (!success)
83 {
Ed Tanousac106bf2023-06-07 09:24:59 -070084 messages::internalError(asyncResp->res);
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060085 return;
86 }
87
88 if (serialNumber != nullptr)
89 {
Ed Tanousac106bf2023-06-07 09:24:59 -070090 asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060091 }
92
93 if (model != nullptr)
94 {
Ed Tanousac106bf2023-06-07 09:24:59 -070095 asyncResp->res.jsonValue["Model"] = *model;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -060096 }
97
98 if (partNumber != nullptr)
99 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700100 asyncResp->res.jsonValue["PartNumber"] = *partNumber;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600101 }
102
103 if (sparePartNumber != nullptr && !sparePartNumber->empty())
104 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700105 asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600106 }
Patrick Williams5a39f772023-10-20 11:20:21 -0500107 });
Lakshmi Yadlapati63694212023-01-27 16:35:22 -0600108}
109
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600110inline void
Ed Tanousac106bf2023-06-07 09:24:59 -0700111 getFabricAdapterState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600112 const std::string& serviceName,
113 const std::string& fabricAdapterPath)
114{
115 sdbusplus::asio::getProperty<bool>(
116 *crow::connections::systemBus, serviceName, fabricAdapterPath,
117 "xyz.openbmc_project.Inventory.Item", "Present",
Ed Tanousac106bf2023-06-07 09:24:59 -0700118 [asyncResp](const boost::system::error_code& ec, const bool present) {
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600119 if (ec)
120 {
121 if (ec.value() != EBADR)
122 {
Ed Tanous62598e32023-07-17 17:06:25 -0700123 BMCWEB_LOG_ERROR("DBUS response error for State");
Ed Tanousac106bf2023-06-07 09:24:59 -0700124 messages::internalError(asyncResp->res);
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600125 }
126 return;
127 }
128
129 if (!present)
130 {
Ed Tanous539d8c62024-06-19 14:38:27 -0700131 asyncResp->res.jsonValue["Status"]["State"] =
132 resource::State::Absent;
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600133 }
Patrick Williams5a39f772023-10-20 11:20:21 -0500134 });
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600135}
136
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600137inline void
Ed Tanousac106bf2023-06-07 09:24:59 -0700138 getFabricAdapterHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600139 const std::string& serviceName,
140 const std::string& fabricAdapterPath)
141{
142 sdbusplus::asio::getProperty<bool>(
143 *crow::connections::systemBus, serviceName, fabricAdapterPath,
144 "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) {
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600147 if (ec)
148 {
149 if (ec.value() != EBADR)
150 {
Ed Tanous62598e32023-07-17 17:06:25 -0700151 BMCWEB_LOG_ERROR("DBUS response error for Health");
Ed Tanousac106bf2023-06-07 09:24:59 -0700152 messages::internalError(asyncResp->res);
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600153 }
154 return;
155 }
156
157 if (!functional)
158 {
Ed Tanous539d8c62024-06-19 14:38:27 -0700159 asyncResp->res.jsonValue["Status"]["Health"] =
160 resource::Health::Critical;
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600161 }
Patrick Williams5a39f772023-10-20 11:20:21 -0500162 });
Lakshmi Yadlapati7da847b2023-01-27 17:53:18 -0600163}
164
Ed Tanousac106bf2023-06-07 09:24:59 -0700165inline void doAdapterGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600166 const std::string& systemName,
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -0600167 const std::string& adapterId,
168 const std::string& fabricAdapterPath,
169 const std::string& serviceName)
Sunny Srivastava31791052021-03-12 10:39:16 -0600170{
Ed Tanousac106bf2023-06-07 09:24:59 -0700171 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600172 boost::beast::http::field::link,
173 "</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
Ed Tanousac106bf2023-06-07 09:24:59 -0700174 asyncResp->res.jsonValue["@odata.type"] =
175 "#FabricAdapter.v1_4_0.FabricAdapter";
176 asyncResp->res.jsonValue["Name"] = "Fabric Adapter";
177 asyncResp->res.jsonValue["Id"] = adapterId;
178 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
Ed Tanousef4c65b2023-04-24 15:28:50 -0700179 "/redfish/v1/Systems/{}/FabricAdapters/{}", systemName, adapterId);
Lakshmi Yadlapati53ffeca2023-01-27 15:12:23 -0600180
Ed Tanous539d8c62024-06-19 14:38:27 -0700181 asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
182 asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
Lakshmi Yadlapaticd7af442023-01-27 17:31:40 -0600183
Ed Tanousac106bf2023-06-07 09:24:59 -0700184 getFabricAdapterLocation(asyncResp, serviceName, fabricAdapterPath);
185 getFabricAdapterAsset(asyncResp, serviceName, fabricAdapterPath);
186 getFabricAdapterState(asyncResp, serviceName, fabricAdapterPath);
187 getFabricAdapterHealth(asyncResp, serviceName, fabricAdapterPath);
Sunny Srivastava31791052021-03-12 10:39:16 -0600188}
189
Myung Bae78c90202024-02-19 13:39:56 -0500190inline void afterGetValidFabricAdapterPath(
191 const std::string& adapterId,
192 std::function<void(const boost::system::error_code&,
193 const std::string& fabricAdapterPath,
194 const std::string& serviceName)>& callback,
195 const boost::system::error_code& ec,
196 const dbus::utility::MapperGetSubTreeResponse& subtree)
Sunny Srivastava31791052021-03-12 10:39:16 -0600197{
Myung Bae78c90202024-02-19 13:39:56 -0500198 std::string fabricAdapterPath;
199 std::string serviceName;
200 if (ec)
201 {
202 callback(ec, fabricAdapterPath, serviceName);
203 return;
204 }
Sunny Srivastava31791052021-03-12 10:39:16 -0600205
Myung Bae78c90202024-02-19 13:39:56 -0500206 for (const auto& [adapterPath, serviceMap] : subtree)
207 {
208 std::string fabricAdapterName =
209 sdbusplus::message::object_path(adapterPath).filename();
210 if (fabricAdapterName == adapterId)
211 {
212 fabricAdapterPath = adapterPath;
213 serviceName = serviceMap.begin()->first;
214 break;
215 }
216 }
217 callback(ec, fabricAdapterPath, serviceName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600218}
219
220inline void getValidFabricAdapterPath(
Myung Bae78c90202024-02-19 13:39:56 -0500221 const std::string& adapterId,
222 std::function<void(const boost::system::error_code& ec,
223 const std::string& fabricAdapterPath,
Sunny Srivastava31791052021-03-12 10:39:16 -0600224 const std::string& serviceName)>&& callback)
225{
Sunny Srivastava31791052021-03-12 10:39:16 -0600226 constexpr std::array<std::string_view, 1> interfaces{
227 "xyz.openbmc_project.Inventory.Item.FabricAdapter"};
Myung Bae78c90202024-02-19 13:39:56 -0500228 dbus::utility::getSubTree("/xyz/openbmc_project/inventory", 0, interfaces,
229 std::bind_front(afterGetValidFabricAdapterPath,
230 adapterId, std::move(callback)));
231}
Sunny Srivastava31791052021-03-12 10:39:16 -0600232
Myung Bae78c90202024-02-19 13:39:56 -0500233inline void afterHandleFabricAdapterGet(
234 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
235 const std::string& systemName, const std::string& adapterId,
236 const boost::system::error_code& ec, const std::string& fabricAdapterPath,
237 const std::string& serviceName)
238{
239 if (ec)
240 {
241 if (ec.value() == boost::system::errc::io_error)
Sunny Srivastava31791052021-03-12 10:39:16 -0600242 {
Myung Bae78c90202024-02-19 13:39:56 -0500243 messages::resourceNotFound(asyncResp->res, "FabricAdapter",
244 adapterId);
Sunny Srivastava31791052021-03-12 10:39:16 -0600245 return;
246 }
Myung Bae78c90202024-02-19 13:39:56 -0500247
248 BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value());
249 messages::internalError(asyncResp->res);
250 return;
251 }
252 if (fabricAdapterPath.empty() || serviceName.empty())
253 {
Ed Tanous62598e32023-07-17 17:06:25 -0700254 BMCWEB_LOG_WARNING("Adapter not found");
Ed Tanousac106bf2023-06-07 09:24:59 -0700255 messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
Myung Bae78c90202024-02-19 13:39:56 -0500256 return;
257 }
258 doAdapterGet(asyncResp, systemName, adapterId, fabricAdapterPath,
259 serviceName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600260}
261
262inline void
263 handleFabricAdapterGet(App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700264 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600265 const std::string& systemName,
266 const std::string& adapterId)
267{
Ed Tanousac106bf2023-06-07 09:24:59 -0700268 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600269 {
270 return;
271 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700272 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800273 {
274 // Option currently returns no systems. TBD
275 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
276 systemName);
277 return;
278 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700279 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Myung Bae78c90202024-02-19 13:39:56 -0500280 {
281 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
282 systemName);
283 return;
284 }
Sunny Srivastava31791052021-03-12 10:39:16 -0600285 getValidFabricAdapterPath(
Myung Bae78c90202024-02-19 13:39:56 -0500286 adapterId, std::bind_front(afterHandleFabricAdapterGet, asyncResp,
287 systemName, adapterId));
Sunny Srivastava31791052021-03-12 10:39:16 -0600288}
289
290inline void handleFabricAdapterCollectionGet(
291 crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700292 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600293 const std::string& systemName)
294{
Ed Tanousac106bf2023-06-07 09:24:59 -0700295 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600296 {
297 return;
298 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700299 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800300 {
301 // Option currently returns no systems. TBD
302 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
303 systemName);
304 return;
305 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700306 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Sunny Srivastava31791052021-03-12 10:39:16 -0600307 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700308 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
309 systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600310 return;
311 }
312
Ed Tanousac106bf2023-06-07 09:24:59 -0700313 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600314 boost::beast::http::field::link,
315 "</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
Ed Tanousac106bf2023-06-07 09:24:59 -0700316 asyncResp->res.jsonValue["@odata.type"] =
Sunny Srivastava31791052021-03-12 10:39:16 -0600317 "#FabricAdapterCollection.FabricAdapterCollection";
Ed Tanousac106bf2023-06-07 09:24:59 -0700318 asyncResp->res.jsonValue["Name"] = "Fabric Adapter Collection";
319 asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
Ed Tanousef4c65b2023-04-24 15:28:50 -0700320 "/redfish/v1/Systems/{}/FabricAdapters", systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600321
322 constexpr std::array<std::string_view, 1> interfaces{
323 "xyz.openbmc_project.Inventory.Item.FabricAdapter"};
324 collection_util::getCollectionMembers(
Ed Tanousac106bf2023-06-07 09:24:59 -0700325 asyncResp,
Ed Tanous253f11b2024-05-16 09:38:31 -0700326 boost::urls::format("/redfish/v1/Systems/{}/FabricAdapters",
327 BMCWEB_REDFISH_SYSTEM_URI_NAME),
Lakshmi Yadlapati36b5f1e2023-09-26 23:53:28 -0500328 interfaces, "/xyz/openbmc_project/inventory");
Sunny Srivastava31791052021-03-12 10:39:16 -0600329}
330
331inline void handleFabricAdapterCollectionHead(
332 crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700333 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600334 const std::string& systemName)
335{
Ed Tanousac106bf2023-06-07 09:24:59 -0700336 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600337 {
338 return;
339 }
Ed Tanous25b54db2024-04-17 15:40:31 -0700340 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800341 {
342 // Option currently returns no systems. TBD
343 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
344 systemName);
345 return;
346 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700347 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Sunny Srivastava31791052021-03-12 10:39:16 -0600348 {
Ed Tanousac106bf2023-06-07 09:24:59 -0700349 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
350 systemName);
Sunny Srivastava31791052021-03-12 10:39:16 -0600351 return;
352 }
Ed Tanousac106bf2023-06-07 09:24:59 -0700353 asyncResp->res.addHeader(
Sunny Srivastava31791052021-03-12 10:39:16 -0600354 boost::beast::http::field::link,
355 "</redfish/v1/JsonSchemas/FabricAdapterCollection/FabricAdapterCollection.json>; rel=describedby");
356}
357
Myung Bae78c90202024-02-19 13:39:56 -0500358inline void afterHandleFabricAdapterHead(
359 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
360 const std::string& adapterId, const boost::system::error_code& ec,
361 const std::string& fabricAdapterPath, const std::string& serviceName)
362{
363 if (ec)
364 {
365 if (ec.value() == boost::system::errc::io_error)
366 {
367 messages::resourceNotFound(asyncResp->res, "FabricAdapter",
368 adapterId);
369 return;
370 }
371
372 BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value());
373 messages::internalError(asyncResp->res);
374 return;
375 }
376 if (fabricAdapterPath.empty() || serviceName.empty())
377 {
378 BMCWEB_LOG_WARNING("Adapter not found");
379 messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId);
380 return;
381 }
382 asyncResp->res.addHeader(
383 boost::beast::http::field::link,
384 "</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
385}
386
Sunny Srivastava31791052021-03-12 10:39:16 -0600387inline void
388 handleFabricAdapterHead(crow::App& app, const crow::Request& req,
Ed Tanousac106bf2023-06-07 09:24:59 -0700389 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
Sunny Srivastava31791052021-03-12 10:39:16 -0600390 const std::string& systemName,
391 const std::string& adapterId)
392{
Ed Tanousac106bf2023-06-07 09:24:59 -0700393 if (!redfish::setUpRedfishRoute(app, req, asyncResp))
Sunny Srivastava31791052021-03-12 10:39:16 -0600394 {
395 return;
396 }
397
Ed Tanous25b54db2024-04-17 15:40:31 -0700398 if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
Ed Tanous7f3e84a2022-12-28 16:22:54 -0800399 {
400 // Option currently returns no systems. TBD
401 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
402 systemName);
403 return;
404 }
Ed Tanous253f11b2024-05-16 09:38:31 -0700405 if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
Myung Bae78c90202024-02-19 13:39:56 -0500406 {
407 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
408 systemName);
409 return;
410 }
411 getValidFabricAdapterPath(
412 adapterId,
413 std::bind_front(afterHandleFabricAdapterHead, asyncResp, adapterId));
Sunny Srivastava31791052021-03-12 10:39:16 -0600414}
415
416inline void requestRoutesFabricAdapterCollection(App& app)
417{
418 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/")
419 .privileges(redfish::privileges::getFabricAdapterCollection)
420 .methods(boost::beast::http::verb::get)(
421 std::bind_front(handleFabricAdapterCollectionGet, std::ref(app)));
422
423 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/")
424 .privileges(redfish::privileges::headFabricAdapterCollection)
425 .methods(boost::beast::http::verb::head)(
426 std::bind_front(handleFabricAdapterCollectionHead, std::ref(app)));
427}
428
429inline void requestRoutesFabricAdapters(App& app)
430{
431 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/<str>/")
432 .privileges(redfish::privileges::getFabricAdapter)
433 .methods(boost::beast::http::verb::get)(
434 std::bind_front(handleFabricAdapterGet, std::ref(app)));
435
436 BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/FabricAdapters/<str>/")
437 .privileges(redfish::privileges::headFabricAdapter)
438 .methods(boost::beast::http::verb::head)(
439 std::bind_front(handleFabricAdapterHead, std::ref(app)));
440}
441} // namespace redfish