# Own modules
from fb_tools.colored import ColoredFormatter
from fb_tools.errors import IoTimeoutError
-from fb_tools.common import pp, is_sequence, human2mbytes
+from fb_tools.common import pp, is_sequence, human2mbytes, to_bool
from fb_tools.app import BaseApplication, DirectoryOptionAction
from fb_tools.config import CfgFileOptionAction
from fb_tools.errors import FbAppError
from .idict import CaseInsensitiveDict
from .istringset import CaseInsensitiveStringSet
-__version__ = '0.8.0'
+__version__ = '0.8.1'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
self._cfg_file = None
self.config = None
+ self._only_struct = False
+
description = "This application migrates a complete LDAP DIT to a new LDAP server. "
description += "During the migration all pointless ObljectClasses and "
description += "Atributes are removed from the entries."
"""Configuration file."""
return self._cfg_file
+ # -------------------------------------------------------------------------
+ @property
+ def only_struct(self):
+ """Flag, whether only structural components should be migrated."""
+ return self._only_struct
+
+ @only_struct.setter
+ def only_struct(self, value):
+ self._only_struct = to_bool(value)
+
# -------------------------------------------------------------------------
def as_dict(self, short=True):
"""
res['attribute_types'] = self.attribute_types.as_dict(short=short)
res['cfg_dir'] = self.cfg_dir
res['cfg_file'] = self.cfg_file
+ res['only_struct'] = self.only_struct
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()
"This option is valid only in simulation mode."),
)
+ app_group.add_argument(
+ '-S', '--struct', '--only-struct', action="store_true", dest="struct",
+ help="Migrate only structural entries (entries with childs).",
+ )
+
app_group.add_argument(
'-c', '--config', '--config-file', dest='cfg_file', metavar='FILE',
action=CfgFileOptionAction,
LOG.warn("Limition should only be done in simulation mode.")
print()
+ if self.args.struct:
+ self.only_struct = True
+
self.initialized = True
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
def migrate_entries(self):
- """The main routine if this application."""
+ """The main routine of this application."""
print()
LOG.info("Migrating all entries from source to target LDAP cluster.")
if not self.migrate_structural_entries(fh):
return False
- if not self.migrate_all_entries(fh):
- return False
+ if not self.only_struct:
+
+ if not self.migrate_all_entries(fh):
+ return False
print()
return True
print()
LOG.info("Migrating all structural entries from source to target LDAP cluster.")
+ print("####################", file=fh, flush=True)
print("# Structural entries", file=fh, flush=True)
print("####################", file=fh, flush=True)
LOG.info("Migrating all entries from source to target LDAP cluster.")
print("", file=fh, flush=True)
+ print("#############", file=fh, flush=True)
print("# All entries", file=fh, flush=True)
print("#############", file=fh, flush=True)