# Own modules
from fb_tools.colored import ColoredFormatter
from fb_tools.errors import IoTimeoutError
-from fb_tools.common import pp
+from fb_tools.common import pp, is_sequence
from fb_tools.app import BaseApplication, DirectoryOptionAction
from fb_tools.config import CfgFileOptionAction
from fb_tools.errors import FbAppError
from .config import LDAPMigrationConfiguration
-__version__ = '0.3.0'
+__version__ = '0.4.0'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
LOG.info("Disconnecting from source server {!r} ...".format(self.config.src_server))
self.src_server = None
+ # -------------------------------------------------------------------------
+ def discover_target_schema(self):
+
+ LOG.info("Discovering target schema ...")
+
+ first = True
+
+ for oid in self.tgt_server.schema.object_classes.keys():
+ 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__))
+ first = False
+ if is_sequence(object_class.name):
+ for oc_name in object_class.name:
+ name_lc = oc_name.lower()
+ oc = {
+ 'single_name': oc_name,
+ 'name': object_class.name,
+ 'oid': object_class.oid,
+ 'description': object_class.description,
+ 'obsolete': object_class.obsolete,
+ 'superior': object_class.superior,
+ 'kind': object_class.kind,
+ 'must_contain': object_class.must_contain,
+ 'may_contain': object_class.may_contain,
+ 'extensions': object_class.extensions,
+ 'experimental': object_class.experimental,
+ 'raw_definition': object_class.raw_definition,
+ }
+ self.object_classes[name_lc] = oc
+ else:
+ name_lc = object_class.name.lower()
+ oc = {
+ 'single_name': object_class.name,
+ 'name': object_class.name,
+ 'oid': object_class.oid,
+ 'description': object_class.description,
+ 'obsolete': object_class.obsolete,
+ 'superior': object_class.superior,
+ 'kind': object_class.kind,
+ 'must_contain': object_class.must_contain,
+ 'may_contain': object_class.may_contain,
+ 'extensions': object_class.extensions,
+ 'experimental': object_class.experimental,
+ 'raw_definition': object_class.raw_definition,
+ }
+
+ if self.verbose > 2:
+ if self.verbose > 3:
+ LOG.debug("Discovered ObjectClasses:\n" + pp(self.object_classes))
+ else:
+ tmp_dict = {}
+ for oc_name in self.object_classes.keys():
+ tmp_dict[oc_name] = self.object_classes[oc_name]['single_name']
+ LOG.debug("Discovered ObjectClasses:\n" + pp(tmp_dict))
+
+
# -------------------------------------------------------------------------
def _run(self):
try:
self.connect_source()
self.connect_target()
+ self.discover_target_schema()
LOG.info("Sleeping ...")
time.sleep(2)
finally: