]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Adding cmd line parameter to migrate ACIs
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 4 Mar 2021 16:30:12 +0000 (17:30 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 4 Mar 2021 16:30:12 +0000 (17:30 +0100)
lib/ldap_migration/__init__.py

index ad7005597cbe297e86233b4e20c1b88d8d2dc371..ff42a31e59ac863bf96268587b5a58a2145429ff 100644 (file)
@@ -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: