From 24194bd9672083de9eb4a33ff8e8369b46f823bf Mon Sep 17 00:00:00 2001 From: Nagaraju Goruganti Date: Tue, 18 Sep 2018 09:55:09 -0500 Subject: phosphor-ldap-conf: Implement the Delete interface Implement the xyz.openbmc_project.Object.Delete interface to delete LDAP config object. Change-Id: Ia7413fd10c91ad5c79286fbe4a00740ced42aad6 Signed-off-by: Nagaraju Goruganti --- phosphor-ldap-config/ldap_configuration.cpp | 12 +++++++++++- phosphor-ldap-config/ldap_configuration.hpp | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'phosphor-ldap-config') diff --git a/phosphor-ldap-config/ldap_configuration.cpp b/phosphor-ldap-config/ldap_configuration.cpp index 6680541..3a4ed2e 100644 --- a/phosphor-ldap-config/ldap_configuration.cpp +++ b/phosphor-ldap-config/ldap_configuration.cpp @@ -40,6 +40,11 @@ Config::Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath, this->emit_object_added(); } +void Config::delete_() +{ + parent.deleteObject(); +} + void Config::writeConfig() { std::stringstream confData; @@ -320,6 +325,11 @@ void ConfigMgr::restartService(const std::string& service) } } +void ConfigMgr::deleteObject() +{ + configPtr.reset(nullptr); +} + std::string ConfigMgr::createConfig(bool secureLDAP, std::string lDAPServerURI, std::string lDAPBindDN, std::string lDAPBaseDN, @@ -329,7 +339,7 @@ std::string { // TODO Validate parameters passed-in. // With current implementation we support only one LDAP server. - configPtr.reset(nullptr); + deleteObject(); auto objPath = std::string(LDAP_CONFIG_DBUS_OBJ_PATH); configPtr = std::make_unique( diff --git a/phosphor-ldap-config/ldap_configuration.hpp b/phosphor-ldap-config/ldap_configuration.hpp index a0324c1..58e9930 100644 --- a/phosphor-ldap-config/ldap_configuration.hpp +++ b/phosphor-ldap-config/ldap_configuration.hpp @@ -1,6 +1,7 @@ #pragma once #include "config.h" +#include #include #include #include @@ -23,7 +24,8 @@ static constexpr auto linuxNsSwitchFile = "/etc/nsswitch_linux.conf"; using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Common::Error; namespace ldap_base = sdbusplus::xyz::openbmc_project::User::Ldap::server; -using ConfigIface = sdbusplus::server::object::object; +using ConfigIface = sdbusplus::server::object::object< + ldap_base::Config, sdbusplus::xyz::openbmc_project::Object::server::Delete>; using CreateIface = sdbusplus::server::object::object; class ConfigMgr; @@ -116,6 +118,10 @@ class Config : public ConfigIface */ ldap_base::Config::Type lDAPType(ldap_base::Config::Type value) override; + /** @brief Delete this D-bus object. + */ + void delete_() override; + private: std::string configFilePath{}; @@ -190,6 +196,10 @@ class ConfigMgr : public CreateIface */ virtual void restartService(const std::string& service); + /** @brief delete the config D-Bus object. + */ + void deleteObject(); + private: /** @brief Persistent sdbusplus D-Bus bus connection. */ sdbusplus::bus::bus& bus; -- cgit v1.2.1