from .idict import CaseInsensitiveDict
from .istringset import CaseInsensitiveStringSet
-__version__ = '0.8.3'
+__version__ = '0.8.4'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
if cur_hash is None:
cur_hash = self.dns
+ if self.verbose > 4:
+ LOG.debug("Trying to register DN {!r} ...".format(dn))
+
iter_hash = cur_hash
tokens = []
for token in reversed(self.re_dn_split.split(dn)):
iter_hash['childs'][token]['childs'] = CaseInsensitiveDict()
iter_hash = iter_hash['childs'][token]
if not len(tokens):
+ if self.verbose > 3:
+ LOG.debug("Registred DN {dn!r} with path {p}.".format(
+ dn=dn, p=tokens_copy))
iter_hash['dn'] = dn
iter_hash['path'] = tokens_copy
iter_hash['object_classes'] = object_classes
}
sfilter = '(objectClass=*)'
attrs = ['objectClass']
+ self.all_entries = []
item_count = 0
new_dn = self.mangle_dn(old_dn)
if self.verbose > 2:
LOG.debug("Found DN {!r}.".format(old_dn))
+ self.all_entries.append(old_dn)
self.register_dn_tokens(old_dn, entry['attributes']['objectClass'], self.dns)
fh.write("{old} => {new}\n".format(old=old_dn, new=new_dn))
if self.limit:
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):
self.count_added = 0
self.count_modified = 0
- try:
- self._migrate_entries(
- self.dns, fh=fh, force=False, is_root=True,
- with_group_entries=False, with_acl=False)
- except (ReadLDAPItemError, WriteLDAPItemError) as e:
- msg = "Abort migration: " + str(e)
- LOG.error(msg)
- return False
+ for src_dn in self.all_entries:
+ try:
+ self.migrate_entry(
+ src_dn, fh=fh, force=False, with_acl=False, migrate_if_group=False)
+ except WriteLDAPItemError as e:
+ msg = "Abort migration: " + str(e)
+ LOG.error(msg)
+ return False
+ except ReadLDAPItemError as e:
+ msg = "Could not get source item: " + str(e)
+ LOG.error(msg)
+ continue
print()
count_groups = 0
return True
return False
- # Both parameters are values
+ # Both parameters are arays
first_array = []
- for val in sorted(first, key=str.lower):
+ for val in first:
first_array.append(str(val).lower())
+ first_array.sort()
second_array = []
- for val in sorted(second, key=str.lower):
+ for val in second:
second_array.append(str(val).lower())
+ second_array.sort()
if first_array == second_array:
return True
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: