Add support for AssetTag in Chassis
This commit adds the GET support for "AssetTag" property
under "/redfish/v1/Chassis/<str>/" Redfish URI.
This property indicates the AssestTag of the Chassis for the
inventory purposes.
As Redfish Service supports for multiple Chassis instances,
so each Chassis instance will have it's own AssetTag, which
can be used to track each chassis for the inventory purposes.
Tested:
- Redfish Validator Test passed.
curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X GET https://${bmc}/redfish/v1/Chassis/WFP_Baseboard
{
"@odata.id": "/redfish/v1/Chassis/WFP_Baseboard",
"@odata.type": "#Chassis.v1_14_0.Chassis",
"Actions": {
"#Chassis.Reset": {
"@Redfish.ActionInfo": "/redfish/v1/Chassis/WFP_Baseboard/ResetActionInfo",
"target": "/redfish/v1/Chassis/WFP_Baseboard/Actions/Chassis.Reset"
}
},
"AssetTag": "abc",
"ChassisType": "RackMount",
"Id": "WFP_Baseboard",
"IndicatorLED": "Off",
"IndicatorLED@Redfish.AllowableValues": [
"Lit",
"Blinking",
"Off"
],
"Links": {
"ComputerSystems": [
{
"@odata.id": "/redfish/v1/Systems/system"
}
],
"ManagedBy": [
{
"@odata.id": "/redfish/v1/Managers/bmc"
}
]
},
"LocationIndicatorActive": false,
"Manufacturer": "Intel Corporation",
"Model": "S2600WFT",
"Name": "WFP_Baseboard",
"PCIeDevices": {
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices"
},
"PartNumber": "..........",
"Power": {
"@odata.id": "/redfish/v1/Chassis/WFP_Baseboard/Power"
},
"PowerState": "On",
"Sensors": {
"@odata.id": "/redfish/v1/Chassis/WFP_Baseboard/Sensors"
},
"SerialNumber": "............",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Thermal": {
"@odata.id": "/redfish/v1/Chassis/WFP_Baseboard/Thermal"
}
}
Signed-off-by: Tejas Patil <tejaspp@ami.com>
Change-Id: I2b0808fcc29057e352581f018ef55564597c7456
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index c41b7e1..5a83793 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -281,6 +281,43 @@
"xyz.openbmc_project.Inventory.Item.Board."
"Motherboard"};
+ const std::string assetTagInterface =
+ "xyz.openbmc_project.Inventory.Decorator."
+ "AssetTag";
+ if (std::find(interfaces2.begin(), interfaces2.end(),
+ assetTagInterface) != 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 "
+ "AssetTag";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ const std::string* assetTag =
+ std::get_if<std::string>(&property);
+ if (assetTag == nullptr)
+ {
+ BMCWEB_LOG_DEBUG
+ << "Null value returned "
+ "for Chassis AssetTag";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["AssetTag"] =
+ *assetTag;
+ },
+ connectionName, path,
+ "org.freedesktop.DBus.Properties", "Get",
+ assetTagInterface, "AssetTag");
+ }
+
for (const char* interface : hasIndicatorLed)
{
if (std::find(interfaces2.begin(),