Skip to content

Commit 8d49bdb

Browse files
PriyangaRamasamySunnySrivastava1984
authored andcommitted
Add pretty name for fabric adapters (#869)
The commit implement changes to make use of util function to populate name for fabric adapters. Validator was executed and no new error was found. Test output: curl -k -H "X-Auth-Token: $bmc_token" -X GET "https://${BMC_IP}/redfish/v1/Systems/system/FabricAdapters/motherboard-pcieslot8-pcie_card8" { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/motherboard-pcieslot8-pcie_card8", "@odata.type": "#FabricAdapter.v1_4_0.FabricAdapter", "Id": "motherboard-pcieslot8-pcie_card8", "Links": { "PCIeDevices": [ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/chassis_motherboard_pcieslot8_pcie_card8" } ], "[email protected]": 1 }, "Location": { "PartLocation": { "ServiceLabel": "U780C.ND0.RCH0011-P0-C8" } }, "Model": "", "Name": "PCIe4 x16 or PCIe5 x8 adapter", "PartNumber": "", "Ports": { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/motherboard-pcieslot8-pcie_card8/Ports" }, "SerialNumber": "", "Status": { "Health": "OK", "State": "Absent" } } Signed-off-by: Sunny Srivastava <[email protected]> Co-authored-by: Sunny Srivastava <[email protected]>
1 parent 3976c19 commit 8d49bdb

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

redfish-core/lib/fabric_adapters.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ inline void doAdapterGet(
351351

352352
inline void afterGetValidFabricAdapterPath(
353353
const std::string& adapterId,
354+
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
354355
std::function<void(
355356
const boost::system::error_code&, const std::string& fabricAdapterPath,
356357
const std::string& serviceName,
@@ -376,6 +377,9 @@ inline void afterGetValidFabricAdapterPath(
376377
fabricAdapterPath = adapterPath;
377378
serviceName = serviceMap.begin()->first;
378379
interfaces = serviceMap.begin()->second;
380+
381+
nlohmann::json::json_pointer ptr("/Name");
382+
name_util::getPrettyName(asyncResp, adapterPath, serviceMap, ptr);
379383
break;
380384
}
381385
}
@@ -384,6 +388,7 @@ inline void afterGetValidFabricAdapterPath(
384388

385389
inline void getValidFabricAdapterPath(
386390
const std::string& adapterId,
391+
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
387392
std::function<void(
388393
const boost::system::error_code& ec,
389394
const std::string& fabricAdapterPath, const std::string& serviceName,
@@ -393,7 +398,8 @@ inline void getValidFabricAdapterPath(
393398
"xyz.openbmc_project.Inventory.Item.FabricAdapter"};
394399
dbus::utility::getSubTree("/xyz/openbmc_project/inventory", 0, interfaces,
395400
std::bind_front(afterGetValidFabricAdapterPath,
396-
adapterId, std::move(callback)));
401+
adapterId, asyncResp,
402+
std::move(callback)));
397403
}
398404

399405
inline void afterHandleFabricAdapterGet(
@@ -448,9 +454,10 @@ inline void handleFabricAdapterGet(
448454
systemName);
449455
return;
450456
}
451-
getValidFabricAdapterPath(
452-
adapterId, std::bind_front(afterHandleFabricAdapterGet, asyncResp,
453-
systemName, adapterId));
457+
getValidFabricAdapterPath(adapterId, asyncResp,
458+
std::bind_front(afterHandleFabricAdapterGet,
459+
asyncResp, systemName,
460+
adapterId));
454461
}
455462

456463
inline void afterHandleFabricAdapterPatch(
@@ -519,9 +526,10 @@ inline void handleFabricAdapterPatch(
519526
return;
520527
}
521528

522-
getValidFabricAdapterPath(
523-
adapterId, std::bind_front(afterHandleFabricAdapterPatch, asyncResp,
524-
adapterId, locationIndicatorActive));
529+
getValidFabricAdapterPath(adapterId, asyncResp,
530+
std::bind_front(afterHandleFabricAdapterPatch,
531+
asyncResp, adapterId,
532+
locationIndicatorActive));
525533
}
526534

527535
inline void handleFabricAdapterCollectionGet(
@@ -646,7 +654,7 @@ inline void handleFabricAdapterHead(
646654
return;
647655
}
648656
getValidFabricAdapterPath(
649-
adapterId,
657+
adapterId, asyncResp,
650658
std::bind_front(afterHandleFabricAdapterHead, asyncResp, adapterId));
651659
}
652660

redfish-core/lib/fabric_ports.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "logging.hpp"
1717
#include "query.hpp"
1818
#include "registries/privilege_registry.hpp"
19+
#include <utils/name_utils.hpp>
1920
#include "utils/json_utils.hpp"
2021

2122
#include <asm-generic/errno.h>
@@ -156,7 +157,12 @@ inline void getFabricPortProperties(
156157
boost::urls::format("/redfish/v1/Systems/{}/FabricAdapters/{}/Ports/{}",
157158
systemName, adapterId, portId);
158159
asyncResp->res.jsonValue["Id"] = portId;
159-
asyncResp->res.jsonValue["Name"] = "Fabric Port";
160+
161+
//Pretty name expects a services map
162+
const dbus::utility::MapperServiceMap& serviceMap = {{serviceName, {""}}};
163+
nlohmann::json::json_pointer ptr("/Name");
164+
name_util::getPrettyName(asyncResp, portPath, serviceMap, ptr);
165+
160166
asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
161167
asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
162168

0 commit comments

Comments
 (0)