Add Asset information for PCIeDevice
This commit publishes inventory properties like SparePartNumber,
Model, PartNumber, SerialNumber, Manufacturer for PCIe devices.
Tested: Validator passed
```
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card10",
"@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice",
"Id": "pcie_card10",
"Manufacturer": "",
"Model": "6B87",
"Name": "PCIe Device",
"PCIeFunctions": {
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card10/PCIeFunctions"
},
"PCIeInterface": {
"LanesInUse": 16,
"PCIeType": "Gen4"
},
"PartNumber": "03FL204",
"SerialNumber": "YA31UF07200Z",
"SparePartNumber": "03FL205"
```
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: I850fe5eb2b3b3b9d47f4256ce0c4408bb1dd2bd1
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index f38ab51..a715acd 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -223,6 +223,70 @@
return std::nullopt;
}
+inline void getPCIeDeviceAsset(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::string& pcieDevicePath,
+ const std::string& service)
+{
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, service, pcieDevicePath,
+ "xyz.openbmc_project.Inventory.Decorator.Asset",
+ [pcieDevicePath,
+ aResp{aResp}](const boost::system::error_code& ec,
+ const dbus::utility::DBusPropertiesMap& assetList) {
+ if (ec)
+ {
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR << "DBUS response error for Properties"
+ << ec.value();
+ messages::internalError(aResp->res);
+ }
+ return;
+ }
+
+ const std::string* manufacturer = nullptr;
+ const std::string* model = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* sparePartNumber = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), assetList, "Manufacturer",
+ manufacturer, "Model", model, "PartNumber", partNumber,
+ "SerialNumber", serialNumber, "SparePartNumber", sparePartNumber);
+
+ if (!success)
+ {
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ if (manufacturer != nullptr)
+ {
+ aResp->res.jsonValue["Manufacturer"] = *manufacturer;
+ }
+ if (model != nullptr)
+ {
+ aResp->res.jsonValue["Model"] = *model;
+ }
+
+ if (partNumber != nullptr)
+ {
+ aResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
+
+ if (serialNumber != nullptr)
+ {
+ aResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
+
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ aResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
+}
+
inline void addPCIeDeviceProperties(
crow::Response& resp, const std::string& pcieDeviceId,
const dbus::utility::DBusPropertiesMap& pcieDevProperties)
@@ -341,6 +405,7 @@
[aResp, pcieDeviceId](const std::string& pcieDevicePath,
const std::string& service) {
addPCIeDeviceCommonProperties(aResp, pcieDeviceId);
+ getPCIeDeviceAsset(aResp, pcieDevicePath, service);
getPCIeDeviceProperties(
aResp, pcieDevicePath, service,
[aResp, pcieDeviceId](