Blame SOURCES/bz1421702-01-gui-allow-forcing-resource-stonith-create-update.patch

a3a2ad
From bca125ee785104fbffdcf487b22599e3c9980f06 Mon Sep 17 00:00:00 2001
a3a2ad
From: Tomas Jelinek <tojeline@redhat.com>
a3a2ad
Date: Tue, 5 Dec 2017 15:10:43 +0100
a3a2ad
Subject: [PATCH] gui: allow forcing resource|stonith create|update
a3a2ad
a3a2ad
---
a3a2ad
 pcsd/pcsd.rb           |  3 +++
a3a2ad
 pcsd/public/js/pcsd.js | 39 +++++++++++++++++++++++++--------------
a3a2ad
 pcsd/remote.rb         |  2 +-
a3a2ad
 3 files changed, 29 insertions(+), 15 deletions(-)
a3a2ad
a3a2ad
diff --git a/pcsd/pcsd.rb b/pcsd/pcsd.rb
a3a2ad
index f97dabc..8f5ad81 100644
a3a2ad
--- a/pcsd/pcsd.rb
a3a2ad
+++ b/pcsd/pcsd.rb
a3a2ad
@@ -211,6 +211,9 @@ helpers do
a3a2ad
       if param == "disabled"
a3a2ad
         meta_options << 'meta' << 'target-role=Stopped'
a3a2ad
       end
a3a2ad
+      if param == "force" and val
a3a2ad
+        param_line << "--force"
a3a2ad
+      end
a3a2ad
     }
a3a2ad
     return param_line + meta_options
a3a2ad
   end
a3a2ad
diff --git a/pcsd/public/js/pcsd.js b/pcsd/public/js/pcsd.js
a3a2ad
index b7e9a7a..2956530 100644
a3a2ad
--- a/pcsd/public/js/pcsd.js
a3a2ad
+++ b/pcsd/public/js/pcsd.js
a3a2ad
@@ -286,9 +286,24 @@ function create_node(form) {
a3a2ad
   });
a3a2ad
 }
a3a2ad
 
a3a2ad
+function create_resource_error_processing(error_message, form, update, stonith) {
a3a2ad
+  var message = (
a3a2ad
+    "Unable to " + (update ? "update " : "add ") + name + "\n" + error_message
a3a2ad
+  );
a3a2ad
+  if (message.indexOf('--force') == -1) {
a3a2ad
+    alert(message);
a3a2ad
+  }
a3a2ad
+  else {
a3a2ad
+    message = message.replace(', use --force to override', '');
a3a2ad
+    if (confirm(message + "\n\nDo you want to force the operation?")) {
a3a2ad
+      create_resource(form, update, stonith, true)
a3a2ad
+    }
a3a2ad
+  }
a3a2ad
+}
a3a2ad
+
a3a2ad
 // If update is set to true we update the resource instead of create it
a3a2ad
 // if stonith is set to true we update/create a stonith agent
a3a2ad
-function create_resource(form, update, stonith) {
a3a2ad
+function create_resource(form, update, stonith, force) {
a3a2ad
   var data = {};
a3a2ad
   $($(form).serializeArray()).each(function(index, obj) {
a3a2ad
     data[obj.name] = obj.value;
a3a2ad
@@ -303,6 +318,9 @@ function create_resource(form, update, stonith) {
a3a2ad
   } else {
a3a2ad
     name = "resource";
a3a2ad
   }
a3a2ad
+  if (force) {
a3a2ad
+    data["force"] = force;
a3a2ad
+  }
a3a2ad
 
a3a2ad
   ajax_wrapper({
a3a2ad
     type: "POST",
a3a2ad
@@ -312,7 +330,9 @@ function create_resource(form, update, stonith) {
a3a2ad
     success: function(returnValue) {
a3a2ad
       $('input.apply_changes').show();
a3a2ad
       if (returnValue["error"] == "true") {
a3a2ad
-        alert(returnValue["stderr"]);
a3a2ad
+        create_resource_error_processing(
a3a2ad
+          returnValue["stderr"], form, update, stonith
a3a2ad
+        );
a3a2ad
       } else {
a3a2ad
         Pcs.update();
a3a2ad
         if (!update) {
a3a2ad
@@ -326,18 +346,9 @@ function create_resource(form, update, stonith) {
a3a2ad
       }
a3a2ad
     },
a3a2ad
     error: function(xhr, status, error) {
a3a2ad
-      if (update) {
a3a2ad
-        alert(
a3a2ad
-          "Unable to update " + name + " "
a3a2ad
-          + ajax_simple_error(xhr, status, error)
a3a2ad
-        );
a3a2ad
-      }
a3a2ad
-      else {
a3a2ad
-        alert(
a3a2ad
-          "Unable to add " + name + " "
a3a2ad
-          + ajax_simple_error(xhr, status, error)
a3a2ad
-        );
a3a2ad
-      }
a3a2ad
+      create_resource_error_processing(
a3a2ad
+        ajax_simple_error(xhr, status, error), form, update, stonith
a3a2ad
+      );
a3a2ad
       $('input.apply_changes').show();
a3a2ad
     }
a3a2ad
   });
a3a2ad
diff --git a/pcsd/remote.rb b/pcsd/remote.rb
a3a2ad
index e1e95a8..518e668 100644
a3a2ad
--- a/pcsd/remote.rb
a3a2ad
+++ b/pcsd/remote.rb
a3a2ad
@@ -1494,7 +1494,7 @@ def update_resource (params, request, auth_user)
a3a2ad
       end
a3a2ad
       resource_group = params[:resource_group]
a3a2ad
     end
a3a2ad
-    if params[:resource_type] == "ocf:pacemaker:remote"
a3a2ad
+    if params[:resource_type] == "ocf:pacemaker:remote" and not cmd.include?("--force")
a3a2ad
       # Workaround for Error: this command is not sufficient for create remote
a3a2ad
       # connection, use 'pcs cluster node add-remote', use --force to override.
a3a2ad
       # It is not possible to specify meta attributes so we don't need to take
a3a2ad
-- 
a3a2ad
1.8.3.1
a3a2ad