From 31051a003c5763ae8f48a8d6176e1e5c3370284b Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 26 Oct 2022 18:34:40 +0200 Subject: [PATCH] Changing debug output --- lib/pp_admintools/app/mirror_ldap.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/pp_admintools/app/mirror_ldap.py b/lib/pp_admintools/app/mirror_ldap.py index 809ebfa..ea1d9c5 100644 --- a/lib/pp_admintools/app/mirror_ldap.py +++ b/lib/pp_admintools/app/mirror_ldap.py @@ -36,7 +36,7 @@ from .ldap import BaseLdapApplication from ..argparse_actions import NonNegativeItegerOptionAction from ..argparse_actions import LimitedFloatOptionAction -__version__ = '0.5.2' +__version__ = '0.5.3' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -351,14 +351,6 @@ class MirrorLdapApplication(BaseLdapApplication): for dn in sorted(list(self.tgt_dns_current.keys()), key=cmp_to_key(self.compare_ldap_dns)): - if dn in self.keep_entry_dns: - LOG.debug(_("Entry {!r} is set to be kept.").format(dn)) - continue - - if dn in self.sync_entry_dns: - LOG.debug(_("Entry {!r} is set to be synchronized.").format(dn)) - continue - entry = self.tgt_dns_current[dn] if 'childs' not in entry: LOG.error("Found entry {dn!r}:\n{e}".format(dn=dn, e=pp(entry))) @@ -369,6 +361,15 @@ class MirrorLdapApplication(BaseLdapApplication): "Entry {!r} is a structural entry, will not be removed " "at this point.").format(dn)) continue + + if dn in self.keep_entry_dns: + LOG.debug(_("Entry {!r} is set to be kept.").format(dn)) + continue + + if dn in self.sync_entry_dns: + LOG.debug(_("Entry {!r} is set to be synchronized.").format(dn)) + continue + self.delete_entry(self.tgt_instance, dn) if self.wait_after_write and not self.simulate: time.sleep(self.wait_after_write) @@ -388,7 +389,11 @@ class MirrorLdapApplication(BaseLdapApplication): dns = sorted(list(self.tgt_dns_current.keys()), key=cmp_to_key(self.compare_ldap_dns)) - for dn in list(reversed(dns[1:])): + for dn in list(reversed(dns)): + + entry = self.tgt_dns_current[dn] + if not entry['childs']: + continue if dn in self.keep_entry_dns: LOG.debug(_("Entry {!r} is set to be kept.").format(dn)) @@ -398,9 +403,6 @@ class MirrorLdapApplication(BaseLdapApplication): LOG.debug(_("Entry {!r} is set to be synchronized.").format(dn)) continue - entry = self.tgt_dns_current[dn] - if not entry['childs']: - continue self.delete_entry(self.tgt_instance, dn) if self.wait_after_write and not self.simulate: time.sleep(self.wait_after_write) -- 2.39.5