Refer to "Fencing agent", not "STONITH plugin"

This is the recommendation from HA people.
This commit is contained in:
Vincent Untz 2014-03-28 14:15:04 +01:00
parent ab21bdf3a8
commit dd48572ffe
3 changed files with 24 additions and 24 deletions

View File

@ -37,7 +37,7 @@ default[:pacemaker][:crm][:no_quorum_policy] = "ignore"
# Values can be "disabled", "manual", "shared", "per_node"
default[:pacemaker][:stonith][:mode] = "disabled"
default[:pacemaker][:stonith][:shared][:plugin] = ""
default[:pacemaker][:stonith][:shared][:agent] = ""
# This can be either a string (containing a list of parameters) or a hash.
# For instance:
# default[:pacemaker][:stonith][:shared][:params] = 'hostname="foo" password="bar"'
@ -45,7 +45,7 @@ default[:pacemaker][:stonith][:shared][:plugin] = ""
# default[:pacemaker][:stonith][:shared][:params] = {"hostname" => "foo", "password" => "bar"}
default[:pacemaker][:stonith][:shared][:params] = {}
default[:pacemaker][:stonith][:per_node][:plugin] = ""
default[:pacemaker][:stonith][:per_node][:agent] = ""
# This can be "all" or "self":
# - if set to "all", then every node will configure the stonith resources for
# all nodes in the cluster

View File

@ -1,24 +1,24 @@
module PacemakerStonithHelper
@@stonith_plugins = nil
@@stonith_agents = nil
def self.stonith_plugin_valid?(plugin)
if plugin.nil? || plugin.empty?
def self.stonith_agent_valid?(agent)
if agent.nil? || agent.empty?
false
else
if @@stonith_plugins.nil?
if @@stonith_agents.nil?
out = %x{stonith -L}
if $?.success?
@@stonith_plugins = out.split("\n")
@@stonith_agents = out.split("\n")
end
end
!@@stonith_plugins.nil? && @@stonith_plugins.include?(plugin)
!@@stonith_agents.nil? && @@stonith_agents.include?(agent)
end
end
def self.assert_stonith_plugin_valid(plugin)
unless stonith_plugin_valid? plugin
raise "STONITH plugin #{plugin} is not available!"
def self.assert_stonith_agent_valid(agent)
unless stonith_agent_valid? agent
raise "STONITH fencing agent #{agent} is not available!"
end
end
end

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
# FIXME: delete old resources when switching mode (or plugin!)
# FIXME: delete old resources when switching mode (or agent!)
case node[:pacemaker][:stonith][:mode]
when "disabled"
@ -26,14 +26,14 @@ when "manual"
# nothing!
when "shared"
plugin = node[:pacemaker][:stonith][:shared][:plugin]
agent = node[:pacemaker][:stonith][:shared][:agent]
params = node[:pacemaker][:stonith][:shared][:params]
# This needs to be done in the second phase of chef, because we need
# cluster-glue to be installed first; hence ruby_block
ruby_block "Check if STONITH #{plugin} is available" do
ruby_block "Check if STONITH fencing agent #{agent} is available" do
block do
PacemakerStonithHelper.assert_stonith_plugin_valid plugin
PacemakerStonithHelper.assert_stonith_agent_valid agent
end
end
@ -42,31 +42,31 @@ when "shared"
elsif params.is_a?(String)
primitive_params = ::Pacemaker::Resource.extract_hash("params #{params}", "params")
else
message = "Unknown format for STONITH shared parameters: #{params.inspect}."
message = "Unknown format for shared fencing agent parameters: #{params.inspect}."
Chef::Log.fatal(message)
raise message
end
unless primitive_params.has_key?("hostlist")
message = "Missing hostlist parameter for STONITH shared!"
message = "Missing hostlist parameter for shared fencing agent!"
Chef::Log.fatal(message)
raise message
end
pacemaker_primitive "fencing" do
agent "stonith:#{plugin}"
agent "stonith:#{agent}"
params primitive_params
action :create
end
when "per_node"
plugin = node[:pacemaker][:stonith][:per_node][:plugin]
agent = node[:pacemaker][:stonith][:per_node][:agent]
# This needs to be done in the second phase of chef, because we need
# cluster-glue to be installed first; hence ruby_block
ruby_block "Check if STONITH #{plugin} is available" do
ruby_block "Check if STONITH fencing agent #{agent} is available" do
block do
PacemakerStonithHelper.assert_stonith_plugin_valid plugin
PacemakerStonithHelper.assert_stonith_agent_valid agent
end
end
@ -83,20 +83,20 @@ when "per_node"
elsif params.is_a?(String)
primitive_params = ::Pacemaker::Resource.extract_hash("params #{params}", "params")
else
message = "Unknown format for STONITH per-node parameters of #{node_name}: #{params.inspect}."
message = "Unknown format for per-node fencing agent parameters of #{node_name}: #{params.inspect}."
Chef::Log.fatal(message)
raise message
end
# Only set one of hostname / hostlist param if none of them are present; we
# do not overwrite it as the user might have passed more information than
# just the hostname (some plugins accept hostname:data in hostlist)
# just the hostname (some agents accept hostname:data in hostlist)
unless primitive_params.has_key?("hostname") || primitive_params.has_key?("hostlist")
primitive_params["hostname"] = node_name
end
pacemaker_primitive stonith_resource do
agent "stonith:#{plugin}"
agent "stonith:#{agent}"
params primitive_params
action :create
end