From 0a97b245cd7c25b4cd16dd937facecc40b066a99 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 26 Nov 2020 17:48:29 +0100 Subject: [PATCH] Tagging migrated entries --- lib/ldap_migration/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index ae85775..ac86515 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.1' +__version__ = '0.7.2' LOG = logging.getLogger(__name__) CFG_BASENAME = 'ldap-migration.ini' @@ -1183,6 +1183,7 @@ class LDAPMigrationApplication(BaseApplication): if 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 src_entry = self.get_source_item(src_dn, tgt_dn, with_acl=with_acl) @@ -1214,11 +1215,10 @@ class LDAPMigrationApplication(BaseApplication): ch=pp(changes)) raise WriteLDAPItemError(msg) self.migrated_entries[rev_dn] = tgt_dn - ts = datetime.datetime.now(self.tz).isoformat(' ', timespec='seconds') - line = "{dn}: {ts}".format(dn=tgt_dn, ts=ts) - print(line, file=fh, flush=True) + self.write_result_file(fh, tgt_dn, '+') return True else: + self.write_result_file(fh, tgt_dn, ' ') return False (tgt_obj_classes, tgt_entry) = self.generate_target_entry(src_entry, src_dn, tgt_dn) @@ -1250,10 +1250,15 @@ class LDAPMigrationApplication(BaseApplication): raise WriteLDAPItemError(msg) self.migrated_entries[rev_dn] = tgt_dn + self.write_result_file(fh, tgt_dn, '*') + return True + + # ------------------------------------------------------------------------- + def write_result_file(self, fh, dn, tag=' '): + ts = datetime.datetime.now(self.tz).isoformat(' ', timespec='seconds') - line = "{dn}: {ts}".format(dn=tgt_dn, ts=ts) + line = "{tag}{dn}: {ts}".format(tag=tag, dn=dn, ts=ts) print(line, file=fh, flush=True) - return True # ------------------------------------------------------------------------- def compare_values(self, first, second): -- 2.39.5