]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Defining structural entries in mirror-ldap
authorFrank Brehm <frank@brehm-online.com>
Thu, 27 Oct 2022 12:08:42 +0000 (14:08 +0200)
committerFrank Brehm <frank@brehm-online.com>
Thu, 27 Oct 2022 12:08:42 +0000 (14:08 +0200)
lib/pp_admintools/app/mirror_ldap.py

index 73a5bc7a62be737cdc55fd2869da9bac8859a9be..e66056d8c6e21880e4f9faffc1f6bb3a3cabf9d5 100644 (file)
@@ -37,7 +37,7 @@ from .ldap import BaseLdapApplication
 from ..argparse_actions import NonNegativeItegerOptionAction
 from ..argparse_actions import LimitedFloatOptionAction
 
-__version__ = '0.6.0'
+__version__ = '0.6.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -74,8 +74,11 @@ class MirrorLdapApplication(BaseLdapApplication):
         self.src_connect_info = None
         self.tgt_connect_info = None
 
-        self.src_dns = []
+        self.src_dns = CIDict()
+        self.src_struct_dns = CIStringSet()
+
         self.tgt_dns_current = CIDict()
+        self.tgt_struct_dns_current = CIStringSet()
 
         self.limit = 0
         self.wait_after_write = self.default_wait_after_write
@@ -295,6 +298,18 @@ class MirrorLdapApplication(BaseLdapApplication):
                 msg = _("Found DNs in instance {!r}:").format(self.src_instance)
                 LOG.debug(msg + '\n' + pp(sorted_dns))
 
+        self.src_struct_dns = CIStringSet()
+        for dn in sorted_dns:
+
+            entry = self.src_dns[dn]
+            if not entry['childs']:
+                continue
+            self.src_struct_dns.add(dn)
+
+        if self.verbose > 2:
+            msg = _("Found structural DNs in instance {!r}:").format(self.src_instance)
+            LOG.debug(msg + '\n' + pp(self.src_struct_dns.as_list()))
+
     # -------------------------------------------------------------------------
     def get_current_tgt_entries(self):
         """Get DNs of all entries in the target LDAP instance and sort them."""
@@ -317,6 +332,18 @@ class MirrorLdapApplication(BaseLdapApplication):
                 msg = _("Found DNs in instance {!r}:").format(self.tgt_instance)
                 LOG.debug(msg + '\n' + pp(sorted_dns))
 
+        self.tgt_struct_dns_current = CIStringSet()
+        for dn in sorted_dns:
+
+            entry = self.tgt_dns_current[dn]
+            if not entry['childs']:
+                continue
+            self.tgt_struct_dns_current.add(dn)
+
+        if self.verbose > 2:
+            msg = _("Found structural DNs in instance {!r}:").format(self.tgt_instance)
+            LOG.debug(msg + '\n' + pp(self.tgt_struct_dns_current.as_list()))
+
     # -------------------------------------------------------------------------
     def eval_sync_entries(self):
         """Evaluating entries, which have to be synced, instead of to be removed and recreated."""