Move the restart systemdunit function to network manager
Change-Id: I647741fc3976ca82c39998a518b1de7be5365e80
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
diff --git a/network_manager.hpp b/network_manager.hpp
index 23eaacb..7a98f9a 100644
--- a/network_manager.hpp
+++ b/network_manager.hpp
@@ -115,6 +115,20 @@
/** @brief restart the network timers. */
void restartTimers();
+ /** @brief Restart the systemd unit
+ * @param[in] unit - systemd unit name which needs to be
+ * restarted.
+ */
+ inline void restartSystemdUnit(const std::string& unit)
+ {
+ auto bus = sdbusplus::bus::new_default();
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "RestartUnit");
+
+ method.append(unit, "replace");
+ bus.call_noreply(method);
+ }
+
private:
/** @brief Persistent sdbusplus DBus bus connection. */
sdbusplus::bus::bus& bus;