diff options
Diffstat (limited to 'meta-ibs/meta-cp2-5422/recipes-phosphor')
-rw-r--r-- | meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0016-Redfish-implement-Syslog-config.patch | 225 | ||||
-rw-r--r-- | meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend | 1 |
2 files changed, 226 insertions, 0 deletions
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0016-Redfish-implement-Syslog-config.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0016-Redfish-implement-Syslog-config.patch new file mode 100644 index 0000000000..d07a6cb3b7 --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0016-Redfish-implement-Syslog-config.patch @@ -0,0 +1,225 @@ +From fce8aebcb0c307a7a797708a26dd39e2b173b1cd Mon Sep 17 00:00:00 2001 +From: Nikita Kosenkov <NKosenkov@IBS.RU> +Date: Thu, 15 Sep 2022 18:22:26 +0300 +Subject: [PATCH] Redfish: implement Syslog config + +1. Get config: + curl -u <Login>:<Password> -k -s -X GET https://<BMC>/redfish/v1/Syslog + +2. Update config: + curl -u <Login>:<Password> -k -s -X POST https://<BMC>/redfish/v1/Syslog/Actions/Syslog.UpdateConfig -d '{"Address": "10.0.0.10", "Port": 777}' +--- + redfish-core/include/redfish.hpp | 5 + + .../include/registries/privilege_registry.hpp | 8 + + redfish-core/lib/service_root.hpp | 1 + + redfish-core/lib/syslog.hpp | 143 ++++++++++++++++++ + 4 files changed, 157 insertions(+) + create mode 100644 redfish-core/lib/syslog.hpp + +diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp +index 9db3a2b8..ebaabdfa 100644 +--- a/redfish-core/include/redfish.hpp ++++ b/redfish-core/include/redfish.hpp +@@ -49,6 +49,7 @@ + #include "../lib/update_service.hpp" + #include "../lib/virtual_media.hpp" + #include "../lib/smtp.hpp" ++#include "../lib/syslog.hpp" + + namespace redfish + { +@@ -229,6 +230,10 @@ class RedfishService + requestRoutesTrigger(app); + requestRoutesSmtp(app); + requestSmtpFunctions(app); ++ ++ requestRoutesSyslog(app); ++ requestRoutesSyslogUpdateConfig(app); ++ + // Note, this must be the last route registered + requestRoutesRedfish(app); + } +diff --git a/redfish-core/include/registries/privilege_registry.hpp b/redfish-core/include/registries/privilege_registry.hpp +index 5ec62749..95dba316 100644 +--- a/redfish-core/include/registries/privilege_registry.hpp ++++ b/redfish-core/include/registries/privilege_registry.hpp +@@ -1435,6 +1435,14 @@ const static auto& postSwitchCollection = privilegeSetConfigureComponents; + const static auto& putSwitchCollection = privilegeSetConfigureComponents; + const static auto& deleteSwitchCollection = privilegeSetConfigureComponents; + ++// Syslog ++const static auto& getSyslog = privilegeSetLogin; ++const static auto& headSyslog = privilegeSetLogin; ++const static auto& patchSyslog = privilegeSetConfigureComponents; ++const static auto& postSyslog = privilegeSetConfigureComponents; ++const static auto& putSyslog = privilegeSetConfigureComponents; ++const static auto& deleteSyslog = privilegeSetConfigureComponents; ++ + // Task + const static auto& getTask = privilegeSetLogin; + const static auto& headTask = privilegeSetLogin; +diff --git a/redfish-core/lib/service_root.hpp b/redfish-core/lib/service_root.hpp +index 1904e8e3..b6eea99b 100644 +--- a/redfish-core/lib/service_root.hpp ++++ b/redfish-core/lib/service_root.hpp +@@ -78,6 +78,7 @@ inline void handleServiceRootGetImpl( + "/redfish/v1/TelemetryService"; + asyncResp->res.jsonValue["Cables"]["@odata.id"] = "/redfish/v1/Cables"; + asyncResp->res.jsonValue["Smtp"]["@odata.id"] = "/redfish/v1/Smtp"; ++ asyncResp->res.jsonValue["Syslog"]["@odata.id"] = "/redfish/v1/Syslog"; + + nlohmann::json& protocolFeatures = + asyncResp->res.jsonValue["ProtocolFeaturesSupported"]; +diff --git a/redfish-core/lib/syslog.hpp b/redfish-core/lib/syslog.hpp +new file mode 100644 +index 00000000..bf7c0073 +--- /dev/null ++++ b/redfish-core/lib/syslog.hpp +@@ -0,0 +1,143 @@ ++#pragma once ++ ++#include <app.hpp> ++#include <registries/privilege_registry.hpp> ++#include <query.hpp> ++ ++ ++namespace redfish ++{ ++ constexpr const char* SYSLOG_SERVICE_PATH = "xyz.openbmc_project.Syslog.Config"; ++ constexpr const char* SYSLOG_OBJECT_PATH = "/xyz/openbmc_project/logging/config/remote"; ++ constexpr const char* SYSLOG_INTERFACE_PATH = "xyz.openbmc_project.Network.Client"; ++ ++ namespace syslog ++ { ++ inline void updateSyslogProperties(std::shared_ptr<bmcweb::AsyncResp> asyncResp, ++ const std::string& address, ++ const uint16_t& port) ++ { ++ auto errorHandler = [asyncResp](const boost::system::error_code ec) { ++ if (ec) ++ { ++ BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; ++ messages::internalError(asyncResp->res); ++ } ++ }; ++ ++ crow::connections::systemBus->async_method_call( ++ errorHandler, ++ SYSLOG_SERVICE_PATH, SYSLOG_OBJECT_PATH, ++ "org.freedesktop.DBus.Properties", "Set", ++ SYSLOG_INTERFACE_PATH, ++ "Address", dbus::utility::DbusVariantType(address)); ++ ++ crow::connections::systemBus->async_method_call( ++ errorHandler, ++ SYSLOG_SERVICE_PATH, SYSLOG_OBJECT_PATH, ++ "org.freedesktop.DBus.Properties", "Set", ++ SYSLOG_INTERFACE_PATH, ++ "Port", dbus::utility::DbusVariantType(port)); ++ } ++ } ++ ++ inline void requestRoutesSyslogUpdateConfig(App& app) ++ { ++ BMCWEB_ROUTE(app, "/redfish/v1/Syslog/Actions/Syslog.UpdateConfig") ++ .privileges(redfish::privileges::postSyslog) ++ .methods(boost::beast::http::verb::post)( ++ [&app](const crow::Request& req, ++ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) ++ { ++ if (!redfish::setUpRedfishRoute(app, req, asyncResp)) ++ { ++ return; ++ } ++ ++ std::optional<std::string> address; ++ std::optional<uint16_t> port; ++ if (!json_util::readJsonAction(req, asyncResp->res, ++ "Address", address, ++ "Port", port)) ++ { ++ return; ++ } ++ ++ if(!address) ++ { ++ messages::propertyMissing(asyncResp->res, "Address"); ++ return; ++ } ++ ++ if(!port) ++ { ++ messages::propertyMissing(asyncResp->res, "Port"); ++ return; ++ } ++ ++ syslog::updateSyslogProperties(asyncResp, *address, *port); ++ }); ++ } ++ ++ inline void requestRoutesSyslog(App& app) ++ { ++ BMCWEB_ROUTE(app, "/redfish/v1/Syslog/") ++ .privileges(redfish::privileges::getSyslog) ++ .methods(boost::beast::http::verb::get)( ++ [&app](const crow::Request& req, ++ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) ++ { ++ if (!redfish::setUpRedfishRoute(app, req, asyncResp)) ++ { ++ return; ++ } ++ ++ sdbusplus::asio::getAllProperties( ++ *crow::connections::systemBus, ++ SYSLOG_SERVICE_PATH, ++ SYSLOG_OBJECT_PATH, ++ SYSLOG_INTERFACE_PATH, ++ [asyncResp](const boost::system::error_code ec, ++ const dbus::utility::DBusPropertiesMap& propertiesList) { ++ if (ec) ++ { ++ BMCWEB_LOG_ERROR << "D-Bus response error on GetSubTree " << ec; ++ messages::internalError(asyncResp->res); ++ return; ++ } ++ ++ const std::string* address = nullptr; ++ const uint16_t* port = nullptr; ++ ++ const bool success = sdbusplus::unpackPropertiesNoThrow( ++ dbus_utils::UnpackErrorPrinter(), ++ propertiesList, ++ "Address", address, ++ "Port", port); ++ ++ if (!success) ++ { ++ messages::internalError(asyncResp->res); ++ return; ++ } ++ ++ if (address != nullptr && port != nullptr) ++ { ++ nlohmann::json& configuration = ++ asyncResp->res.jsonValue["Configuration"]; ++ configuration["Address"] = *address; ++ configuration["Port"] = *port; ++ } ++ } ++ ); ++ ++ asyncResp->res.jsonValue["@odata.type"] ="#Syslog"; ++ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Syslog"; ++ asyncResp->res.jsonValue["Name"] = "Syslog"; ++ asyncResp->res.jsonValue["Description"] = "Remote Syslog destination"; ++ asyncResp->res.jsonValue["Actions"]["#Syslog.UpdateConfig"] = { ++ {"target", "/redfish/v1/Syslog/Actions/Syslog.UpdateConfig"} ++ }; ++ }); ++ } ++} +\ No newline at end of file +-- +2.35.1 + diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend index c58244089e..6a86d4360c 100644 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend @@ -12,6 +12,7 @@ SRC_URI += "\ file://0013-bugfix-telemetry-circular-buffer.patch \ file://0014-Additional-details-about-errors-when-change-user-pw.patch \ file://0015-Redfish-Implement-SNMP-Trap.patch \ + file://0016-Redfish-implement-Syslog-config.patch \ " EXTRA_OEMESON += "\ |