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>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 149b9f6..9bf661a 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1926,23 +1926,62 @@
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))
- {
- return;
- }
+ std::vector<std::vector<uint8_t>> peciCommands;
+ nlohmann::json reqJson =
+ nlohmann::json::parse(req.body, nullptr, false);
+ if (reqJson.find("PECICommands") != reqJson.end())
+ {
+ 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 @@
// 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);
}
};