diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2020-05-19 14:52:08 +0300 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2020-06-17 07:49:45 +0300 |
commit | 67a78d8758859a4e4477de932d24fac5fb287dad (patch) | |
tree | 1c523b1ad167738f477ef48be5c274d4f0a13dc1 /redfish-core/lib/network_protocol.hpp | |
parent | 92f682233ff0b8b20692e337632326cbd5a03676 (diff) | |
download | bmcweb-67a78d8758859a4e4477de932d24fac5fb287dad.tar.xz |
ipmi: Enable/Disable IPMI-over-LAN
This patch adds support for enabling and disabling IPMI-over-LAN using
Redfish API. If there are multiple instances of phosphor-ipmi-net
service, then the PATCH action applies to all the instances. This patch
does not add support for configuring the port of IPMI-over-LAN.
Tested:
1) Ran the Redfish Validator.
2) Disabled IPMI-over-LAN from Redfish and verified network IPMI
stopped and verified ProtocolEnabled is false for IPMI.
3) Enabled IPMI-over-LAN from Redfish and verified network IPMI is
running and verified ProtocolEnabled is true for IPMI.
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Change-Id: Ie9b00c8195bbfea14a69cbe9a73492187e6b4e1c
Diffstat (limited to 'redfish-core/lib/network_protocol.hpp')
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 60735d049a..e5448f183c 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -17,6 +17,7 @@ #include "error_messages.hpp" #include "node.hpp" +#include "openbmc_dbus_rest.hpp" #include <utils/json_utils.hpp> @@ -426,14 +427,76 @@ class NetworkProtocol : public Node std::variant<std::vector<std::string>>{ntpServers}); } + void handleIpmiProtocolEnabled(const bool ipmiProtocolEnabled, + const std::shared_ptr<AsyncResp>& asyncResp) + { + crow::connections::systemBus->async_method_call( + [ipmiProtocolEnabled, + asyncResp](const boost::system::error_code ec, + const crow::openbmc_mapper::GetSubTreeType& subtree) { + if (ec) + { + messages::internalError(asyncResp->res); + return; + } + + constexpr char const* netipmidBasePath = + "/xyz/openbmc_project/control/service/" + "phosphor_2dipmi_2dnet_40"; + + for (const auto& entry : subtree) + { + if (boost::algorithm::starts_with(entry.first, + netipmidBasePath)) + { + crow::connections::systemBus->async_method_call( + [ipmiProtocolEnabled, + asyncResp](const boost::system::error_code ec) { + if (ec) + { + messages::internalError(asyncResp->res); + return; + } + }, + entry.second.begin()->first, entry.first, + "org.freedesktop.DBus.Properties", "Set", + "xyz.openbmc_project.Control.Service.Attributes", + "Running", std::variant<bool>{ipmiProtocolEnabled}); + + crow::connections::systemBus->async_method_call( + [ipmiProtocolEnabled, + asyncResp](const boost::system::error_code ec) { + if (ec) + { + messages::internalError(asyncResp->res); + return; + } + }, + entry.second.begin()->first, entry.first, + "org.freedesktop.DBus.Properties", "Set", + "xyz.openbmc_project.Control.Service.Attributes", + "Enabled", std::variant<bool>{ipmiProtocolEnabled}); + } + } + }, + "xyz.openbmc_project.ObjectMapper", + "/xyz/openbmc_project/object_mapper", + "xyz.openbmc_project.ObjectMapper", "GetSubTree", + "/xyz/openbmc_project/control/service", 0, + std::array<const char*, 1>{ + "xyz.openbmc_project.Control.Service.Attributes"}); + } + void doPatch(crow::Response& res, const crow::Request& req, const std::vector<std::string>& params) override { std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); std::optional<std::string> newHostName; std::optional<nlohmann::json> ntp; + std::optional<nlohmann::json> ipmi; - if (!json_util::readJson(req, res, "HostName", newHostName, "NTP", ntp)) + if (!json_util::readJson(req, res, "HostName", newHostName, "NTP", ntp, + "IPMI", ipmi)) { return; } @@ -469,6 +532,21 @@ class NetworkProtocol : public Node handleNTPServersPatch(*ntpServers, asyncResp); } } + + if (ipmi) + { + std::optional<bool> ipmiProtocolEnabled; + if (!json_util::readJson(*ipmi, res, "ProtocolEnabled", + ipmiProtocolEnabled)) + { + return; + } + + if (ipmiProtocolEnabled) + { + handleIpmiProtocolEnabled(*ipmiProtocolEnabled, asyncResp); + } + } } }; |