summaryrefslogtreecommitdiffstats
path: root/phosphor-rsyslog-config/server-conf.hpp
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2018-08-23 02:19:58 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2018-08-29 03:38:49 -0500
commitc49661925b0c59a4355aca6813a85d749c21e764 (patch)
tree65d4ecebf593f3d77cd428bf3397f7d99f762006 /phosphor-rsyslog-config/server-conf.hpp
parent9067c077034cd92e0498646b7d7a05fba890532c (diff)
downloadphosphor-logging-c49661925b0c59a4355aca6813a85d749c21e764.tar.gz
phosphor-logging-c49661925b0c59a4355aca6813a85d749c21e764.zip
Add application to configure rsyslog
The application implements the xyz.openbmc_project.Network.Client D-Bus interface to set a remote rsyslog server's address and port in the rsyslog config file. This lets us configure rsyslog to be able to stream out logs. TODO: Exception handling and validation will be handled in subsequent commits. Change-Id: I8917daab3f0de1806d2f1aafe99cb3a872f19184 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'phosphor-rsyslog-config/server-conf.hpp')
-rw-r--r--phosphor-rsyslog-config/server-conf.hpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/phosphor-rsyslog-config/server-conf.hpp b/phosphor-rsyslog-config/server-conf.hpp
new file mode 100644
index 0000000..cb8882b
--- /dev/null
+++ b/phosphor-rsyslog-config/server-conf.hpp
@@ -0,0 +1,76 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <string>
+#include "xyz/openbmc_project/Network/Client/server.hpp"
+
+namespace phosphor
+{
+namespace rsyslog_config
+{
+
+using NetworkClient = sdbusplus::xyz::openbmc_project::Network::server::Client;
+using Iface = sdbusplus::server::object::object<NetworkClient>;
+
+/** @class Server
+ * @brief Configuration for rsyslog server
+ * @details A concrete implementation of the
+ * xyz.openbmc_project.Network.Client API, in order to
+ * provide remote rsyslog server's address and port.
+ */
+class Server : public Iface
+{
+ public:
+ Server() = delete;
+ Server(const Server&) = delete;
+ Server& operator=(const Server&) = delete;
+ Server(Server&&) = delete;
+ Server& operator=(Server&&) = delete;
+ virtual ~Server() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ * @param[in] filePath - rsyslog remote logging config file
+ */
+ Server(sdbusplus::bus::bus& bus,
+ const std::string& path,
+ const char* filePath) :
+ Iface(bus, path.c_str()),
+ configFilePath(filePath)
+ {
+ }
+
+ using NetworkClient::address;
+ using NetworkClient::port;
+
+ /** @brief Override that updates rsyslog config file as well
+ * @param[in] value - remote server address
+ * @returns value of changed address
+ */
+ virtual std::string address(std::string value) override;
+
+ /** @brief Override that updates rsyslog config file as well
+ * @param[in] value - remote server port
+ * @returns value of changed port
+ */
+ virtual uint16_t port(uint16_t value) override;
+
+ private:
+ /** @brief Update remote server address and port in
+ * rsyslog config file.
+ * @param[in] serverAddress - remote server address
+ * @param[in] serverPort - remote server port
+ * @param[in] filePath - rsyslog config file path
+ */
+ void writeConfig(
+ const std::string& serverAddress,
+ uint16_t serverPort,
+ const char* filePath);
+
+ std::string configFilePath{};
+};
+
+} // namespace rsyslog_config
+} // namespace phosphor
OpenPOWER on IntegriCloud