From 9acd280093fba90873233535106ccf4bcae652c7 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 20 Nov 2020 17:28:08 +0100 Subject: [PATCH] Discovering integer based attribute types --- lib/ldap_migration/__init__.py | 20 +++++++++++++++++++- lib/ldap_migration/istringset.py | 11 ++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index 85f8f29..c5ca22a 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -36,8 +36,9 @@ from fb_tools.errors import FbAppError from .config import LDAPMigrationConfiguration from .idict import CaseInsensitiveDict +from .istringset import CaseInsensitiveStringSet -__version__ = '0.6.6' +__version__ = '0.6.7' LOG = logging.getLogger(__name__) CFG_BASENAME = 'ldap-migration.ini' @@ -182,6 +183,7 @@ class LDAPMigrationApplication(BaseApplication): self.attribute_types = CaseInsensitiveDict() self.dns = CaseInsensitiveDict() self.struct_dns = CaseInsensitiveDict() + self.integer_attribute_types = CaseInsensitiveStringSet([]) super(LDAPMigrationApplication, self).__init__( appname=appname, verbose=verbose, version=version, base_dir=base_dir, @@ -224,6 +226,7 @@ class LDAPMigrationApplication(BaseApplication): res['cfg_file'] = self.cfg_file res['dns'] = self.dns.as_dict(short=short) res['struct_dns'] = self.struct_dns.as_dict(short=short) + res['integer_attribute_types'] = self.integer_attribute_types.as_list() return res @@ -500,6 +503,7 @@ class LDAPMigrationApplication(BaseApplication): self.discover_target_object_classes() self.discover_target_attribute_types() + self.discover_integer_attribute_types() # ------------------------------------------------------------------------- def discover_target_object_classes(self): @@ -626,6 +630,20 @@ class LDAPMigrationApplication(BaseApplication): else: LOG.debug("Discovered AttributeTypes:\n" + pp(list(self.attribute_types.keys()))) + # ------------------------------------------------------------------------- + def discover_integer_attribute_types(self): + + for key in self.attribute_types.keys(): + attribute_type = self.attribute_types[key] + if not attribute_type['syntax']: + continue + if attribute_type['syntax'] == '1.3.6.1.4.1.1466.115.121.1.27': + self.integer_attribute_types.add(key) + + if self.verbose > 2: + LOG.debug("Discovered Integer AttributeTypes:\n" + pp( + self.integer_attribute_types.as_list())) + # ------------------------------------------------------------------------- def check_tmp_dir(self): """Checking existence of temp-dir and creating it, if necessary.""" diff --git a/lib/ldap_migration/istringset.py b/lib/ldap_migration/istringset.py index 302becd..55f85b0 100644 --- a/lib/ldap_migration/istringset.py +++ b/lib/ldap_migration/istringset.py @@ -21,7 +21,7 @@ except ImportError: # Own modules from fb_tools.errors import FbError -__version__ = '0.1.0' +__version__ = '0.1.1' LOG = logging.getLogger(__name__) @@ -495,6 +495,15 @@ class CaseInsensitiveStringSet(MutableSet): self._items = {} + # ------------------------------------------------------------------------- + def as_list(self): + + ret = [] + for item in self: + ret.append(item) + + return ret + # ============================================================================= if __name__ == "__main__": -- 2.39.5