Serialize the config objects
This commit serializes the config object into cereal
path and restores the config object when the phosphor-ldap-conf
restarts.
TestedBy: Unit tested
Serialize the object
Restart the phosphor-ldap-conf restores the object.
Ldap/Local authentication works fine.
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Change-Id: Ie6e940ddd6851085dc4213677dfb20e3afa0964f
diff --git a/phosphor-ldap-config/ldap_config_mgr.cpp b/phosphor-ldap-config/ldap_config_mgr.cpp
index a60e8f8..65d4bda 100644
--- a/phosphor-ldap-config/ldap_config_mgr.cpp
+++ b/phosphor-ldap-config/ldap_config_mgr.cpp
@@ -1,6 +1,5 @@
#include "ldap_config_mgr.hpp"
#include "ldap_config.hpp"
-#include "ldap_config_serialize.hpp"
#include "utils.hpp"
#include <filesystem>
@@ -73,12 +72,6 @@
}
}
-void ConfigMgr::deleteObject()
-{
- // TODO Not needed the delete functionality.
- // will do in later commit
-}
-
std::string ConfigMgr::createConfig(
std::string lDAPServerURI, std::string lDAPBindDN, std::string lDAPBaseDN,
std::string lDAPBindDNPassword, CreateIface::SearchScope lDAPSearchScope,
@@ -167,17 +160,31 @@
{
openLDAPConfigPtr = std::make_unique<Config>(
bus, openLDAPDbusObjectPath.c_str(), configFilePath.c_str(),
- tlsCacertFile.c_str(), false, "", "", "", "",
- ConfigIface::SearchScope::sub, ConfigIface::Type::OpenLdap, false,
- "", "", *this);
+ tlsCacertFile.c_str(), ConfigIface::Type::OpenLdap, *this);
+ openLDAPConfigPtr->emit_object_added();
}
if (!ADConfigPtr)
{
ADConfigPtr = std::make_unique<Config>(
bus, ADDbusObjectPath.c_str(), configFilePath.c_str(),
- tlsCacertFile.c_str(), false, "", "", "", "",
- ConfigIface::SearchScope::sub, ConfigIface::Type::ActiveDirectory,
- false, "", "", *this);
+ tlsCacertFile.c_str(), ConfigIface::Type::ActiveDirectory, *this);
+ ADConfigPtr->emit_object_added();
+ }
+}
+
+void ConfigMgr::restore()
+{
+ createDefaultObjects();
+ // Restore the ldap config and their mappings
+ if (ADConfigPtr->deserialize())
+ {
+ // Restore the role mappings in later commit
+ ADConfigPtr->emit_object_added();
+ }
+ if (openLDAPConfigPtr->deserialize())
+ {
+ // Restore the role mappings in later commit
+ openLDAPConfigPtr->emit_object_added();
}
}