return attr_changes
+ # -------------------------------------------------------------------------
+ def generate_create_entry(self, src_attribs):
+
+ object_classes = []
+ target_entry = {}
+
+ for attrib_name in src_attribs:
+
+ if attrib_name.lower() == 'memberof':
+ if self.verbose > 2:
+ msg = _("Attribute {!r} will not be touched.").format(attrib_name)
+ LOG.debug(msg)
+ continue
+
+ if attrib_name.lower() == 'objectclass':
+ for object_class in sorted(src_attribs[attrib_name], key=str.lower):
+ object_classes.append(object_class)
+ continue
+
+ if not src_attribs[attrib_name]:
+ continue
+
+ target_entry[attrib_name] = []
+ for value in src_attribs[attrib_name]:
+ target_entry[attrib_name].append(value)
+
+ return (object_classes, target_entry)
+
# =============================================================================
if __name__ == "__main__":
# from fb_tools.common import to_bool, is_sequence
# from fb_tools.collections import FrozenCIStringSet, CIStringSet, CIDict
from fb_tools.collections import CIDict, CIStringSet
+from fb_tools.xlate import format_list
from .. import pp
continue
self.src_struct_dns.add(dn)
+ no_total = len(self.src_dns)
+ no_struct = len(self.src_struct_dns)
+ no_non_struct = no_total - no_struct
+
+ msgs = []
+
+ msgs.append(ngettext(
+ "Found total one entry in source LDAP", "Found {no} entries in source LDAP",
+ no_total).format(no=no_total))
+
+ msgs.append(ngettext(
+ "one structural entry in source LDAP", "{no} structural entries in source LDAP",
+ no_struct).format(no=no_struct))
+
+ msgs.append(ngettext(
+ "one non-structural entry in source LDAP.",
+ "{no} non-structural entries in source LDAP.",
+ no_non_struct).format(no=no_non_struct))
+
+ LOG.info(format_list(msgs))
+
if self.verbose > 2:
msg = _("Found structural DNs in instance {!r}:").format(self.src_instance)
LOG.debug(msg + '\n' + pp(self.src_struct_dns.as_list()))
continue
self.tgt_struct_dns_current.add(dn)
+ no_total = len(self.tgt_dns_current)
+ no_struct = len(self.tgt_struct_dns_current)
+ no_non_struct = no_total - no_struct
+
+ msgs = []
+
+ msgs.append(ngettext(
+ "Found total one entry in target LDAP", "Found {no} entries in target LDAP",
+ no_total).format(no=no_total))
+
+ msgs.append(ngettext(
+ "one structural entry in target LDAP", "{no} structural entries in target LDAP",
+ no_struct).format(no=no_struct))
+
+ msgs.append(ngettext(
+ "one non-structural entry in target LDAP.",
+ "{no} non-structural entries in target LDAP.",
+ no_non_struct).format(no=no_non_struct))
+
+ LOG.info(format_list(msgs))
+
if self.verbose > 2:
msg = _("Found structural DNs in instance {!r}:").format(self.tgt_instance)
LOG.debug(msg + '\n' + pp(self.tgt_struct_dns_current.as_list()))
else:
LOG.debug(_("Target entry {!r} not found.").format(dn))
+ (object_classes, target_entry) = self.generate_create_entry(src_attribs)
+ msg = _("Got create data for DN {!r}:").format(dn)
+ msg += '\nobjectClasses:\n' + pp(object_classes)
+ msg += "\nAttributes:\n" + pp(target_entry)
+ LOG.debug(msg)
+ self.mirrored_entries += 1
+ count += 1
if self.limit and self.mirrored_entries >= self.limit:
break