]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Discovering integer based attribute types
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 20 Nov 2020 16:28:08 +0000 (17:28 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 20 Nov 2020 16:28:08 +0000 (17:28 +0100)
lib/ldap_migration/__init__.py
lib/ldap_migration/istringset.py

index 85f8f299abe768666cc052e9755697e29e1421db..c5ca22a6f17074968a52f68ffa760fe31ddedfaa 100644 (file)
@@ -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."""
index 302becd88df363e2d5174be471272fc951b24169..55f85b0cfd725a294a3c226b9340c49e8b1f43cc 100644 (file)
@@ -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__":