From d5ee2070e3895b5919680cdb9e5ac1e528eac66d Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 27 Nov 2020 14:52:50 +0100 Subject: [PATCH] Adding force parameter to some methods --- lib/ldap_migration/__init__.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index ac86515..13bd276 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -45,7 +45,7 @@ from .config import LDAPMigrationConfiguration from .idict import CaseInsensitiveDict from .istringset import CaseInsensitiveStringSet -__version__ = '0.7.2' +__version__ = '0.7.3' LOG = logging.getLogger(__name__) CFG_BASENAME = 'ldap-migration.ini' @@ -1022,7 +1022,8 @@ class LDAPMigrationApplication(BaseApplication): self.count_modified = 0 try: - self._migrate_entries(self.struct_dns, fh=fh, is_root=True, with_acl=False) + self._migrate_entries( + self.struct_dns, fh=fh, force=False, is_root=True, with_acl=False) except (ReadLDAPItemError, WriteLDAPItemError) as e: msg = "Abort migration: " + str(e) LOG.error(msg) @@ -1159,29 +1160,30 @@ class LDAPMigrationApplication(BaseApplication): return None # ------------------------------------------------------------------------- - def _migrate_entries(self, cur_hash, fh, is_root=False, with_acl=False): + def _migrate_entries(self, cur_hash, fh, force=False, is_root=False, with_acl=False): wait = self.config.wait_after_write if not is_root: src_dn = cur_hash['dn'] - if self.migrate_entry(src_dn, fh=fh, with_acl=with_acl): + if self.migrate_entry(src_dn, fh=fh, force=force, with_acl=with_acl): if wait: time.sleep(wait) for key in cur_hash['childs'].keys(): - self._migrate_entries(cur_hash['childs'][key], fh=fh, is_root=False, with_acl=with_acl) + self._migrate_entries( + cur_hash['childs'][key], fh=fh, force=force, is_root=False, with_acl=with_acl) # ------------------------------------------------------------------------- - def migrate_entry(self, src_dn, fh, with_acl=False): + def migrate_entry(self, src_dn, fh, force=False, with_acl=False): tgt_dn = self.mangle_dn(src_dn) rev_dn = self.get_reverse_dn(tgt_dn) LOG.debug("Migrating source DN {sdn!r} -> {tdn!r}.".format( sdn=src_dn, tdn=tgt_dn)) - if rev_dn in self.migrated_entries: + if not force and rev_dn in self.migrated_entries: LOG.debug("Entry {!r} is already migrated.".format(tgt_dn)) self.write_result_file(fh, tgt_dn, '-') return False -- 2.39.5