]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Changing debug output
authorFrank Brehm <frank@brehm-online.com>
Wed, 26 Oct 2022 16:34:40 +0000 (18:34 +0200)
committerFrank Brehm <frank@brehm-online.com>
Wed, 26 Oct 2022 16:34:40 +0000 (18:34 +0200)
lib/pp_admintools/app/mirror_ldap.py

index 809ebfa7284b244caf1fba8997826a81687e2893..ea1d9c50a93bcfed6bbad1d783ac4c1edc747f79 100644 (file)
@@ -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)