from ..argparse_actions import NonNegativeItegerOptionAction
from ..argparse_actions import LimitedFloatOptionAction
-__version__ = '0.5.1'
+__version__ = '0.5.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.structural_entr_dns = []
self.non_structural_entr_dns = []
self.keep_entry_dns = []
+ self.sync_entry_dns = []
desc = _(
"Mirror the content of a complete LDAP instance (server or cluster) to "
"(except the base DN entry, of course)."))
self.get_current_tgt_entries()
+ self.eval_sync_entries()
self.clean_tgt_non_struct_entries()
self.clean_tgt_struct_entries()
if self.verbose > 4:
LOG.debug("Current target entries:\n" + pp(self.tgt_dns_current.dict()))
+ # -------------------------------------------------------------------------
+ def eval_sync_entries(self):
+ """Evaluating entries, which have to be synced, instead of to be removed and recreated."""
+
+ self.sync_entry_dns = []
+ LOG.debug(_(
+ "Evaluating DNs of all target entries, which have to be synchronized, "
+ "instead of removing and recreating them."))
+
+ base_dn = self.tgt_connect_info.base_dn
+
+ self.sync_entry_dns.append(base_dn)
+
+ for dn in self.keep_entry_dns:
+
+ tokens = self.re_dn_separator.split(dn)
+ while len(tokens):
+ tokens.pop(0)
+ if not len(tokens):
+ break
+ parent_dn = ','.join(tokens)
+ if base_dn not in parent_dn:
+ break
+ if parent_dn not in self.sync_entry_dns:
+ self.sync_entry_dns.append(parent_dn)
+
+ LOG.debug("DNs of sync entries:\n" + pp(self.sync_entry_dns))
+
# -------------------------------------------------------------------------
def register_dn_tokens(self, dn, entry, registry):
self.empty_line()
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)))
dns = sorted(list(self.tgt_dns_current.keys()), key=cmp_to_key(self.compare_ldap_dns))
for dn in list(reversed(dns[1:])):
+
+ 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 not entry['childs']:
continue