diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2020-09-28 21:45:19 +0300 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2020-11-10 19:46:42 +0300 |
commit | 9f8bfa7c6deb3808e3679d332479311dc4202819 (patch) | |
tree | d877cf0c95fb597b35fd6e90b109aca38d94e421 /redfish-core/lib/chassis.hpp | |
parent | c0ea7ae1c502fa2c67b0a58aee05b75581dafa7a (diff) | |
download | bmcweb-9f8bfa7c6deb3808e3679d332479311dc4202819.tar.xz |
Add new Location Indicator property
In ComputerSystem 1.13 and Chassis 1.14 as well as in many other
schemas IndicatorLED is replaced with LocationIndicatorActive.
LocationIndicatorActive is a bool while IndicatorLED had 3 states:
Lit, Blink, and off. Map Lit and Blink both to
LocationIndicatorActive true.
led.hpp was calling both enclosure_identify_blink and
enclosure_identify, continue this.
Keep the deprecated IndicatorLED and implement the new
LocationIndicatorActive property. Have both properties for
the time being. This new property makes the same calls.
This does add a new Redfish warning for the deprecated
IndicatorLED. Other warning are there today.
Tested: Validator passes
Could use help testing on Chassis. Our systems don't have a
IndicatorLED on chassis. See chassis bumped.
curl -k https://$bmc/redfish/v1/Systems/system
{
"@odata.id": "/redfish/v1/Systems/system",
"@odata.type": "#ComputerSystem.v1_13_0.ComputerSystem",
...
"IndicatorLED": "Off",
"LastResetTime": "2020-10-29T09:01:03+00:00",
"Links": {
"Chassis": [
{
"@odata.id": "/redfish/v1/Chassis/chassis"
}
],
"ManagedBy": [
{
"@odata.id": "/redfish/v1/Managers/bmc"
}
]
},
"LocationIndicatorActive": false,
curl -X PATCH -d '{ "LocationIndicatorActive":true}' -k \
https://$bmc/redfish/v1/Systems/system
curl -X PATCH -d '{ "IndicatorLED":"Off"}' -k \
https://$bmc/redfish/v1/Systems/system
Change-Id: I105bed5794912c575aa9a00e0442461bfdee6180
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/chassis.hpp')
-rw-r--r-- | redfish-core/lib/chassis.hpp | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index b7186985b3..cd26849c65 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp @@ -288,7 +288,7 @@ class Chassis : public Node } asyncResp->res.jsonValue["@odata.type"] = - "#Chassis.v1_10_0.Chassis"; + "#Chassis.v1_14_0.Chassis"; asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis/" + chassisId; asyncResp->res.jsonValue["Name"] = "Chassis Collection"; @@ -318,6 +318,7 @@ class Chassis : public Node interface) != interfaces2.end()) { getIndicatorLedState(asyncResp); + getLocationIndicatorActive(asyncResp); break; } } @@ -381,7 +382,7 @@ class Chassis : public Node // Couldn't find an object with that name. return an error messages::resourceNotFound( - asyncResp->res, "#Chassis.v1_10_0.Chassis", chassisId); + asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId); }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", @@ -394,6 +395,7 @@ class Chassis : public Node void doPatch(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { + std::optional<bool> locationIndicatorActive; std::optional<std::string> indicatorLed; auto asyncResp = std::make_shared<AsyncResp>(res); @@ -402,12 +404,15 @@ class Chassis : public Node return; } - if (!json_util::readJson(req, res, "IndicatorLED", indicatorLed)) + if (!json_util::readJson(req, res, "LocationIndicatorActive", + locationIndicatorActive, "IndicatorLED", + indicatorLed)) { return; } - if (!indicatorLed) + // TODO (Gunnar): Remove IndicatorLED after enough time has passed + if (!locationIndicatorActive && !indicatorLed) { return; // delete this when we support more patch properties } @@ -419,7 +424,7 @@ class Chassis : public Node const std::string& chassisId = params[0]; crow::connections::systemBus->async_method_call( - [asyncResp, chassisId, indicatorLed]( + [asyncResp, chassisId, locationIndicatorActive, indicatorLed]( const boost::system::error_code ec, const crow::openbmc_mapper::GetSubTreeType& subtree) { if (ec) @@ -454,23 +459,35 @@ class Chassis : public Node const std::vector<std::string>& interfaces3 = connectionNames[0].second; - if (indicatorLed) + const std::array<const char*, 2> hasIndicatorLed = { + "xyz.openbmc_project.Inventory.Item.Panel", + "xyz.openbmc_project.Inventory.Item.Board." + "Motherboard"}; + bool indicatorChassis = false; + for (const char* interface : hasIndicatorLed) { - const std::array<const char*, 2> hasIndicatorLed = { - "xyz.openbmc_project.Inventory.Item.Panel", - "xyz.openbmc_project.Inventory.Item.Board." - "Motherboard"}; - bool indicatorChassis = false; - for (const char* interface : hasIndicatorLed) + if (std::find(interfaces3.begin(), interfaces3.end(), + interface) != interfaces3.end()) { - if (std::find(interfaces3.begin(), - interfaces3.end(), - interface) != interfaces3.end()) - { - indicatorChassis = true; - break; - } + indicatorChassis = true; + break; + } + } + if (locationIndicatorActive) + { + if (indicatorChassis) + { + setLocationIndicatorActive( + asyncResp, *locationIndicatorActive); } + else + { + messages::propertyUnknown( + asyncResp->res, "LocationIndicatorActive"); + } + } + if (indicatorLed) + { if (indicatorChassis) { setIndicatorLedState(asyncResp, *indicatorLed); @@ -485,7 +502,7 @@ class Chassis : public Node } messages::resourceNotFound( - asyncResp->res, "#Chassis.v1_10_0.Chassis", chassisId); + asyncResp->res, "#Chassis.v1_14_0.Chassis", chassisId); }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", |