|
|
71541a |
From ef01aa872871b8e1ea79058cbe3301ce878dde9a Mon Sep 17 00:00:00 2001
|
|
|
71541a |
From: Ondrej Mular <omular@redhat.com>
|
|
|
71541a |
Date: Tue, 25 Aug 2015 11:44:00 +0200
|
|
|
71541a |
Subject: [PATCH] fix dashboard in web UI
|
|
|
71541a |
|
|
|
71541a |
---
|
|
|
71541a |
pcsd/cluster_entity.rb | 53 +++++++++++++++++++++++++++++-----------
|
|
|
71541a |
pcsd/pcs.rb | 14 ++++++++---
|
|
|
71541a |
pcsd/public/js/nodes-ember.js | 17 ++++++++++---
|
|
|
71541a |
pcsd/public/js/pcsd.js | 38 ++++++++++++++--------------
|
|
|
71541a |
pcsd/remote.rb | 22 +++++++++++++++--
|
|
|
71541a |
pcsd/test/test_cluster_entity.rb | 4 +--
|
|
|
71541a |
pcsd/views/_resource.erb | 20 +++++++--------
|
|
|
71541a |
pcsd/views/main.erb | 4 +++
|
|
|
71541a |
8 files changed, 117 insertions(+), 55 deletions(-)
|
|
|
71541a |
|
|
|
71541a |
diff --git a/pcsd/cluster_entity.rb b/pcsd/cluster_entity.rb
|
|
|
71541a |
index b291937..78bc5ab 100644
|
|
|
71541a |
--- a/pcsd/cluster_entity.rb
|
|
|
71541a |
+++ b/pcsd/cluster_entity.rb
|
|
|
71541a |
@@ -112,6 +112,9 @@ module ClusterEntity
|
|
|
71541a |
status.node = node
|
|
|
71541a |
primitive.crm_status << status
|
|
|
71541a |
}
|
|
|
71541a |
+ primitives.each {|_, resource|
|
|
|
71541a |
+ resource[0].update_status
|
|
|
71541a |
+ }
|
|
|
71541a |
return primitives
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
@@ -178,6 +181,9 @@ module ClusterEntity
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
}
|
|
|
71541a |
+ tree.each {|resource|
|
|
|
71541a |
+ resource.update_status
|
|
|
71541a |
+ }
|
|
|
71541a |
return tree
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
@@ -491,23 +497,27 @@ module ClusterEntity
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
+ def update_status
|
|
|
71541a |
+ @status = get_status
|
|
|
71541a |
+ end
|
|
|
71541a |
+
|
|
|
71541a |
def get_status
|
|
|
71541a |
- count = @crm_status.length
|
|
|
71541a |
running = 0
|
|
|
71541a |
+ failed = 0
|
|
|
71541a |
@crm_status.each do |s|
|
|
|
71541a |
- if ['Started', 'Master', 'Slave'].include?(s.role)
|
|
|
71541a |
+ if s.active
|
|
|
71541a |
running += 1
|
|
|
71541a |
+ elsif s.failed
|
|
|
71541a |
+ failed += 1
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
if disabled?
|
|
|
71541a |
status = ClusterEntity::ResourceStatus.new(:disabled)
|
|
|
71541a |
- elsif running != 0
|
|
|
71541a |
- if running == count
|
|
|
71541a |
- status = ClusterEntity::ResourceStatus.new(:running)
|
|
|
71541a |
- else
|
|
|
71541a |
- status = ClusterEntity::ResourceStatus.new(:partially_running)
|
|
|
71541a |
- end
|
|
|
71541a |
+ elsif running > 0
|
|
|
71541a |
+ status = ClusterEntity::ResourceStatus.new(:running)
|
|
|
71541a |
+ elsif failed > 0
|
|
|
71541a |
+ status = ClusterEntity::ResourceStatus.new(:failed)
|
|
|
71541a |
else
|
|
|
71541a |
status = ClusterEntity::ResourceStatus.new(:blocked)
|
|
|
71541a |
end
|
|
|
71541a |
@@ -655,6 +665,14 @@ module ClusterEntity
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
+ def update_status
|
|
|
71541a |
+ @status = ClusterEntity::ResourceStatus.new(:running)
|
|
|
71541a |
+ @members.each { |p|
|
|
|
71541a |
+ p.update_status
|
|
|
71541a |
+ @status = p.status if @status < p.status
|
|
|
71541a |
+ }
|
|
|
71541a |
+ end
|
|
|
71541a |
+
|
|
|
71541a |
def to_status(version='1')
|
|
|
71541a |
if version == '2'
|
|
|
71541a |
hash = super(version)
|
|
|
71541a |
@@ -730,6 +748,13 @@ module ClusterEntity
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
+ def update_status
|
|
|
71541a |
+ if @member
|
|
|
71541a |
+ @member.update_status
|
|
|
71541a |
+ @status = @member.status
|
|
|
71541a |
+ end
|
|
|
71541a |
+ end
|
|
|
71541a |
+
|
|
|
71541a |
def to_status(version='1')
|
|
|
71541a |
if version == '2'
|
|
|
71541a |
hash = super(version)
|
|
|
71541a |
@@ -794,13 +819,13 @@ module ClusterEntity
|
|
|
71541a |
primitive_list = @member.members
|
|
|
71541a |
end
|
|
|
71541a |
@masters, @slaves = get_masters_slaves(primitive_list)
|
|
|
71541a |
- end
|
|
|
71541a |
- if @masters.empty?
|
|
|
71541a |
- @error_list << {
|
|
|
71541a |
- :message => 'Resource is master/slave but has not been promoted '\
|
|
|
71541a |
+ if @masters.empty?
|
|
|
71541a |
+ @error_list << {
|
|
|
71541a |
+ :message => 'Resource is master/slave but has not been promoted '\
|
|
|
71541a |
+ 'to master on any node.',
|
|
|
71541a |
- :type => 'no_master'
|
|
|
71541a |
- }
|
|
|
71541a |
+ :type => 'no_master'
|
|
|
71541a |
+ }
|
|
|
71541a |
+ end
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb
|
|
|
71541a |
index 1fe9b99..cc5b038 100644
|
|
|
71541a |
--- a/pcsd/pcs.rb
|
|
|
71541a |
+++ b/pcsd/pcs.rb
|
|
|
71541a |
@@ -1506,10 +1506,18 @@ def cluster_status_from_nodes(session, cluster_nodes, cluster_name)
|
|
|
71541a |
status = overview.update(cluster_nodes_map[quorate_nodes[0]])
|
|
|
71541a |
status[:quorate] = true
|
|
|
71541a |
status[:node_list] = node_status_list
|
|
|
71541a |
- # if we don't have quorum, use data from any node
|
|
|
71541a |
- # no node has quorum, so no node has any info about the cluster
|
|
|
71541a |
+ # if we don't have quorum, use data from any online node,
|
|
|
71541a |
+ # otherwise use data from any node no node has quorum, so no node has any
|
|
|
71541a |
+ # info about the cluster
|
|
|
71541a |
elsif not old_status
|
|
|
71541a |
- status = overview.update(cluster_nodes_map.values[0])
|
|
|
71541a |
+ node_to_use = cluster_nodes_map.values[0]
|
|
|
71541a |
+ cluster_nodes_map.each { |_, node_data|
|
|
|
71541a |
+ if node_data[:node] and node_data[:node][:status] == 'online'
|
|
|
71541a |
+ node_to_use = node_data
|
|
|
71541a |
+ break
|
|
|
71541a |
+ end
|
|
|
71541a |
+ }
|
|
|
71541a |
+ status = overview.update(node_to_use)
|
|
|
71541a |
status[:quorate] = false
|
|
|
71541a |
status[:node_list] = node_status_list
|
|
|
71541a |
# old pcsd doesn't provide info about quorum, use data from any node
|
|
|
71541a |
diff --git a/pcsd/public/js/nodes-ember.js b/pcsd/public/js/nodes-ember.js
|
|
|
71541a |
index 1f60adc..172c00a 100644
|
|
|
71541a |
--- a/pcsd/public/js/nodes-ember.js
|
|
|
71541a |
+++ b/pcsd/public/js/nodes-ember.js
|
|
|
71541a |
@@ -54,7 +54,8 @@ Pcs = Ember.Application.createWithMixins({
|
|
|
71541a |
if (window.location.pathname.lastIndexOf('/manage', 0) !== 0) {
|
|
|
71541a |
return;
|
|
|
71541a |
}
|
|
|
71541a |
- clearTimeout(Pcs.update_timeout);
|
|
|
71541a |
+ clearTimeout(Pcs.get('update_timeout'));
|
|
|
71541a |
+ Pcs.set('update_timeout', null);
|
|
|
71541a |
var self = Pcs;
|
|
|
71541a |
var cluster_name = self.cluster_name;
|
|
|
71541a |
if (cluster_name == null) {
|
|
|
71541a |
@@ -77,7 +78,7 @@ Pcs = Ember.Application.createWithMixins({
|
|
|
71541a |
if (data["not_current_data"]) {
|
|
|
71541a |
self.update();
|
|
|
71541a |
} else {
|
|
|
71541a |
- Pcs.update_timeout = window.setTimeout(self.update, 20000);
|
|
|
71541a |
+ Pcs.set('update_timeout', window.setTimeout(self.update,20000));
|
|
|
71541a |
}
|
|
|
71541a |
hide_loading_screen();
|
|
|
71541a |
},
|
|
|
71541a |
@@ -92,7 +93,7 @@ Pcs = Ember.Application.createWithMixins({
|
|
|
71541a |
console.log("Error: Unable to parse json for clusters_overview");
|
|
|
71541a |
}
|
|
|
71541a |
}
|
|
|
71541a |
- Pcs.update_timeout = window.setTimeout(self.update,20000);
|
|
|
71541a |
+ Pcs.set('update_timeout', window.setTimeout(self.update,20000));
|
|
|
71541a |
hide_loading_screen();
|
|
|
71541a |
}
|
|
|
71541a |
});
|
|
|
71541a |
@@ -126,6 +127,7 @@ Pcs = Ember.Application.createWithMixins({
|
|
|
71541a |
var cur_resource = self.get('cur_resource');
|
|
|
71541a |
var resource_map = self.get('resource_map');
|
|
|
71541a |
if (first_run) {
|
|
|
71541a |
+ setup_node_links();
|
|
|
71541a |
Pcs.nodesController.load_node($('#node_list_row').find('.node_selected').first(),true);
|
|
|
71541a |
Pcs.aclsController.load_role($('#acls_list_row').find('.node_selected').first(), true);
|
|
|
71541a |
if (self.get("fence_id_to_load")) {
|
|
|
71541a |
@@ -173,7 +175,6 @@ Pcs = Ember.Application.createWithMixins({
|
|
|
71541a |
if (!resource_change && self.get('cur_resource'))
|
|
|
71541a |
tree_view_select(self.get('cur_resource').get('id'));
|
|
|
71541a |
Pcs.selectedNodeController.reset();
|
|
|
71541a |
- setup_node_links();
|
|
|
71541a |
disable_checkbox_clicks();
|
|
|
71541a |
});
|
|
|
71541a |
});
|
|
|
71541a |
@@ -207,6 +208,7 @@ Pcs.resourcesContainer = Ember.Object.create({
|
|
|
71541a |
cur_fence: null,
|
|
|
71541a |
constraints: {},
|
|
|
71541a |
group_list: [],
|
|
|
71541a |
+ data_version: null,
|
|
|
71541a |
|
|
|
71541a |
get_resource_by_id: function(resource_id) {
|
|
|
71541a |
var resource_map = this.get('resource_map');
|
|
|
71541a |
@@ -434,6 +436,7 @@ Pcs.resourcesContainer = Ember.Object.create({
|
|
|
71541a |
update: function(data) {
|
|
|
71541a |
var self = this;
|
|
|
71541a |
self.set('group_list', data['groups']);
|
|
|
71541a |
+ self.set("data_version", data['status_version']);
|
|
|
71541a |
var resources = data["resource_list"];
|
|
|
71541a |
var resource_obj = null;
|
|
|
71541a |
var resource_id;
|
|
|
71541a |
@@ -495,6 +498,12 @@ Pcs.resourcesContainer = Ember.Object.create({
|
|
|
71541a |
}
|
|
|
71541a |
});
|
|
|
71541a |
|
|
|
71541a |
+Pcs.resourcesContainer.reopen({
|
|
|
71541a |
+ is_version_1: function() {
|
|
|
71541a |
+ return (this.get("data_version") == '1');
|
|
|
71541a |
+ }.property('data_version')
|
|
|
71541a |
+});
|
|
|
71541a |
+
|
|
|
71541a |
Pcs.ResourceObj = Ember.Object.extend({
|
|
|
71541a |
id: null,
|
|
|
71541a |
_id: Ember.computed.alias('id'),
|
|
|
71541a |
diff --git a/pcsd/public/js/pcsd.js b/pcsd/public/js/pcsd.js
|
|
|
71541a |
index 9891aa8..2c71e6b 100644
|
|
|
71541a |
--- a/pcsd/public/js/pcsd.js
|
|
|
71541a |
+++ b/pcsd/public/js/pcsd.js
|
|
|
71541a |
@@ -1242,26 +1242,24 @@ function destroy_tooltips() {
|
|
|
71541a |
}
|
|
|
71541a |
|
|
|
71541a |
function remove_cluster(ids) {
|
|
|
71541a |
- for (var i=0; i
|
|
|
71541a |
- var cluster = ids[i];
|
|
|
71541a |
- var clusterid_name = "clusterid-"+ids[i];
|
|
|
71541a |
- var data = {}
|
|
|
71541a |
- data[clusterid_name] = true;
|
|
|
71541a |
- $.ajax({
|
|
|
71541a |
- type: 'POST',
|
|
|
71541a |
- url: '/manage/removecluster',
|
|
|
71541a |
- data: data,
|
|
|
71541a |
- timeout: pcs_timeout,
|
|
|
71541a |
- success: function () {
|
|
|
71541a |
- $("#dialog_verify_remove_clusters.ui-dialog-content").each(function(key, item) {$(item).dialog("destroy")});
|
|
|
71541a |
- location.reload();
|
|
|
71541a |
- },
|
|
|
71541a |
- error: function (xhr, status, error) {
|
|
|
71541a |
- alert("Unable to remove cluster: " + res + " ("+error+")");
|
|
|
71541a |
- $("#dialog_verify_remove_clusters.ui-dialog-content").each(function(key, item) {$(item).dialog("destroy")});
|
|
|
71541a |
- }
|
|
|
71541a |
- });
|
|
|
71541a |
- }
|
|
|
71541a |
+ var data = {};
|
|
|
71541a |
+ $.each(ids, function(_, cluster) {
|
|
|
71541a |
+ data[ "clusterid-" + cluster] = true;
|
|
|
71541a |
+ });
|
|
|
71541a |
+ $.ajax({
|
|
|
71541a |
+ type: 'POST',
|
|
|
71541a |
+ url: '/manage/removecluster',
|
|
|
71541a |
+ data: data,
|
|
|
71541a |
+ timeout: pcs_timeout,
|
|
|
71541a |
+ success: function () {
|
|
|
71541a |
+ $("#dialog_verify_remove_clusters.ui-dialog-content").each(function(key, item) {$(item).dialog("destroy")});
|
|
|
71541a |
+ location.reload();
|
|
|
71541a |
+ },
|
|
|
71541a |
+ error: function (xhr, status, error) {
|
|
|
71541a |
+ alert("Unable to remove cluster: " + res + " ("+error+")");
|
|
|
71541a |
+ $("#dialog_verify_remove_clusters.ui-dialog-content").each(function(key, item) {$(item).dialog("destroy")});
|
|
|
71541a |
+ }
|
|
|
71541a |
+ });
|
|
|
71541a |
}
|
|
|
71541a |
|
|
|
71541a |
function remove_nodes(ids, force) {
|
|
|
71541a |
diff --git a/pcsd/remote.rb b/pcsd/remote.rb
|
|
|
71541a |
index a40c1c7..06947ec 100644
|
|
|
71541a |
--- a/pcsd/remote.rb
|
|
|
71541a |
+++ b/pcsd/remote.rb
|
|
|
71541a |
@@ -2,6 +2,7 @@ require 'json'
|
|
|
71541a |
require 'uri'
|
|
|
71541a |
require 'open4'
|
|
|
71541a |
require 'set'
|
|
|
71541a |
+require 'timeout'
|
|
|
71541a |
|
|
|
71541a |
require 'pcs.rb'
|
|
|
71541a |
require 'resource.rb'
|
|
|
71541a |
@@ -1120,6 +1121,16 @@ def clusters_overview(params, request, session)
|
|
|
71541a |
config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text())
|
|
|
71541a |
config.clusters.each { |cluster|
|
|
|
71541a |
threads << Thread.new {
|
|
|
71541a |
+ cluster_map[cluster.name] = {
|
|
|
71541a |
+ 'cluster_name' => cluster.name,
|
|
|
71541a |
+ 'error_list' => [
|
|
|
71541a |
+ {'message' => 'Unable to connect to the cluster. Request timeout.'}
|
|
|
71541a |
+ ],
|
|
|
71541a |
+ 'warning_list' => [],
|
|
|
71541a |
+ 'status' => 'unknown',
|
|
|
71541a |
+ 'node_list' => get_default_overview_node_list(cluster.name),
|
|
|
71541a |
+ 'resource_list' => []
|
|
|
71541a |
+ }
|
|
|
71541a |
overview_cluster = nil
|
|
|
71541a |
online, offline, not_authorized_nodes = check_gui_status_of_nodes(
|
|
|
71541a |
session,
|
|
|
71541a |
@@ -1134,7 +1145,7 @@ def clusters_overview(params, request, session)
|
|
|
71541a |
nodes_not_in_cluster = []
|
|
|
71541a |
for node in cluster_nodes_auth
|
|
|
71541a |
code, response = send_request_with_token(
|
|
|
71541a |
- session, node, 'cluster_status', true, {}, true, nil, 15
|
|
|
71541a |
+ session, node, 'cluster_status', true, {}, true, nil, 8
|
|
|
71541a |
)
|
|
|
71541a |
if code == 404
|
|
|
71541a |
not_supported = true
|
|
|
71541a |
@@ -1228,7 +1239,14 @@ def clusters_overview(params, request, session)
|
|
|
71541a |
cluster_map[cluster.name] = overview_cluster
|
|
|
71541a |
}
|
|
|
71541a |
}
|
|
|
71541a |
- threads.each { |t| t.join }
|
|
|
71541a |
+
|
|
|
71541a |
+ begin
|
|
|
71541a |
+ Timeout::timeout(18) {
|
|
|
71541a |
+ threads.each { |t| t.join }
|
|
|
71541a |
+ }
|
|
|
71541a |
+ rescue Timeout::Error
|
|
|
71541a |
+ threads.each { |t| t.exit }
|
|
|
71541a |
+ end
|
|
|
71541a |
|
|
|
71541a |
# update clusters in PCSConfig
|
|
|
71541a |
not_current_data = false
|
|
|
71541a |
diff --git a/pcsd/views/_resource.erb b/pcsd/views/_resource.erb
|
|
|
71541a |
index 862b648..cc4c06e 100644
|
|
|
71541a |
--- a/pcsd/views/_resource.erb
|
|
|
71541a |
+++ b/pcsd/views/_resource.erb
|
|
|
71541a |
@@ -32,16 +32,16 @@
|
|
|
71541a |
|
|
|
71541a |
<%= erb :_resource_list %>
|
|
|
71541a |
|
|
|
71541a |
-
|
|
|
71541a |
-
|
|
|
71541a |
- <% if @myView == "resource" %>
|
|
|
71541a |
- {{resource-edit resource=Pcs.resourcesContainer.cur_resource page_name="Resource"}}
|
|
|
71541a |
- <% else %>
|
|
|
71541a |
- {{resource-edit resource=Pcs.resourcesContainer.cur_fence page_name="Fence device" stonith=1}}
|
|
|
71541a |
- <% end %>
|
|
|
71541a |
-
|
|
|
71541a |
-
|
|
|
71541a |
-
|
|
|
71541a |
+
|
|
|
71541a |
+
|
|
|
71541a |
+ <% if @myView == "resource" %>
|
|
|
71541a |
+ {{resource-edit resource=Pcs.resourcesContainer.cur_resource page_name="Resource" old_pcsd=Pcs.resourcesContainer.is_version_1}}
|
|
|
71541a |
+ <% else %>
|
|
|
71541a |
+ {{resource-edit resource=Pcs.resourcesContainer.cur_fence page_name="Fence device" stonith=1 old_pcsd=Pcs.resourcesContainer.is_version_1}}
|
|
|
71541a |
+ <% end %>
|
|
|
71541a |
+
|
|
|
71541a |
+
|
|
|
71541a |
+
|
|
|
71541a |
<% if @myView == "resource" %>
|
|
|
71541a |
|
|
|
71541a |
|
|
|
71541a |
diff --git a/pcsd/views/main.erb b/pcsd/views/main.erb
|
|
|
71541a |
index 3c1e0cd..bb4e989 100644
|
|
|
71541a |
--- a/pcsd/views/main.erb
|
|
|
71541a |
+++ b/pcsd/views/main.erb
|
|
|
71541a |
@@ -197,6 +197,7 @@
|
|
|
71541a |
Current Location:
|
|
|
71541a |
{{resource.nodes_running_on_string}}
|
|
|
71541a |
|
|
|
71541a |
+ {{#unless old_pcsd}}
|
|
|
71541a |
{{#unless resource.parent}}
|
|
|
71541a |
|
|
|
71541a |
Clone:
|
|
|
71541a |
@@ -226,8 +227,10 @@
|
|
|
71541a |
|
|
|
71541a |
{{/if}}
|
|
|
71541a |
{{/unless}}
|
|
|
71541a |
+ {{/unless}}
|
|
|
71541a |
{{/if}}
|
|
|
71541a |
{{/unless}}
|
|
|
71541a |
+ {{#unless old_pcsd}}
|
|
|
71541a |
{{#if resource.is_group}}
|
|
|
71541a |
{{#unless resource.parent}}
|
|
|
71541a |
|
|
|
71541a |
@@ -258,6 +261,7 @@
|
|
|
71541a |
|
|
|
71541a |
|
|
|
71541a |
{{/if}}
|
|
|
71541a |
+ {{/unless}}
|
|
|
71541a |
|
|
|
71541a |
{{#unless resource.stonith}}
|
|
|
71541a |
{{location_constraints-table constraints=resource.location_constraints}}
|
|
|
71541a |
--
|
|
|
71541a |
1.9.1
|
|
|
71541a |
|