summaryrefslogtreecommitdiff
path: root/redfish-core/lib/chassis.hpp
diff options
context:
space:
mode:
authorSunnySrivastava1984 <sunnsr25@in.ibm.com>2020-12-03 19:27:52 +0300
committersunnsr25 <sunnsr25@in.ibm.com>2021-03-08 18:48:04 +0300
commit88ad7f03b3ea7133cb253d528d03923f084f62bd (patch)
tree035af3cd9bef8d0e4eb63dd88e49e96affd8f911 /redfish-core/lib/chassis.hpp
parent29a82b08abd4bb1435cf5b18b3d7638b6be0cc63 (diff)
downloadbmcweb-88ad7f03b3ea7133cb253d528d03923f084f62bd.tar.xz
Chassis Location property on bmcweb
This commit implements change to publish LocationCode property for Chassis on bmcweb. Location code of Motherboard FRU is published via chassis schema. LocationCode, a free form, implementation-defined string to provide the location. This is needed so an implementation can identify the FRU via system diagrams. Validator has been executed and no new error has been found. Sample output: { "@odata.id": "/redfish/v1/Chassis/chassis", "@odata.type": "#Chassis.v1_14_0.Chassis", "Actions": { "#Chassis.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Chassis/chassis/ResetActionInfo", "target": "/redfish/v1/Chassis/chassis/Actions/Chassis.Reset" } }, "ChassisType": "RackMount", "Id": "chassis", "Links": { "ComputerSystems": [ { "@odata.id": "/redfish/v1/Systems/system" } ], "ManagedBy": [ { "@odata.id": "/redfish/v1/Managers/bmc" } ] }, "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND1.1234567" } }, "Manufacturer": "", "Model": "", "Name": "chassis", "PCIeDevices": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices" }, "PartNumber": "PN12345", "Power": { "@odata.id": "/redfish/v1/Chassis/chassis/Power" }, "PowerState": "Off", "Sensors": { "@odata.id": "/redfish/v1/Chassis/chassis/Sensors" }, "SerialNumber": "BBBE2D010000", "Status": { "Health": "OK", "HealthRollup": "OK", "State": "StandbyOffline" }, "Thermal": { "@odata.id": "/redfish/v1/Chassis/chassis/Thermal" } } Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com> Change-Id: Ib248b79156e8b04664e89e37bae49d4574e97086
Diffstat (limited to 'redfish-core/lib/chassis.hpp')
-rw-r--r--redfish-core/lib/chassis.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 2ebdaefff2..01d6081899 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -323,6 +323,41 @@ class Chassis : public Node
}
}
+ const std::string locationInterface =
+ "xyz.openbmc_project.Inventory.Decorator.LocationCode";
+ if (std::find(interfaces2.begin(), interfaces2.end(),
+ locationInterface) != interfaces2.end())
+ {
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, chassisId(std::string(chassisId))](
+ const boost::system::error_code ec,
+ const std::variant<std::string>& property) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG
+ << "DBUS response error for Location";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ const std::string* value =
+ std::get_if<std::string>(&property);
+ if (value == nullptr)
+ {
+ BMCWEB_LOG_DEBUG << "Null value returned "
+ "for locaton code";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]
+ ["ServiceLabel"] = *value;
+ },
+ connectionName, path,
+ "org.freedesktop.DBus.Properties", "Get",
+ locationInterface, "LocationCode");
+ }
+
crow::connections::systemBus->async_method_call(
[asyncResp, chassisId(std::string(chassisId))](
const boost::system::error_code /*ec2*/,