summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLakshmi Yadlapati <lakshmiy@us.ibm.com>2023-01-28 01:35:22 +0300
committerLakshmi Yadlapati <lakshmiy@us.ibm.com>2023-02-16 20:08:57 +0300
commit6369421d5a3abea181b28a61f806465be1ba517a (patch)
tree78c2c1e2707407312751bd7dd7f2cbee2f3b0a85
parent4ce2c1b55617262e497164ebed001509d5ce8a60 (diff)
downloadbmcweb-6369421d5a3abea181b28a61f806465be1ba517a.tar.xz
Add Asset information for FabricAdapter
This commit is to add asset information according to the Redfish FabricAdapter schema. If the `xyz.openbmc_project.Inventory.Decorator.Asset` interface does not exist, the asset information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/FabricAdapter.v1_4_0.json Tested: Validator passes # ``` curl -k https://$bmc:/redfish/v1/Systems/system/FabricAdapters/disk_backplane0 { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0", "@odata.type": "#FabricAdapter.v1_4_0.FabricAdapter", "Id": "disk_backplane0", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS0042-P1" } }, "Model": "6B89", "Name": "Fabric Adapter", "PartNumber": "02WG682", "SerialNumber": "YA31UF09P002", "SparePartNumber": "02WG681" } ``` Change-Id: Id9265b8bd323aa1503c32122899eaa458bcdbb51 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
-rw-r--r--Redfish.md4
-rw-r--r--redfish-core/lib/fabric_adapters.hpp60
2 files changed, 64 insertions, 0 deletions
diff --git a/Redfish.md b/Redfish.md
index 8d29ec0efb..1f2ca29573 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -677,6 +677,10 @@ other.
#### FabricAdapter
- Location
+- Model
+- PartNumber
+- SerialNumber
+- SparePartNumber
### /redfish/v1/Systems/system/LogServices/
diff --git a/redfish-core/lib/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp
index 5cfd0b5a77..f6099e6392 100644
--- a/redfish-core/lib/fabric_adapters.hpp
+++ b/redfish-core/lib/fabric_adapters.hpp
@@ -59,6 +59,65 @@ inline void
});
}
+inline void
+ getFabricAdapterAsset(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::string& serviceName,
+ const std::string& fabricAdapterPath)
+{
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, serviceName, fabricAdapterPath,
+ "xyz.openbmc_project.Inventory.Decorator.Asset",
+ [fabricAdapterPath,
+ aResp{aResp}](const boost::system::error_code ec,
+ const dbus::utility::DBusPropertiesMap& propertiesList) {
+ if (ec)
+ {
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR << "DBUS response error for Properties";
+ messages::internalError(aResp->res);
+ }
+ return;
+ }
+
+ const std::string* serialNumber = nullptr;
+ const std::string* model = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* sparePartNumber = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList, "SerialNumber",
+ serialNumber, "Model", model, "PartNumber", partNumber,
+ "SparePartNumber", sparePartNumber);
+
+ if (!success)
+ {
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ if (serialNumber != nullptr)
+ {
+ aResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
+
+ if (model != nullptr)
+ {
+ aResp->res.jsonValue["Model"] = *model;
+ }
+
+ if (partNumber != nullptr)
+ {
+ aResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
+
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ aResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
+}
+
inline void doAdapterGet(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
const std::string& systemName,
const std::string& adapterId,
@@ -75,6 +134,7 @@ inline void doAdapterGet(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
"redfish", "v1", "Systems", systemName, "FabricAdapters", adapterId);
getFabricAdapterLocation(aResp, serviceName, fabricAdapterPath);
+ getFabricAdapterAsset(aResp, serviceName, fabricAdapterPath);
}
inline bool checkFabricAdapterId(const std::string& adapterPath,