|
|
71541a |
From 35bb4addbc04e8a8dea26aa2099d852ce084ec14 Mon Sep 17 00:00:00 2001
|
|
|
71541a |
From: Tomas Jelinek <tojeline@redhat.com>
|
|
|
71541a |
Date: Wed, 21 Oct 2015 10:46:17 +0200
|
|
|
71541a |
Subject: [PATCH] fix setting cluster properties in web UI
|
|
|
71541a |
|
|
|
71541a |
- set the properties correctly even if it is not possible to load the
|
|
|
71541a |
properties' current values
|
|
|
71541a |
- do not depend on cluster being imported in pcsd when loading the
|
|
|
71541a |
properties
|
|
|
71541a |
- fix loading default values of cluster properties
|
|
|
71541a |
---
|
|
|
71541a |
pcsd/pcsd.rb | 39 +++++++++++++++-----------------
|
|
|
71541a |
pcsd/remote.rb | 11 ++++++---
|
|
|
71541a |
pcsd/settings.rb | 1 +
|
|
|
71541a |
pcsd/settings.rb.i386-linux-gnu.debian | 1 +
|
|
|
71541a |
pcsd/settings.rb.x86_64-linux-gnu.debian | 1 +
|
|
|
71541a |
5 files changed, 29 insertions(+), 24 deletions(-)
|
|
|
71541a |
|
|
|
71541a |
diff --git a/pcsd/pcsd.rb b/pcsd/pcsd.rb
|
|
|
71541a |
index b7c2a49..c42abb8 100644
|
|
|
71541a |
--- a/pcsd/pcsd.rb
|
|
|
71541a |
+++ b/pcsd/pcsd.rb
|
|
|
71541a |
@@ -573,7 +573,7 @@ if not DISABLE_GUI
|
|
|
71541a |
end
|
|
|
71541a |
@resource_agents = get_resource_agents_avail(session)
|
|
|
71541a |
@stonith_agents = get_stonith_agents_avail(session)
|
|
|
71541a |
- @config_options = getConfigOptions2(session, @cluster_name)
|
|
|
71541a |
+ @config_options = getConfigOptions2(session, @nodes)
|
|
|
71541a |
|
|
|
71541a |
erb :nodes, :layout => :main
|
|
|
71541a |
end
|
|
|
71541a |
@@ -895,7 +895,7 @@ def getLocationDeps(session, cur_node)
|
|
|
71541a |
[deps_allow, deps_disallow]
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
-def getConfigOptions2(session, cluster_name)
|
|
|
71541a |
+def getConfigOptions2(session, cluster_nodes)
|
|
|
71541a |
config_options = {}
|
|
|
71541a |
general_page = []
|
|
|
71541a |
# general_page << ConfigOption.new("Cluster Delay Time", "cluster-delay", "int", 4, "Seconds")
|
|
|
71541a |
@@ -933,7 +933,7 @@ If checked, the cluster will refuse to start resources unless one or more STONIT
|
|
|
71541a |
allconfigoptions = []
|
|
|
71541a |
config_options.each { |i,k| k.each { |j| allconfigoptions << j } }
|
|
|
71541a |
ConfigOption.getDefaultValues(allconfigoptions)
|
|
|
71541a |
- ConfigOption.loadValues(session, allconfigoptions, cluster_name)
|
|
|
71541a |
+ ConfigOption.loadValues(session, allconfigoptions, cluster_nodes)
|
|
|
71541a |
return config_options
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
@@ -1005,16 +1005,8 @@ class ConfigOption
|
|
|
71541a |
@desc = desc
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
- def self.loadValues(session, cos, cluster_name, node_list=nil)
|
|
|
71541a |
- if node_list
|
|
|
71541a |
- code, output = send_nodes_request_with_token(
|
|
|
71541a |
- session, node_list, "get_cib"
|
|
|
71541a |
- )
|
|
|
71541a |
- else
|
|
|
71541a |
- code, output = send_cluster_request_with_token(
|
|
|
71541a |
- session, cluster_name, "get_cib"
|
|
|
71541a |
- )
|
|
|
71541a |
- end
|
|
|
71541a |
+ def self.loadValues(session, cos, node_list)
|
|
|
71541a |
+ code, output = send_nodes_request_with_token(session, node_list, "get_cib")
|
|
|
71541a |
$logger.info(code)
|
|
|
71541a |
if code != 200
|
|
|
71541a |
$logger.info "Error: unable to load cib"
|
|
|
71541a |
@@ -1037,14 +1029,19 @@ class ConfigOption
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
def self.getDefaultValues(cos)
|
|
|
71541a |
- metadata = `#{PENGINE} metadata`
|
|
|
71541a |
- doc = REXML::Document.new(metadata)
|
|
|
71541a |
-
|
|
|
71541a |
- cos.each { |co|
|
|
|
71541a |
- doc.elements.each("resource-agent/parameters/parameter[@name='#{co.configname}']/content") { |e|
|
|
|
71541a |
- co.default = e.attributes["default"]
|
|
|
71541a |
- break
|
|
|
71541a |
- }
|
|
|
71541a |
+ [PENGINE, CIB_BINARY].each { |command|
|
|
|
71541a |
+ metadata = `#{command} metadata`
|
|
|
71541a |
+ begin
|
|
|
71541a |
+ doc = REXML::Document.new(metadata)
|
|
|
71541a |
+ cos.each { |co|
|
|
|
71541a |
+ doc.elements.each("resource-agent/parameters/parameter[@name='#{co.configname}']/content") { |e|
|
|
|
71541a |
+ co.default = e.attributes["default"]
|
|
|
71541a |
+ break
|
|
|
71541a |
+ }
|
|
|
71541a |
+ }
|
|
|
71541a |
+ rescue
|
|
|
71541a |
+ $logger.error("Failed to parse #{command} metadata")
|
|
|
71541a |
+ end
|
|
|
71541a |
}
|
|
|
71541a |
end
|
|
|
71541a |
|
|
|
71541a |
diff --git a/pcsd/remote.rb b/pcsd/remote.rb
|
|
|
71541a |
index e65c8ac..dc90fc9 100644
|
|
|
71541a |
--- a/pcsd/remote.rb
|
|
|
71541a |
+++ b/pcsd/remote.rb
|
|
|
71541a |
@@ -1921,9 +1921,13 @@ def update_cluster_settings(params, request, session)
|
|
|
71541a |
binary_settings = []
|
|
|
71541a |
changed_settings = []
|
|
|
71541a |
old_settings = {}
|
|
|
71541a |
- getConfigOptions2(PCSAuth.getSuperuserSession(), $cluster_name).values().flatten().each { |opt|
|
|
|
71541a |
+ getConfigOptions2(
|
|
|
71541a |
+ PCSAuth.getSuperuserSession(), get_nodes().flatten()
|
|
|
71541a |
+ ).values().flatten().each { |opt|
|
|
|
71541a |
+ binary_settings << opt.configname if "check" == opt.type
|
|
|
71541a |
+ # if we don't know current value of an option, consider it changed
|
|
|
71541a |
+ next if opt.value.nil?
|
|
|
71541a |
if "check" == opt.type
|
|
|
71541a |
- binary_settings << opt.configname
|
|
|
71541a |
old_settings[opt.configname] = is_cib_true(opt.value)
|
|
|
71541a |
else
|
|
|
71541a |
old_settings[opt.configname] = opt.value
|
|
|
71541a |
@@ -1931,6 +1935,7 @@ def update_cluster_settings(params, request, session)
|
|
|
71541a |
}
|
|
|
71541a |
settings.each { |key, val|
|
|
|
71541a |
new_val = binary_settings.include?(key) ? is_cib_true(val) : val
|
|
|
71541a |
+ # if we don't know current value of an option, consider it changed
|
|
|
71541a |
if (not old_settings.key?(key)) or (old_settings[key] != new_val)
|
|
|
71541a |
changed_settings << key.downcase()
|
|
|
71541a |
end
|
|
|
71541a |
@@ -1940,7 +1945,7 @@ def update_cluster_settings(params, request, session)
|
|
|
71541a |
return 403, 'Permission denied'
|
|
|
71541a |
end
|
|
|
71541a |
end
|
|
|
71541a |
- if changed_settings.count { |x| x != 'enable-acl'} > 0
|
|
|
71541a |
+ if changed_settings.count { |x| x != 'enable-acl' } > 0
|
|
|
71541a |
if not allowed_for_local_cluster(session, Permissions::WRITE)
|
|
|
71541a |
return 403, 'Permission denied'
|
|
|
71541a |
end
|
|
|
71541a |
diff --git a/pcsd/settings.rb b/pcsd/settings.rb
|
|
|
71541a |
index 4cea800..ff056a4 100644
|
|
|
71541a |
--- a/pcsd/settings.rb
|
|
|
71541a |
+++ b/pcsd/settings.rb
|
|
|
71541a |
@@ -10,6 +10,7 @@ HEARTBEAT_AGENTS_DIR = "/usr/lib/ocf/resource.d/heartbeat/"
|
|
|
71541a |
PACEMAKER_AGENTS_DIR = "/usr/lib/ocf/resource.d/pacemaker/"
|
|
|
71541a |
NAGIOS_METADATA_DIR = '/usr/share/pacemaker/nagios/plugins-metadata/'
|
|
|
71541a |
PENGINE = "/usr/libexec/pacemaker/pengine"
|
|
|
71541a |
+CIB_BINARY = '/usr/libexec/pacemaker/cib'
|
|
|
71541a |
CRM_MON = "/usr/sbin/crm_mon"
|
|
|
71541a |
CRM_NODE = "/usr/sbin/crm_node"
|
|
|
71541a |
CRM_ATTRIBUTE = "/usr/sbin/crm_attribute"
|
|
|
71541a |
diff --git a/pcsd/settings.rb.i386-linux-gnu.debian b/pcsd/settings.rb.i386-linux-gnu.debian
|
|
|
71541a |
index 6366651..4db23e4 100644
|
|
|
71541a |
--- a/pcsd/settings.rb.i386-linux-gnu.debian
|
|
|
71541a |
+++ b/pcsd/settings.rb.i386-linux-gnu.debian
|
|
|
71541a |
@@ -7,6 +7,7 @@ OCF_ROOT = "/usr/lib/ocf"
|
|
|
71541a |
HEARTBEAT_AGENTS_DIR = "/usr/lib/ocf/resource.d/heartbeat/"
|
|
|
71541a |
PACEMAKER_AGENTS_DIR = "/usr/lib/ocf/resource.d/pacemaker/"
|
|
|
71541a |
PENGINE = "/usr/lib/i386-linux-gnu/pacemaker/pengine"
|
|
|
71541a |
+CIB_BINARY = '/usr/lib/i386-linux-gnu/pacemaker/cib'
|
|
|
71541a |
CRM_NODE = "/usr/sbin/crm_node"
|
|
|
71541a |
CRM_ATTRIBUTE = "/usr/sbin/crm_attribute"
|
|
|
71541a |
COROSYNC_BINARIES = "/usr/sbin/"
|
|
|
71541a |
diff --git a/pcsd/settings.rb.x86_64-linux-gnu.debian b/pcsd/settings.rb.x86_64-linux-gnu.debian
|
|
|
71541a |
index 23a71ab..3f6d5c0 100644
|
|
|
71541a |
--- a/pcsd/settings.rb.x86_64-linux-gnu.debian
|
|
|
71541a |
+++ b/pcsd/settings.rb.x86_64-linux-gnu.debian
|
|
|
71541a |
@@ -7,6 +7,7 @@ OCF_ROOT = "/usr/lib/ocf"
|
|
|
71541a |
HEARTBEAT_AGENTS_DIR = "/usr/lib/ocf/resource.d/heartbeat/"
|
|
|
71541a |
PACEMAKER_AGENTS_DIR = "/usr/lib/ocf/resource.d/pacemaker/"
|
|
|
71541a |
PENGINE = "/usr/lib/x86_64-linux-gnu/pacemaker/pengine"
|
|
|
71541a |
+CIB_BINARY = '/usr/lib/x86_64-linux-gnu/pacemaker/cib'
|
|
|
71541a |
CRM_NODE = "/usr/sbin/crm_node"
|
|
|
71541a |
CRM_ATTRIBUTE = "/usr/sbin/crm_attribute"
|
|
|
71541a |
COROSYNC_BINARIES = "/usr/sbin/"
|
|
|
71541a |
--
|
|
|
71541a |
1.9.1
|
|
|
71541a |
|