711f45
From 2deaaa788cbdde22d5b15566599fdcf7a10f02c6 Mon Sep 17 00:00:00 2001
711f45
From: Florence Blanc-Renaud <flo@redhat.com>
711f45
Date: Feb 02 2023 10:08:26 +0000
711f45
Subject: automember-rebuild: add a notice about high CPU usage
711f45
711f45
711f45
The automember-rebuild task may require high CPU usage
711f45
if many users/hosts/groups are processed.
711f45
Add a note in the ipa automember-rebuild CLI output
711f45
and in the WebUI confirmation message.
711f45
711f45
Fixes: https://pagure.io/freeipa/issue/9320
711f45
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
711f45
Reviewed-By: Francisco Trivino <ftrivino@redhat.com>
711f45
711f45
---
711f45
711f45
diff --git a/install/ui/test/data/i18n_messages.json b/install/ui/test/data/i18n_messages.json
711f45
index 49d2883..5b73548 100644
711f45
--- a/install/ui/test/data/i18n_messages.json
711f45
+++ b/install/ui/test/data/i18n_messages.json
711f45
@@ -7,7 +7,7 @@
711f45
             "actions": {
711f45
                 "apply": "Apply", 
711f45
                 "automember_rebuild": "Rebuild auto membership", 
711f45
-                "automember_rebuild_confirm": "Are you sure you want to rebuild auto membership?", 
711f45
+                "automember_rebuild_confirm": "Are you sure you want to rebuild auto membership? In case of a high number of users, hosts or groups, the operation may require high CPU usage.",
711f45
                 "automember_rebuild_success": "Automember rebuild membership task completed", 
711f45
                 "confirm": "Are you sure you want to proceed with the action?", 
711f45
                 "delete_confirm": "Are you sure you want to delete ${object}?", 
711f45
diff --git a/ipaclient/plugins/automember.py b/ipaclient/plugins/automember.py
711f45
index df4a2e5..7108dc9 100644
711f45
--- a/ipaclient/plugins/automember.py
711f45
+++ b/ipaclient/plugins/automember.py
711f45
@@ -34,3 +34,11 @@ class automember_add_condition(MethodOverride):
711f45
             flags=['suppress_empty'],
711f45
         ),
711f45
     )
711f45
+
711f45
+
711f45
+@register(override=True, no_fail=True)
711f45
+class automember_rebuild(MethodOverride):
711f45
+    def interactive_prompt_callback(self, kw):
711f45
+        msg = _('IMPORTANT: In case of a high number of users, hosts or '
711f45
+                'groups, the operation may require high CPU usage.')
711f45
+        self.Backend.textui.print_plain(msg)
711f45
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
711f45
index 5ffa7a2..e1e920f 100644
711f45
--- a/ipaserver/plugins/internal.py
711f45
+++ b/ipaserver/plugins/internal.py
711f45
@@ -160,7 +160,11 @@ class i18n_messages(Command):
711f45
         "actions": {
711f45
             "apply": _("Apply"),
711f45
             "automember_rebuild": _("Rebuild auto membership"),
711f45
-            "automember_rebuild_confirm": _("Are you sure you want to rebuild auto membership?"),
711f45
+            "automember_rebuild_confirm": _(
711f45
+                "Are you sure you want to rebuild auto membership? In case of "
711f45
+                "a high number of users, hosts or groups, the operation "
711f45
+                "may require high CPU usage."
711f45
+            ),
711f45
             "automember_rebuild_success": _("Automember rebuild membership task completed"),
711f45
             "confirm": _("Are you sure you want to proceed with the action?"),
711f45
             "delete_confirm": _("Are you sure you want to delete ${object}?"),
711f45