diff options
author | Shawn McCarney <shawnmm@us.ibm.com> | 2019-03-01 19:46:20 +0300 |
---|---|---|
committer | Shawn McCarney <shawnmm@us.ibm.com> | 2019-03-08 20:04:32 +0300 |
commit | 99cffd7f78aaacaffab2c75c85863cc7aeee3cbe (patch) | |
tree | bd0cb611360e16493cf15ada47bc075ee8ccc61d /redfish-core/lib/chassis.hpp | |
parent | 39e77504ba0d1e8de273cd54e1f000166bfa6d0d (diff) | |
download | bmcweb-99cffd7f78aaacaffab2c75c85863cc7aeee3cbe.tar.xz |
Redfish Chassis: Fix @odata.id, remove BuildDate
Fixed the following errors when obtaining the Redfish properties of a
Chassis:
* @odata.id URI did not contain the chassis name
* Non-Redfish DBus properties like BuildDate were returned
Tested: Verified the URL /redfish/v1/Chassis/<chassis>/ returns the
correct properties on a Witherspoon system. Ran Redfish
Service Validator.
Change-Id: I73280990db0b468aea1b12b2b919dabb2e20ca89
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/chassis.hpp')
-rw-r--r-- | redfish-core/lib/chassis.hpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index 821c7b3eeb..43bef62795 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp @@ -145,16 +145,16 @@ class Chassis : public Node res.end(); return; } + const std::string &chassisId = params[0]; res.jsonValue["@odata.type"] = "#Chassis.v1_4_0.Chassis"; - res.jsonValue["@odata.id"] = "/redfish/v1/Chassis"; + res.jsonValue["@odata.id"] = "/redfish/v1/Chassis/" + chassisId; res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Chassis.Chassis"; res.jsonValue["Name"] = "Chassis Collection"; res.jsonValue["ChassisType"] = "RackMount"; res.jsonValue["PowerState"] = "On"; - const std::string &chassisId = params[0]; auto asyncResp = std::make_shared<AsyncResp>(res); crow::connections::systemBus->async_method_call( [asyncResp, chassisId(std::string(chassisId))]( @@ -201,12 +201,23 @@ class Chassis : public Node for (const std::pair<std::string, VariantType> &property : propertiesList) { - const std::string *value = - std::get_if<std::string>(&property.second); - if (value != nullptr) + // Store DBus properties that are also Redfish + // properties with same name and a string value + const std::string &propertyName = + property.first; + if ((propertyName == "PartNumber") || + (propertyName == "SerialNumber") || + (propertyName == "Manufacturer") || + (propertyName == "Model")) { - asyncResp->res.jsonValue[property.first] = - *value; + const std::string *value = + std::get_if<std::string>( + &property.second); + if (value != nullptr) + { + asyncResp->res.jsonValue[propertyName] = + *value; + } } } asyncResp->res.jsonValue["Name"] = chassisId; |