From: Frank Brehm Date: Fri, 13 Nov 2020 10:19:59 +0000 (+0100) Subject: Discovering AttributeTypes of target server X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=ee4528183f092648f1bccb0ff80cf5d83cc5a8fd;p=pixelpark%2Fldap-migration.git Discovering AttributeTypes of target server --- diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index 8806c27..b24da97 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -342,13 +342,21 @@ class LDAPMigrationApplication(BaseApplication): LOG.info("Discovering target schema ...") + self.discover_target_object_classes() + self.discover_target_attribute_types() + + # ------------------------------------------------------------------------- + def discover_target_object_classes(self): + + LOG.debug("Discovering target object classes ...") + first = True for oid in self.tgt_server.schema.object_classes.keys(): - object_class =self.tgt_server.schema.object_classes[oid] + object_class = self.tgt_server.schema.object_classes[oid] if first: if self.verbose > 2: - LOG.debug("iFirst ObjectClass-Object:\n" + pp(object_class.__dict__)) + LOG.debug("First ObjectClass-Object:\n" + pp(object_class.__dict__)) first = False if is_sequence(object_class.name): for oc_name in object_class.name: @@ -384,7 +392,9 @@ class LDAPMigrationApplication(BaseApplication): 'experimental': object_class.experimental, 'raw_definition': object_class.raw_definition, } + self.object_classes[name_lc] = oc + LOG.debug("Found {} ObjectClasses.".format(len(self.object_classes.keys()))) if self.verbose > 2: if self.verbose > 3: LOG.debug("Discovered ObjectClasses:\n" + pp(self.object_classes)) @@ -394,6 +404,83 @@ class LDAPMigrationApplication(BaseApplication): tmp_dict[oc_name] = self.object_classes[oc_name]['single_name'] LOG.debug("Discovered ObjectClasses:\n" + pp(tmp_dict)) + # ------------------------------------------------------------------------- + def discover_target_attribute_types(self): + + LOG.debug("Discovering target attribute types ...") + + first = True + + for oid in self.tgt_server.schema.attribute_types.keys(): + + atype = self.tgt_server.schema.attribute_types[oid] + + if first: + if self.verbose > 2: + LOG.debug("First Attribute_Type-Object:\n" + pp(atype.__dict__)) + first = False + + if is_sequence(atype.name): + for at_name in atype.name: + name_lc = at_name.lower() + at = { + 'single_name': at_name, + 'name': atype.name, + 'oid': atype.oid, + 'description': atype.description, + 'obsolete': atype.obsolete, + 'superior': atype.superior, + 'collective': atype.collective, + 'equality': atype.equality, + 'experimental': atype.experimental, + 'extensions': atype.extensions, + 'mandatory_in': atype.mandatory_in, + 'min_length': atype.min_length, + 'no_user_modification': atype.no_user_modification, + 'optional_in': atype.optional_in, + 'ordering': atype.ordering, + 'raw_definition': atype.raw_definition, + 'single_value': atype.single_value, + 'substring': atype.substring, + 'syntax': atype.syntax, + 'usage': atype.usage, + } + self.attribute_types[name_lc] = at + else: + name_lc = atype.name.lower() + at = { + 'single_name': atype.name, + 'name': atype.name, + 'oid': atype.oid, + 'description': atype.description, + 'obsolete': atype.obsolete, + 'superior': atype.superior, + 'collective': atype.collective, + 'equality': atype.equality, + 'experimental': atype.experimental, + 'extensions': atype.extensions, + 'mandatory_in': atype.mandatory_in, + 'min_length': atype.min_length, + 'no_user_modification': atype.no_user_modification, + 'optional_in': atype.optional_in, + 'ordering': atype.ordering, + 'raw_definition': atype.raw_definition, + 'single_value': atype.single_value, + 'substring': atype.substring, + 'syntax': atype.syntax, + 'usage': atype.usage, + } + self.attribute_types[name_lc] = at + + LOG.debug("Found {} AttributeTypes.".format(len(self.attribute_types.keys()))) + if self.verbose > 2: + if self.verbose > 3: + LOG.debug("Discovered AttributeTypes:\n" + pp(self.attribute_types)) + else: + tmp_dict = {} + for name_lc in self.attribute_types.keys(): + tmp_dict[name_lc] = self.attribute_types[name_lc]['single_name'] + LOG.debug("Discovered AttributeTypes:\n" + pp(tmp_dict)) # ------------------------------------------------------------------------- def _run(self):