From 3cab9312d1fd0de246d729598054b487fbcd55ae Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 27 Oct 2022 14:08:42 +0200 Subject: [PATCH] Defining structural entries in mirror-ldap --- lib/pp_admintools/app/mirror_ldap.py | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/pp_admintools/app/mirror_ldap.py b/lib/pp_admintools/app/mirror_ldap.py index 73a5bc7..e66056d 100644 --- a/lib/pp_admintools/app/mirror_ldap.py +++ b/lib/pp_admintools/app/mirror_ldap.py @@ -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.""" -- 2.39.5