Skip to content

Commit a3ef5ee

Browse files
PriyangaRamasamySunnySrivastava1984
authored andcommitted
Publish Location under PCIeDevice schema (#1083)
The commit publishes Location code under PCIeDevice schema. Validator was executed and no new error was found. Test: curl -k -H "X-Auth-Token: $bmc_token" -X GET "https://${BMC_IP}/redfish/ v1/Systems/system/PCIeDevices/chassis_motherboard_pcieslot0_pcie_card0" { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/ chassis_motherboard_pcieslot0_pcie_card0", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", "Id": "chassis_motherboard_pcieslot0_pcie_card0", "Oem": { "IBM": { "@odata.type": "#IBMPCIeDevice.v1_0_0.IBM", "LinkReset": false } }, "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/ chassis_motherboard_pcieslot0_pcie_card0/PCIeFunctions" }, "PCIeInterface": { "LanesInUse": null }, "Slot": { "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS003T-P0-C0" } }, "SlotType": "FullLength" }, "Status": { "Health": "OK", "State": "Enabled" } } Change-Id: Iba1b98734fdfee43c2995f6c9f1f2660e196814a Signed-off-by: Sunny Srivastava <[email protected]> Co-authored-by: Sunny Srivastava <[email protected]> Signed-off-by: Souvik Roy <[email protected]>
1 parent 9bfb291 commit a3ef5ee

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

redfish-core/lib/pcie.hpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,46 @@ inline void getPCIeDeviceAsset(
523523
});
524524
}
525525

526+
inline void getPCIeDeviceLocation(
527+
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
528+
const std::string& pcieDevicePath, const std::string& service)
529+
{
530+
sdbusplus::asio::getAllProperties(
531+
*crow::connections::systemBus, service, pcieDevicePath,
532+
"xyz.openbmc_project.Inventory.Decorator.LocationCode",
533+
[pcieDevicePath,
534+
asyncResp](const boost::system::error_code& ec,
535+
const dbus::utility::DBusPropertiesMap& locationCodeList) {
536+
if (ec)
537+
{
538+
if (ec.value() != EBADR)
539+
{
540+
BMCWEB_LOG_ERROR("DBUS response error for Properties{}",
541+
ec.value());
542+
messages::internalError(asyncResp->res);
543+
}
544+
return;
545+
}
546+
547+
const std::string* locationCode = nullptr;
548+
const bool success = sdbusplus::unpackPropertiesNoThrow(
549+
dbus_utils::UnpackErrorPrinter(), locationCodeList,
550+
"LocationCode", locationCode);
551+
552+
if (!success)
553+
{
554+
messages::internalError(asyncResp->res);
555+
return;
556+
}
557+
558+
if (locationCode != nullptr)
559+
{
560+
asyncResp->res.jsonValue["Slot"]["Location"]["PartLocation"]
561+
["ServiceLabel"] = *locationCode;
562+
}
563+
});
564+
}
565+
526566
inline void addPCIeDeviceProperties(
527567
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
528568
const std::string& pcieDeviceId,
@@ -676,6 +716,7 @@ inline void afterGetValidPcieDevicePath(
676716
getPCIeDeviceSlotPath(
677717
pcieDevicePath, asyncResp,
678718
std::bind_front(afterGetPCIeDeviceSlotPath, asyncResp));
719+
getPCIeDeviceLocation(asyncResp, pcieDevicePath, service);
679720
}
680721

681722
inline void handlePCIeDeviceGet(

0 commit comments

Comments
 (0)