From 5c2c2d4d5eb0850fc333198daceced1cf8d9c136 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 27 Nov 2020 17:23:11 +0100 Subject: [PATCH] Trying to migrate normal entries - without success at all. --- lib/ldap_migration/__init__.py | 44 ++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index 13bd276..b2f9311 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -45,7 +45,7 @@ from .config import LDAPMigrationConfiguration from .idict import CaseInsensitiveDict from .istringset import CaseInsensitiveStringSet -__version__ = '0.7.3' +__version__ = '0.8.0' LOG = logging.getLogger(__name__) CFG_BASENAME = 'ldap-migration.ini' @@ -1008,6 +1008,9 @@ class LDAPMigrationApplication(BaseApplication): if not self.migrate_structural_entries(fh): return False + if not self.migrate_all_entries(fh): + return False + print() return True @@ -1017,6 +1020,9 @@ class LDAPMigrationApplication(BaseApplication): print() LOG.info("Migrating all structural entries from source to target LDAP cluster.") + print("# Structural entries", file=fh, flush=True) + print("####################", file=fh, flush=True) + self.count_unchanged = 0 self.count_added = 0 self.count_modified = 0 @@ -1037,6 +1043,40 @@ class LDAPMigrationApplication(BaseApplication): to=total, ad=self.count_added, mo=self.count_modified, un=self.count_unchanged) LOG.info(msg) + time.sleep(3) + return True + + # ------------------------------------------------------------------------- + def migrate_all_entries(self, fh): + + print() + LOG.info("Migrating all entries from source to target LDAP cluster.") + + print("", file=fh, flush=True) + print("# All entries", file=fh, flush=True) + print("#############", file=fh, flush=True) + + self.count_unchanged = 0 + self.count_added = 0 + self.count_modified = 0 + + try: + self._migrate_entries( + self.dns, fh=fh, force=False, is_root=True, with_acl=False) + except (ReadLDAPItemError, WriteLDAPItemError) as e: + msg = "Abort migration: " + str(e) + LOG.error(msg) + return False + + print() + total = self.count_unchanged + self.count_added + self.count_modified + msg = ( + "Performed all entries: {to} total, {ad} added, {mo} modified, " + "{un} unchanged.").format( + to=total, ad=self.count_added, mo=self.count_modified, + un=self.count_unchanged) + LOG.info(msg) + time.sleep(3) return True # ------------------------------------------------------------------------- @@ -1259,7 +1299,7 @@ class LDAPMigrationApplication(BaseApplication): def write_result_file(self, fh, dn, tag=' '): ts = datetime.datetime.now(self.tz).isoformat(' ', timespec='seconds') - line = "{tag}{dn}: {ts}".format(tag=tag, dn=dn, ts=ts) + line = "{tag} {dn}: {ts}".format(tag=tag, dn=dn, ts=ts) print(line, file=fh, flush=True) # ------------------------------------------------------------------------- -- 2.39.5