Move STONITH check to second pass
This commit is contained in:
parent
95563f791a
commit
4915a3dd62
24
libraries/stonith.rb
Normal file
24
libraries/stonith.rb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
module PacemakerStonithHelper
|
||||||
|
@@stonith_plugins = nil
|
||||||
|
|
||||||
|
def self.stonith_plugin_valid?(plugin)
|
||||||
|
if plugin.nil? || plugin.empty?
|
||||||
|
false
|
||||||
|
else
|
||||||
|
if @@stonith_plugins.nil?
|
||||||
|
out = %x{stonith -L}
|
||||||
|
if $?.success?
|
||||||
|
@@stonith_plugins = out.split("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
!@@stonith_plugins.nil? && @@stonith_plugins.include?(plugin)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.assert_stonith_plugin_valid(plugin)
|
||||||
|
unless stonith_plugin_valid? plugin
|
||||||
|
raise "STONITH plugin #{plugin} is not available!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -20,23 +20,6 @@
|
|||||||
|
|
||||||
# FIXME: delete old resources when switching mode (or plugin!)
|
# FIXME: delete old resources when switching mode (or plugin!)
|
||||||
|
|
||||||
@stonith_plugins = nil
|
|
||||||
|
|
||||||
def stonith_plugin_valid?(plugin)
|
|
||||||
if plugin.nil? || plugin.empty?
|
|
||||||
false
|
|
||||||
else
|
|
||||||
if @stonith_plugins.nil?
|
|
||||||
out = %x{stonith -L}
|
|
||||||
if $?.success?
|
|
||||||
@stonith_plugins = out.split("\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
!@stonith_plugins.nil? && @stonith_plugins.include?(plugin)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
case node[:pacemaker][:stonith][:mode]
|
case node[:pacemaker][:stonith][:mode]
|
||||||
when "disabled"
|
when "disabled"
|
||||||
when "manual"
|
when "manual"
|
||||||
@ -46,10 +29,12 @@ when "clone"
|
|||||||
plugin = node[:pacemaker][:stonith][:clone][:plugin]
|
plugin = node[:pacemaker][:stonith][:clone][:plugin]
|
||||||
params = node[:pacemaker][:stonith][:clone][:params]
|
params = node[:pacemaker][:stonith][:clone][:params]
|
||||||
|
|
||||||
unless stonith_plugin_valid? plugin
|
# This needs to be done in the second phase of chef, because we need
|
||||||
message = "STONITH plugin #{plugin} is not available!"
|
# cluster-glue to be installed first; hence ruby_block
|
||||||
Chef::Log.fatal(message)
|
ruby_block "Check if STONITH #{plugin} is available" do
|
||||||
raise message
|
block do
|
||||||
|
PacemakerStonithHelper.assert_stonith_plugin_valid plugin
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if params.respond_to?('to_hash')
|
if params.respond_to?('to_hash')
|
||||||
@ -82,10 +67,12 @@ when "clone"
|
|||||||
when "per_node"
|
when "per_node"
|
||||||
plugin = node[:pacemaker][:stonith][:per_node][:plugin]
|
plugin = node[:pacemaker][:stonith][:per_node][:plugin]
|
||||||
|
|
||||||
unless stonith_plugin_valid? plugin
|
# This needs to be done in the second phase of chef, because we need
|
||||||
message = "STONITH plugin #{plugin} is not available!"
|
# cluster-glue to be installed first; hence ruby_block
|
||||||
Chef::Log.fatal(message)
|
ruby_block "Check if STONITH #{plugin} is available" do
|
||||||
raise message
|
block do
|
||||||
|
PacemakerStonithHelper.assert_stonith_plugin_valid plugin
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
node[:pacemaker][:stonith][:per_node][:nodes].keys.each do |node_name|
|
node[:pacemaker][:stonith][:per_node][:nodes].keys.each do |node_name|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user