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