from .idict import CaseInsensitiveDict
from .istringset import CaseInsensitiveStringSet
-__version__ = '0.7.3'
+__version__ = '0.8.0'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
if not self.migrate_structural_entries(fh):
return False
+ if not self.migrate_all_entries(fh):
+ return False
+
print()
return True
print()
LOG.info("Migrating all structural entries from source to target LDAP cluster.")
+ print("# Structural entries", file=fh, flush=True)
+ print("####################", file=fh, flush=True)
+
self.count_unchanged = 0
self.count_added = 0
self.count_modified = 0
to=total, ad=self.count_added, mo=self.count_modified,
un=self.count_unchanged)
LOG.info(msg)
+ time.sleep(3)
+ return True
+
+ # -------------------------------------------------------------------------
+ def migrate_all_entries(self, fh):
+
+ print()
+ LOG.info("Migrating all entries from source to target LDAP cluster.")
+
+ print("", file=fh, flush=True)
+ print("# All entries", file=fh, flush=True)
+ print("#############", file=fh, flush=True)
+
+ self.count_unchanged = 0
+ self.count_added = 0
+ self.count_modified = 0
+
+ try:
+ self._migrate_entries(
+ self.dns, fh=fh, force=False, is_root=True, with_acl=False)
+ except (ReadLDAPItemError, WriteLDAPItemError) as e:
+ msg = "Abort migration: " + str(e)
+ LOG.error(msg)
+ return False
+
+ print()
+ total = self.count_unchanged + self.count_added + self.count_modified
+ msg = (
+ "Performed all entries: {to} total, {ad} added, {mo} modified, "
+ "{un} unchanged.").format(
+ to=total, ad=self.count_added, mo=self.count_modified,
+ un=self.count_unchanged)
+ LOG.info(msg)
+ time.sleep(3)
return True
# -------------------------------------------------------------------------
def write_result_file(self, fh, dn, tag=' '):
ts = datetime.datetime.now(self.tz).isoformat(' ', timespec='seconds')
- line = "{tag}{dn}: {ts}".format(tag=tag, dn=dn, ts=ts)
+ line = "{tag} {dn}: {ts}".format(tag=tag, dn=dn, ts=ts)
print(line, file=fh, flush=True)
# -------------------------------------------------------------------------