from .idict import CaseInsensitiveDict
from .istringset import CaseInsensitiveStringSet
-__version__ = '0.8.2'
+__version__ = '0.8.3'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
self.all_dns_file = None
self.structural_dns_file = None
self.migrated_file = None
+ self.lap = 0
+ self.total_count = 0
+
+ self.struct_entries = []
+ self.all_entries = []
+ self.group_entries = CaseInsensitiveDict()
self.limit = 0
self.struct_dns = CaseInsensitiveDict()
self.migrated_entries = CaseInsensitiveDict()
self.integer_attribute_types = CaseInsensitiveStringSet([])
- self.group_entries = CaseInsensitiveDict()
super(LDAPMigrationApplication, self).__init__(
appname=appname, verbose=verbose, version=version, base_dir=base_dir,
if self.verbose > 4:
LOG.debug("Registred DN tokens:\n{}".format(pp(self.dns.as_dict())))
+ # -------------------------------------------------------------------------
+ def get_entry_list(self):
+
+ print()
+ LOG.info("Getting an ordered list of all source entries ...")
+
+ self.all_entries = []
+ cur_hash = self.dns
+ self._get_entries(cur_hash)
+
+ # -------------------------------------------------------------------------
+ def _get_entries(cur_hash):
+
+ if 'dn' in cur_hash:
+ self.struct_entries.append(cur_hash['dn'])
+
+ if 'childs' in cur_hash:
+ for key in cur_hash['childs'].keys():
+ self._get_entries(fh, cur_hash['childs'][key])
+
# -------------------------------------------------------------------------
def get_structural_dns(self):
+ print()
LOG.info("Collecting all structural and writing them into {!r} ...".format(
str(self.structural_dns_file)))
with self.migrated_file.open(**open_args) as fh:
+ self.lap = 1
if not self.migrate_structural_entries(fh):
return False
+ self.total_count = 0
+ self.lap = 2
if not self.only_struct:
-
if not self.migrate_all_entries(fh):
return False
with_group_entries=True, with_acl=False):
wait = self.config.wait_after_write
+ point = '<root>'
+
+ self.total_count += 1
+ if self.verbose > 2:
+ LOG.debug("Migrating entry number {} ...".format(self.total_count))
if not is_root:
+ if 'dn' not in cur_hash:
+ msg = "Key 'dn' not found in current hash. Current keys:\n{}".format(
+ pp(cur_hash.keys()))
+ raise KeyError(msg)
+
src_dn = cur_hash['dn']
+ point = src_dn
if self.migrate_entry(
src_dn, fh=fh, force=force, with_acl=with_acl,
migrate_if_group=with_group_entries):
if wait:
time.sleep(wait)
+ if self.verbose > 2:
+ LOG.debug("Migrating childs of {!r} ...".format(point))
for key in cur_hash['childs'].keys():
+ child = cur_hash['childs'][key]
+ if self.lap == 2 and self.total_count > 1 and self.verbose > 2:
+ LOG.debug("Migrating child of key {k!r}:\n{c}".format(
+ k=key, c=pp(child)))
self._migrate_entries(
- cur_hash['childs'][key], fh=fh, force=force, is_root=False,
+ child, fh=fh, force=force, is_root=False,
with_group_entries=with_group_entries, with_acl=with_acl)
# -------------------------------------------------------------------------
self.discover_target_schema()
self.check_tmp_dir()
self.get_all_dns()
+ self.get_entry_list()
self.get_structural_dns()
self.migrate_entries()
if self.verbose > 1: