pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0071-Add-warning-about-only-one-existing-CA-server.patch

403b09
From 7767a6befe2cc461cd6b8aadff1626108e3101b0 Mon Sep 17 00:00:00 2001
403b09
From: Pavel Vomacka <pvomacka@redhat.com>
403b09
Date: Tue, 16 Aug 2016 10:03:36 +0200
403b09
Subject: [PATCH] Add warning about only one existing CA server
403b09
403b09
It is not safe to have only one CA server in topology. Therefore there is a check
403b09
and in case that there is only one CA server a warning is shown. The warning is
403b09
shown after each refreshing of servers facet.
403b09
403b09
https://fedorahosted.org/freeipa/ticket/5828
403b09
403b09
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
403b09
---
403b09
 install/ui/src/freeipa/topology.js | 73 +++++++++++++++++++++++++++++++++++++-
403b09
 install/ui/test/data/ipa_init.json |  2 ++
403b09
 ipaserver/plugins/internal.py      |  2 ++
403b09
 3 files changed, 76 insertions(+), 1 deletion(-)
403b09
403b09
diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js
403b09
index 7e501eb3506587ea653497d2806938890066e4f0..c33adba9a3c704b66b85689dd18e927ab975d2fe 100644
403b09
--- a/install/ui/src/freeipa/topology.js
403b09
+++ b/install/ui/src/freeipa/topology.js
403b09
@@ -28,13 +28,14 @@ define([
403b09
         './facets/Facet',
403b09
         './topology_graph',
403b09
         './navigation',
403b09
+        './widget',
403b09
         // plain imports
403b09
         './search',
403b09
         './entity'],
403b09
             function(lang, declare, Evented, Stateful, Deferred, on, all, when,
403b09
                 builder, IPA, $, menu, metadata_provider, phases, reg, rpc,
403b09
                 text, mod_details, mod_facet, mod_field, ActionMixin,
403b09
-                HeaderMixin, Facet, topology_graph, navigation) {
403b09
+                HeaderMixin, Facet, topology_graph, navigation, widget_mod) {
403b09
 /**
403b09
  * Topology module
403b09
  * @class
403b09
@@ -206,6 +207,7 @@ return {
403b09
     facets: [
403b09
            {
403b09
             $type: 'search',
403b09
+            $factory: topology.servers_search_facet,
403b09
             no_update: true,
403b09
             disable_facet_tabs: false,
403b09
             tabs_in_sidebar: true,
403b09
@@ -483,6 +485,75 @@ topology.location_adapter = declare([mod_field.Adapter], {
403b09
     }
403b09
 });
403b09
 
403b09
+topology.servers_search_facet = function(spec, no_init) {
403b09
+    spec = spec || {};
403b09
+
403b09
+    var that = IPA.search_facet(spec);
403b09
+
403b09
+    that.create_get_records_command = function(pkeys, on_success, on_error) {
403b09
+
403b09
+        var on_success_extended = function(data, text_status, xhr) {
403b09
+            // Call original on_success handler
403b09
+            on_success(data, text_status, xhr);
403b09
+
403b09
+            var result = data.result.results;
403b09
+            var counter = 0;
403b09
+
403b09
+            for (var i=0, l=result.length; i
403b09
+                var current = result[i];
403b09
+                var roles = current.result.enabled_role_servrole;
403b09
+                for (var k=0, m=roles.length; k
403b09
+                    if (roles[k] === 'CA server') counter++;
403b09
+                }
403b09
+            }
403b09
+
403b09
+            // Create dialog and show it only when there is only one CA server
403b09
+            if (counter != 1) return;
403b09
+
403b09
+            var message = text.get('@i18n:objects.servers.ca_warning_message');
403b09
+            var dialog = IPA.dialog({
403b09
+                name: 'ca_warning',
403b09
+                title: '@i18n:objects.servers.ca_warning_title',
403b09
+                sections: [
403b09
+                    {
403b09
+                        show_header: false,
403b09
+                        layout:
403b09
+                        {
403b09
+                            $factory: widget_mod.fluid_layout,
403b09
+                            widget_cls: "col-sm-12 controls",
403b09
+                            label_cls: "hide"
403b09
+                        },
403b09
+                        fields: [
403b09
+                            {
403b09
+                                field: false,
403b09
+                                $type: 'html',
403b09
+                                html: message
403b09
+                            }
403b09
+                        ]
403b09
+                    }
403b09
+                ]
403b09
+            });
403b09
+
403b09
+            dialog.create_button({
403b09
+                name: 'ok',
403b09
+                label: '@i18n:buttons.ok',
403b09
+                click: function() {
403b09
+                    dialog.close();
403b09
+                }
403b09
+            });
403b09
+
403b09
+            dialog.open();
403b09
+        };
403b09
+
403b09
+        var batch = that.table_facet_create_get_records_command(pkeys,
403b09
+                                                on_success_extended, on_error);
403b09
+
403b09
+        return batch;
403b09
+    };
403b09
+
403b09
+    return that;
403b09
+};
403b09
+
403b09
 topology.servers_facet = function(spec, no_init) {
403b09
     spec = spec || {};
403b09
 
403b09
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
403b09
index 77d6fce4e9ca0cf281d89e09f803d6a1a81c6870..efaf6b649296507c3b5b78c96d64db50e087370a 100644
403b09
--- a/install/ui/test/data/ipa_init.json
403b09
+++ b/install/ui/test/data/ipa_init.json
403b09
@@ -552,6 +552,8 @@
403b09
                             "label_singular": "Server Role",
403b09
                         },
403b09
                         "servers": {
403b09
+                            "ca_warning_message": "It is strongly recommended to keep the CA services installed on more than one server.",
403b09
+                            "ca_warning_title": "Warning: Only One CA Server Detected",
403b09
                             "remove_server": "Delete Server",
403b09
                             "remove_server_msg": "Deleting a server removes it permanently from the topology. Note that this is a non-reversible action."
403b09
                         },
403b09
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
403b09
index ff29262180a967b2611db17271a742c5e472a19f..8af0af76c0b6305e9411d5bf4763d80df7304924 100644
403b09
--- a/ipaserver/plugins/internal.py
403b09
+++ b/ipaserver/plugins/internal.py
403b09
@@ -704,6 +704,8 @@ class i18n_messages(Command):
403b09
                 "label_singular": _("Server Role"),
403b09
             },
403b09
             "servers": {
403b09
+                "ca_warning_message": _("It is strongly recommended to keep the CA services installed on more than one server."),
403b09
+                "ca_warning_title": _("Warning: Only One CA Server Detected"),
403b09
                 "remove_server": _("Delete Server"),
403b09
                 "remove_server_msg": _("Deleting a server removes it permanently from the topology. Note that this is a non-reversible action.")
403b09
             },
403b09
-- 
403b09
2.7.4
403b09