From: Frank Brehm Date: Thu, 4 Mar 2021 16:30:12 +0000 (+0100) Subject: Adding cmd line parameter to migrate ACIs X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=3089a84761b818579549621d92e562258e4386d7;p=pixelpark%2Fldap-migration.git Adding cmd line parameter to migrate ACIs --- diff --git a/lib/ldap_migration/__init__.py b/lib/ldap_migration/__init__.py index ad70055..ff42a31 100644 --- a/lib/ldap_migration/__init__.py +++ b/lib/ldap_migration/__init__.py @@ -296,6 +296,7 @@ class LDAPMigrationApplication(BaseApplication): self.error_logfile = None self.lap = 0 self.total_count = 0 + self.do_aci = False self.struct_entries = [] self.all_entries = [] @@ -424,6 +425,11 @@ class LDAPMigrationApplication(BaseApplication): help="Migrate only structural entries (entries with childs).", ) + app_group.add_argument( + '-A', '--aci', action="store_true", dest="aci", + help="Migrate also ACI entries.", + ) + app_group.add_argument( '-c', '--config', '--config-file', dest='cfg_file', metavar='FILE', action=CfgFileOptionAction, @@ -605,6 +611,9 @@ class LDAPMigrationApplication(BaseApplication): if self.args.struct: self.only_struct = True + if self.args.aci: + self.do_aci = True + self.initialized = True # ------------------------------------------------------------------------- @@ -1389,7 +1398,7 @@ class LDAPMigrationApplication(BaseApplication): try: self._migrate_entries( self.struct_dns, fh=fh, force=False, is_root=True, - with_group_entries=True, with_acl=True) + with_group_entries=True, with_acl=self.do_aci) except CommonLDAPMigrationError as e: msg = "Abort migration by {c}: {e}".format(c=e.__class__.__name__, e=e) LOG.error(msg) @@ -1425,7 +1434,7 @@ class LDAPMigrationApplication(BaseApplication): for src_dn in self.all_entries: try: if self.migrate_entry( - src_dn, fh=fh, force=False, with_acl=True, migrate_if_group=False): + src_dn, fh=fh, force=False, with_acl=self.do_aci, migrate_if_group=False): if wait: time.sleep(wait) except FatalLDAPMigrationError as e: @@ -1941,8 +1950,8 @@ class LDAPMigrationApplication(BaseApplication): msg = "Migrating group entry {src!r} -> {tgt!r} ...".format(src=src_dn, tgt=tgt_dn) LOG.info(msg) - src_entry = self.get_source_item(src_dn, tgt_dn, with_acl=False) - tgt_entry = self.get_target_item(tgt_dn, with_acl=False) + src_entry = self.get_source_item(src_dn, tgt_dn, with_acl=self.do_aci) + tgt_entry = self.get_target_item(tgt_dn, with_acl=self.do_aci) try: if tgt_entry: