]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Trying to migrate normal entries - without success at all.
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 27 Nov 2020 16:23:11 +0000 (17:23 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 27 Nov 2020 16:23:11 +0000 (17:23 +0100)
lib/ldap_migration/__init__.py

index 13bd27673ed936b955242e9876619b3e766d4159..b2f93117aa36da085a75fdef9c9903166a400272 100644 (file)
@@ -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)
 
     # -------------------------------------------------------------------------