diff options
author | Johnathan Mantey <johnathanx.mantey@intel.com> | 2019-08-30 16:56:24 +0300 |
---|---|---|
committer | Johnathan Mantey <johnathanx.mantey@intel.com> | 2019-09-04 02:38:41 +0300 |
commit | cf05f9dc31a47123521348bc870fc687e3f35b4c (patch) | |
tree | 051a52251c2ac442f95133d80cb00143869bc3f5 /redfish-core/lib/network_protocol.hpp | |
parent | 265c1602771dfb1eab8da654688bf881b37b3ee2 (diff) | |
download | bmcweb-cf05f9dc31a47123521348bc870fc687e3f35b4c.tar.xz |
Redfish: Make PATCH NTP Servers operate correctly
The Managers NTP node did not get implemented correctly. The first
level parsing did not search for "NTP" as the base entry, nor did it
correctly attempt to acquire the NTPServers, NTPEnabled sub-nodes.
Removed the data response as it was returning a string vector instead
of a json::array. The original code caused a seg fault. Instead of
returning a carbon copy of the values sent, the return is a 204 code,
indicating success and returning no data.
Change-Id: Ifb82855e1cd143e3cf2cb8979531b01b27d32234
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
Diffstat (limited to 'redfish-core/lib/network_protocol.hpp')
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 74d742f7e0..d92315e1eb 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -352,7 +352,6 @@ class NetworkProtocol : public Node messages::internalError(asyncResp->res); return; } - messages::success(asyncResp->res); }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/config", @@ -377,10 +376,7 @@ class NetworkProtocol : public Node } crow::connections::systemBus->async_method_call( - [asyncResp, - ntpEnabled](const boost::system::error_code error_code) { - asyncResp->res.jsonValue["NTP"]["ProtocolEnabled"] = ntpEnabled; - }, + [asyncResp](const boost::system::error_code error_code) {}, "xyz.openbmc_project.Settings", "/xyz/openbmc_project/time/sync_method", "org.freedesktop.DBus.Properties", "Set", @@ -392,14 +388,12 @@ class NetworkProtocol : public Node const std::shared_ptr<AsyncResp>& asyncResp) { crow::connections::systemBus->async_method_call( - [asyncResp, ntpServers](const boost::system::error_code ec) { + [asyncResp](const boost::system::error_code ec) { if (ec) { messages::internalError(asyncResp->res); return; } - asyncResp->res.jsonValue["NTP"]["NTPServers"] = - std::move(ntpServers); }, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/eth0", "org.freedesktop.DBus.Properties", "Set", @@ -412,27 +406,38 @@ class NetworkProtocol : public Node { std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); std::optional<std::string> newHostName; - std::optional<std::vector<std::string>> ntpServers; - std::optional<bool> ntpEnabled; + std::optional<nlohmann::json> ntp; - if (!json_util::readJson(req, res, "HostName", newHostName, - "NTPServers", ntpServers, "NTPEnabled", - ntpEnabled)) + if (!json_util::readJson(req, res, "HostName", newHostName, "NTP", ntp)) { return; } + + res.result(boost::beast::http::status::no_content); if (newHostName) { handleHostnamePatch(*newHostName, asyncResp); - return; } - if (ntpEnabled) - { - handleNTPProtocolEnabled(*ntpEnabled, asyncResp); - } - if (ntpServers) + + if (ntp) { - handleNTPServersPatch(*ntpServers, asyncResp); + std::optional<std::vector<std::string>> ntpServers; + std::optional<bool> ntpEnabled; + if (!json_util::readJson(*ntp, res, "NTPServers", ntpServers, + "ProtocolEnabled", ntpEnabled)) + { + return; + } + + if (ntpEnabled) + { + handleNTPProtocolEnabled(*ntpEnabled, asyncResp); + } + + if (ntpServers) + { + handleNTPServersPatch(*ntpServers, asyncResp); + } } } }; |