]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Adding counters
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 18 Nov 2020 16:52:19 +0000 (17:52 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 18 Nov 2020 16:52:19 +0000 (17:52 +0100)
lib/ldap_migration/__init__.py

index 75f7a81de7d4071bc5dcb7d674375ddb56a0c3d1..1a890609046e317c1035329ededa76094ad9343d 100644 (file)
@@ -37,7 +37,7 @@ from fb_tools.errors import FbAppError
 from .config import LDAPMigrationConfiguration
 from .idict import CaseInsensitiveDict
 
-__version__ = '0.6.3'
+__version__ = '0.6.4'
 
 LOG = logging.getLogger(__name__)
 CFG_BASENAME = 'ldap-migration.ini'
@@ -174,6 +174,10 @@ class LDAPMigrationApplication(BaseApplication):
 
         self.limit = 0
 
+        self.count_unchanged = 0
+        self.count_added = 0
+        self.count_modified = 0
+
         self.object_classes = CaseInsensitiveDict()
         self.attribute_types = CaseInsensitiveDict()
         self.dns = CaseInsensitiveDict()
@@ -832,8 +836,20 @@ class LDAPMigrationApplication(BaseApplication):
         print()
         LOG.info("Migrating all structural from source to target LDAP cluster.")
 
+        self.count_unchanged = 0
+        self.count_added = 0
+        self.count_modified = 0
+
         self._migrate_entries(self.struct_dns, is_root=True, with_acl=False)
 
+        total = self.count_unchanged + self.count_added + self.count_modified
+        msg = (
+            "Performed structural 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)
+
     # -------------------------------------------------------------------------
     def generate_target_entry(self, src_entry, src_dn, tgt_dn):
 
@@ -941,6 +957,7 @@ class LDAPMigrationApplication(BaseApplication):
         if changes.keys():
             return changes
 
+        self.count_unchanged += 1
         if self.verbose:
             msg = "No changes on target entry {tdn!r} necessary.".format(tdn=tgt_dn)
             LOG.info(msg)
@@ -1006,6 +1023,7 @@ class LDAPMigrationApplication(BaseApplication):
                             msg = "Changes on target entry {tdn!r}:\n{ch}".format(
                                 tdn=tgt_dn, ch=pp(changes))
                             LOG.debug(msg)
+                        self.count_modified += 1
                         if not self.simulate:
                             self.target.modify(tgt_dn, changes)
                         if wait:
@@ -1023,6 +1041,7 @@ class LDAPMigrationApplication(BaseApplication):
                         msg += "entry: {en}"
                         msg = msg.format(dn=tgt_dn, oc=tgt_obj_classes, en=tgt_entry)
                         LOG.debug(msg)
+                    self.count_added += 1
                     if not self.simulate:
                         self.target.add(tgt_dn, object_class=tgt_obj_classes, attributes=tgt_entry)
                     if wait: