From ce8b4ca7c0027a3c87e5e4dc669a42b8665d1a4a Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Dec 04 2019 13:11:22 +0000 Subject: Issue 50753 - Dumping the changelog to a file doesn't work Description: Pass the logging object to the code branch where -i CHANGELOG_FILE is not specified, so -o OUTPUT_FILE works correctly in that case too. https://pagure.io/389-ds-base/issue/50753 Reviewed by: mreynolds (Thanks!) --- diff --git a/src/lib389/lib389/cli_conf/replication.py b/src/lib389/lib389/cli_conf/replication.py index 58bbd13..47f530a 100644 --- a/src/lib389/lib389/cli_conf/replication.py +++ b/src/lib389/lib389/cli_conf/replication.py @@ -1000,7 +1000,8 @@ def dump_cl(inst, basedn, log, args): if not args.changelog_ldif: replicas.process_and_dump_changelog(replica_roots=args.replica_roots, csn_only=args.csn_only, - preserve_ldif_done=args.preserve_ldif_done) + preserve_ldif_done=args.preserve_ldif_done, + log=log) else: try: assert os.path.exists(args.changelog_ldif) diff --git a/src/lib389/lib389/replica.py b/src/lib389/lib389/replica.py index 9b84d8f..9ba97ff 100644 --- a/src/lib389/lib389/replica.py +++ b/src/lib389/lib389/replica.py @@ -1648,7 +1648,7 @@ class Replicas(DSLdapObjects): replica._populate_suffix() return replica - def process_and_dump_changelog(self, replica_roots=[], csn_only=False, preserve_ldif_done=False): + def process_and_dump_changelog(self, replica_roots=[], csn_only=False, preserve_ldif_done=False, log=None): """Dump and decode Directory Server replication change log :param replica_roots: Replica suffixes that need to be processed @@ -1657,6 +1657,9 @@ class Replicas(DSLdapObjects): :type csn_only: bool """ + if log is None: + log = self._log + repl_roots = [] try: cl = Changelog5(self._instance) @@ -1677,7 +1680,7 @@ class Replicas(DSLdapObjects): got_ldif = False current_time = time.time() replica = self.get(repl_root) - self._log.info(f"# Replica Root: {repl_root}") + log.info(f"# Replica Root: {repl_root}") replica.replace("nsDS5Task", 'CL2LDIF') # Decode the dumped changelog @@ -1687,7 +1690,7 @@ class Replicas(DSLdapObjects): if os.path.getmtime(file_path) < current_time: continue got_ldif = True - cl_ldif = ChangelogLDIF(file_path, self._log) + cl_ldif = ChangelogLDIF(file_path, log) if csn_only: cl_ldif.grep_csn() @@ -1700,7 +1703,7 @@ class Replicas(DSLdapObjects): os.remove(file_path) if not got_ldif: - self._log.info("LDIF file: Not found") + log.info("LDIF file: Not found") class BootstrapReplicationManager(DSLdapObject):