diff options
author | Karthick Sundarrajan <karthick.sundarrajan@intel.com> | 2020-01-06 20:04:48 +0300 |
---|---|---|
committer | Karthick Sundarrajan <karthick.sundarrajan@intel.com> | 2020-01-17 22:43:41 +0300 |
commit | 8724c2975eaeb0eb36715204fec4406eb484e8e5 (patch) | |
tree | 98af41afd3c6b5282aa230c3010b79c3bdacdad3 | |
parent | bc6be2376b4a5407e51deab72b1a4c8a1b7fd425 (diff) | |
download | bmcweb-8724c2975eaeb0eb36715204fec4406eb484e8e5.tar.xz |
Changed input data format for Crashdump.SendRawPeci
At present, the Crashdump.SendRawPeci redfish interface accepts one
PECI command at a time. Changed it to accept array of PECI commands
through which multiple PECI commands can be aggregated into one redfish
call. Also provided backward compatibility for existing single PECI
command input format.
Tested:
Tested by aggregating 1000 PECI commands in one redfish call.
Tested by giving single PECI command with the existing format.
Change-Id: I05c547438ce9833519807b39347223183bdfb4ed
Signed-off-by: Karthick Sundarrajan <karthick.sundarrajan@intel.com>
-rw-r--r-- | redfish-core/lib/log_services.hpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 149b9f6889..9bf661a161 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -1926,23 +1926,62 @@ class SendRawPECI : public Node const std::vector<std::string> ¶ms) override { std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); - uint8_t clientAddress = 0; - uint8_t readLength = 0; - std::vector<uint8_t> peciCommand; - if (!json_util::readJson(req, res, "ClientAddress", clientAddress, - "ReadLength", readLength, "PECICommand", - peciCommand)) + std::vector<std::vector<uint8_t>> peciCommands; + + nlohmann::json reqJson = + nlohmann::json::parse(req.body, nullptr, false); + if (reqJson.find("PECICommands") != reqJson.end()) { - return; + if (!json_util::readJson(req, res, "PECICommands", peciCommands)) + { + return; + } + uint32_t idx = 0; + for (auto const &cmd : peciCommands) + { + if (cmd.size() < 3) + { + std::string s("["); + for (auto const &val : cmd) + { + if (val != *cmd.begin()) + { + s += ","; + } + s += std::to_string(val); + } + s += "]"; + messages::actionParameterValueFormatError( + res, s, "PECICommands[" + std::to_string(idx) + "]", + "SendRawPeci"); + return; + } + idx++; + } + } + else + { + /* This interface is deprecated */ + uint8_t clientAddress = 0; + uint8_t readLength = 0; + std::vector<uint8_t> peciCommand; + if (!json_util::readJson(req, res, "ClientAddress", clientAddress, + "ReadLength", readLength, "PECICommand", + peciCommand)) + { + return; + } + peciCommands.push_back({clientAddress, 0, readLength}); + peciCommands[0].insert(peciCommands[0].end(), peciCommand.begin(), + peciCommand.end()); } - // Callback to return the Raw PECI response auto sendRawPECICallback = [asyncResp](const boost::system::error_code ec, - const std::vector<uint8_t> &resp) { + const std::vector<std::vector<uint8_t>> &resp) { if (ec) { - BMCWEB_LOG_DEBUG << "failed to send PECI command ec: " + BMCWEB_LOG_DEBUG << "failed to process PECI commands ec: " << ec.message(); messages::internalError(asyncResp->res); return; @@ -1953,8 +1992,7 @@ class SendRawPECI : public Node // Call the SendRawPECI command with the provided data crow::connections::systemBus->async_method_call( std::move(sendRawPECICallback), crashdumpObject, crashdumpPath, - crashdumpRawPECIInterface, "SendRawPeci", clientAddress, readLength, - peciCommand); + crashdumpRawPECIInterface, "SendRawPeci", peciCommands); } }; |