From 7ab06f49454378a9b5c1934f5e155a4f3c352fdb Mon Sep 17 00:00:00 2001 From: Gunnar Mills Date: Tue, 2 Jul 2019 13:07:16 -0500 Subject: Move PowerLimit to correct location See the following Redfish Validator errors and warning: /redfish/v1/Chassis/chassis/Power ERROR - PowerLimit not defined in schema Power.v1_5_2 (check version, spelling and casing) /redfish/v1/Chassis/chassis/Power#/PowerControl/ ERROR - Decoded object no longer a dictionary /redfish/v1/Chassis/chassis/Power ERROR - @odata.id of ReferenceableMember does not properly resolve: /redfish/v1/Chassis/chassis/Power#/PowerControl/ WARNING - No @odata.type present, assuming highest type Power.v1_0_0.PowerControl Power.v1_4_0.PowerControl If you look at the specification/mockups, PowerLimit is under PowerControl. From the https://redfish.dmtf.org/redfish/mockups/v1/893 mockup: PowerControl": [ { "@odata.id": "/redfish/v1/Chassis/1U/Power#/PowerControl/0", "MemberId": "0", ... "PowerAvailableWatts": 0, "PowerCapacityWatts": 800, ... "PowerLimit": { "LimitInWatts": 500, "LimitException": "LogEventOnly", "CorrectionInMs": 50 } , ... } ], Added an odata.type and fixed the odata.id for PowerControl. Put all power control sensors under the same PowerControl like we do for PowerSupplies. Tested: No longer see the errors. If no total_power (happens when a Open Power system is off): curl -k https://${bmc}/redfish/v1/Chassis/chassis/Power ... "PowerControl": [ { "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/0", "@odata.type": "#Power.v1_0_0.PowerControl", "MemberId": "0", "Name": "Chassis Power Control", "PowerLimit": { "LimitInWatts": null } } ], "Redundancy": [], ... curl -k https://${bmc}/redfish/v1/Chassis/chassis/Power/ { "PowerControl": [ { "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/0", "@odata.type": "#Power.v1_0_0.PowerControl", "MemberId": "0", "Name": "Chassis Power Control", "PowerConsumedWatts": 232.0, "PowerLimit": { "LimitInWatts": null }, "Status": { "Health": "OK", "State": "Enabled" Change-Id: I8ca47bd6c7dedf5d0685886e2e45e6f964f69060 Signed-off-by: Gunnar Mills --- redfish-core/lib/power.hpp | 17 ++++++++++++++--- redfish-core/lib/sensors.hpp | 24 +++++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp index e6f1eba..8c3927b 100644 --- a/redfish-core/lib/power.hpp +++ b/redfish-core/lib/power.hpp @@ -124,11 +124,21 @@ class Power : public Node } nlohmann::json& tempArray = - sensorAsyncResp->res.jsonValue["PowerLimit"]; + sensorAsyncResp->res.jsonValue["PowerControl"]; + // Put multiple "sensors" into a single PowerControl, 0, so + // only create the first one if (tempArray.empty()) { - tempArray.push_back({}); + // Mandatory properties odata.id and MemberId + // A warning without a odata.type + tempArray.push_back( + {{"@odata.type", "#Power.v1_0_0.PowerControl"}, + {"@odata.id", "/redfish/v1/Chassis/" + + sensorAsyncResp->chassisId + + "/Power#/PowerControl/0"}, + {"Name", "Chassis Power Control"}, + {"MemberId", "0"}}); } nlohmann::json& sensorJson = tempArray.back(); @@ -188,7 +198,8 @@ class Power : public Node } } - nlohmann::json& value = sensorJson["LimitInWatts"]; + nlohmann::json& value = + sensorJson["PowerLimit"]["LimitInWatts"]; if (enabled) { diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 7980ba2..0ed47f7 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -568,6 +568,11 @@ void objectInterfacesToJson( if (!sensorName.compare("total_power")) { + sensor_json["@odata.type"] = "#Power.v1_0_0.PowerControl"; + // Put multiple "sensors" into a single PowerControl, so have + // generic names for MemberId and Name. Follows Redfish mockup. + sensor_json["MemberId"] = "0"; + sensor_json["Name"] = "Chassis Power Control"; unit = "PowerConsumedWatts"; } else if (sensorNameLower.find("input") != std::string::npos) @@ -1493,10 +1498,23 @@ void getSensorData( nlohmann::json& tempArray = SensorsAsyncResp->res.jsonValue[fieldName]; - if (fieldName == "PowerSupplies" && !tempArray.empty()) + if ((fieldName == "PowerSupplies" || + fieldName == "PowerControl") && + !tempArray.empty()) { - // Power supplies put multiple "sensors" into a single power - // supply entry, so only create the first one + // For power supplies and power control put multiple + // "sensors" into a single power supply or power control + // entry, so only create the first one + } + else if (fieldName == "PowerControl") + { + // Put multiple "sensors" into a single PowerControl. + // Follows MemberId naming and naming in power.hpp. + tempArray.push_back( + {{"@odata.id", "/redfish/v1/Chassis/" + + SensorsAsyncResp->chassisId + "/" + + SensorsAsyncResp->chassisSubNode + + "#/" + fieldName + "/0"}}); } else { -- cgit v1.2.3