Move Redfish PECI to the new json interface
This change adds vector handling to the new json interface
and modifies the SendRawPECI Redfish command to utilize it.
Tested: Executed raw PECI commands with good and bad input
to check that it will work and error out correctly.
Change-Id: Ic1c837f5823d28555f727849156b4dabf1b8acef
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index a0c7351..2dda752 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1312,62 +1312,16 @@
const std::vector<std::string> ¶ms) override
{
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
- // Get the Raw PECI command from the request
- nlohmann::json rawPECICmd;
- if (!json_util::processJsonFromRequest(res, req, rawPECICmd))
- {
- return;
- }
- // Get the Client Address from the request
- nlohmann::json::const_iterator caIt = rawPECICmd.find("ClientAddress");
- if (caIt == rawPECICmd.end())
- {
- messages::propertyMissing(asyncResp->res, "ClientAddress");
- return;
- }
- const uint64_t *ca = caIt->get_ptr<const uint64_t *>();
- if (ca == nullptr)
- {
- messages::propertyValueTypeError(asyncResp->res, caIt->dump(),
- "ClientAddress");
- return;
- }
- // Get the Read Length from the request
- const uint8_t clientAddress = static_cast<uint8_t>(*ca);
- nlohmann::json::const_iterator rlIt = rawPECICmd.find("ReadLength");
- if (rlIt == rawPECICmd.end())
- {
- messages::propertyMissing(asyncResp->res, "ReadLength");
- return;
- }
- const uint64_t *rl = rlIt->get_ptr<const uint64_t *>();
- if (rl == nullptr)
- {
- messages::propertyValueTypeError(asyncResp->res, rlIt->dump(),
- "ReadLength");
- return;
- }
- // Get the PECI Command from the request
- const uint32_t readLength = static_cast<uint32_t>(*rl);
- nlohmann::json::const_iterator pcIt = rawPECICmd.find("PECICommand");
- if (pcIt == rawPECICmd.end())
- {
- messages::propertyMissing(asyncResp->res, "PECICommand");
- return;
- }
+ uint8_t clientAddress = 0;
+ uint8_t readLength = 0;
std::vector<uint8_t> peciCommand;
- for (auto pc : *pcIt)
+ if (!json_util::readJson(req, res, "ClientAddress", clientAddress,
+ "ReadLength", readLength, "PECICommand",
+ peciCommand))
{
- const uint64_t *val = pc.get_ptr<const uint64_t *>();
- if (val == nullptr)
- {
- messages::propertyValueTypeError(
- asyncResp->res, pc.dump(),
- "PECICommand/" + std::to_string(peciCommand.size()));
- return;
- }
- peciCommand.push_back(static_cast<uint8_t>(*val));
+ return;
}
+
// Callback to return the Raw PECI response
auto sendRawPECICallback =
[asyncResp](const boost::system::error_code ec,