diff options
Diffstat (limited to 'redfish-core/lib/network_protocol.hpp')
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 133 |
1 files changed, 66 insertions, 67 deletions
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 3a769afa78..9acf5d417a 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -380,8 +380,8 @@ inline void { asyncResp->res.jsonValue["NTP"]["ProtocolEnabled"] = true; } - else if (*s == "xyz.openbmc_project.Time.Synchronization." - "Method.Manual") + else if (*s == + "xyz.openbmc_project.Time.Synchronization.Method.Manual") { asyncResp->res.jsonValue["NTP"]["ProtocolEnabled"] = false; } @@ -395,88 +395,87 @@ inline void requestRoutesNetworkProtocol(App& app) { BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/NetworkProtocol/") .privileges(redfish::privileges::patchManagerNetworkProtocol) - .methods(boost::beast::http::verb::patch)( - [](const crow::Request& req, - const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - std::optional<std::string> newHostName; - std::optional<nlohmann::json> ntp; - std::optional<nlohmann::json> ipmi; - std::optional<nlohmann::json> ssh; - - if (!json_util::readJson(req, asyncResp->res, "NTP", ntp, - "HostName", newHostName, "IPMI", ipmi, - "SSH", ssh)) + .methods( + boost::beast::http::verb:: + patch)([](const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { + std::optional<std::string> newHostName; + std::optional<nlohmann::json> ntp; + std::optional<nlohmann::json> ipmi; + std::optional<nlohmann::json> ssh; + + if (!json_util::readJson(req, asyncResp->res, "NTP", ntp, + "HostName", newHostName, "IPMI", ipmi, + "SSH", ssh)) + { + return; + } + + asyncResp->res.result(boost::beast::http::status::no_content); + if (newHostName) + { + messages::propertyNotWritable(asyncResp->res, "HostName"); + return; + } + + if (ntp) + { + std::optional<std::vector<std::string>> ntpServers; + std::optional<bool> ntpEnabled; + if (!json_util::readJson(*ntp, asyncResp->res, "NTPServers", + ntpServers, "ProtocolEnabled", + ntpEnabled)) { return; } - asyncResp->res.result(boost::beast::http::status::no_content); - if (newHostName) + if (ntpEnabled) { - messages::propertyNotWritable(asyncResp->res, "HostName"); - return; + handleNTPProtocolEnabled(*ntpEnabled, asyncResp); } - if (ntp) + if (ntpServers) { - std::optional<std::vector<std::string>> ntpServers; - std::optional<bool> ntpEnabled; - if (!json_util::readJson(*ntp, asyncResp->res, "NTPServers", - ntpServers, "ProtocolEnabled", - ntpEnabled)) - { - return; - } - - if (ntpEnabled) - { - handleNTPProtocolEnabled(*ntpEnabled, asyncResp); - } - - if (ntpServers) - { - stl_utils::removeDuplicate(*ntpServers); - handleNTPServersPatch(asyncResp, *ntpServers); - } + stl_utils::removeDuplicate(*ntpServers); + handleNTPServersPatch(asyncResp, *ntpServers); } + } - if (ipmi) + if (ipmi) + { + std::optional<bool> ipmiProtocolEnabled; + if (!json_util::readJson(*ipmi, asyncResp->res, + "ProtocolEnabled", + ipmiProtocolEnabled)) { - std::optional<bool> ipmiProtocolEnabled; - if (!json_util::readJson(*ipmi, asyncResp->res, - "ProtocolEnabled", - ipmiProtocolEnabled)) - { - return; - } + return; + } - if (ipmiProtocolEnabled) - { - handleProtocolEnabled( - *ipmiProtocolEnabled, asyncResp, - "/xyz/openbmc_project/control/service/" - "phosphor_2dipmi_2dnet_40"); - } + if (ipmiProtocolEnabled) + { + handleProtocolEnabled( + *ipmiProtocolEnabled, asyncResp, + "/xyz/openbmc_project/control/service/phosphor_2dipmi_2dnet_40"); } + } - if (ssh) + if (ssh) + { + std::optional<bool> sshProtocolEnabled; + if (!json_util::readJson(*ssh, asyncResp->res, + "ProtocolEnabled", sshProtocolEnabled)) { - std::optional<bool> sshProtocolEnabled; - if (!json_util::readJson(*ssh, asyncResp->res, - "ProtocolEnabled", - sshProtocolEnabled)) - { - return; - } + return; + } - if (sshProtocolEnabled) - { - handleProtocolEnabled( - *sshProtocolEnabled, asyncResp, - "/xyz/openbmc_project/control/service/dropbear"); - } + if (sshProtocolEnabled) + { + handleProtocolEnabled( + *sshProtocolEnabled, asyncResp, + "/xyz/openbmc_project/control/service/dropbear"); } - }); + } + }); BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/NetworkProtocol/") .privileges(redfish::privileges::getManagerNetworkProtocol) |