summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Liu <liuxiwei@inspur.com>2022-10-04 11:13:44 +0300
committerGunnar Mills <gmills@us.ibm.com>2023-07-13 06:02:47 +0300
commit4a2e485d4d846ef7b6e03749795e9dc827b50ba1 (patch)
treef6517770145c81e92393ead1b650140dea2c3a5e
parent090ae7ba35fef7157327f3a4686fec3e8a4df66f (diff)
downloadbmcweb-4a2e485d4d846ef7b6e03749795e9dc827b50ba1.tar.xz
Add Location information for Fan
This commit is to add Location/PartLocation/ServiceLabel information according to the Redfish Fan schema. If the `xyz.openbmc_project.Inventory.Decorator.LocationCode` interface does not exist, the ServiceLabel information property is not displayed. ref: https://redfish.dmtf.org/schemas/v1/Fan.v1_3_0.json Tested: Validator passes ''' 1. doGet method to get Fan ServiceLabel information curl -k https://${bmc}/redfish/v1/Chassis/chassis/ThermalSubsystem/Fans/fan0 { "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/Fans/fan0", "@odata.type": "#Fan.v1_3_0.Fan", "Id": "fan0", "Manufacturer": "Delta", "Model": "7B5F", "Name": "Fan", "PartNumber": "02YK323", "SerialNumber": "YL12JP1C1234", "Slot": { "Location": { "PartLocation": { "ServiceLabel": "U78DB.ND0.WZS002U-A0" } } }, "SparePartNumber": "02YK323", "Status": { "Health": "OK", "State": "Enabled" } } ''' Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I1c3357d6dde654c71c8384139b8e3f03cf671e4e Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
-rw-r--r--Redfish.md1
-rw-r--r--redfish-core/lib/fan.hpp25
2 files changed, 26 insertions, 0 deletions
diff --git a/Redfish.md b/Redfish.md
index d72a2f8933..cd03a7ca86 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -324,6 +324,7 @@ Fields common to all schemas
#### Fan
+- Location
- Manufacturer
- Model
- PartNumber
diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp
index 0acb762a04..76805315d3 100644
--- a/redfish-core/lib/fan.hpp
+++ b/redfish-core/lib/fan.hpp
@@ -335,6 +335,30 @@ inline void getFanAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
});
}
+inline void getFanLocation(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::string& fanPath,
+ const std::string& service)
+{
+ sdbusplus::asio::getProperty<std::string>(
+ *crow::connections::systemBus, service, fanPath,
+ "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
+ [aResp](const boost::system::error_code& ec,
+ const std::string& property) {
+ if (ec)
+ {
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR << "DBUS response error for Location"
+ << ec.value();
+ messages::internalError(aResp->res);
+ }
+ return;
+ }
+ aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
+ });
+}
+
inline void
afterGetValidFanPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& chassisId, const std::string& fanId,
@@ -344,6 +368,7 @@ inline void
getFanState(asyncResp, fanPath, service);
getFanHealth(asyncResp, fanPath, service);
getFanAsset(asyncResp, fanPath, service);
+ getFanLocation(asyncResp, fanPath, service);
}
inline void doFanGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,