Check that the specified STONITH plugin is available

We simply need to check if the plugin is in the output of "stonith -L".
This commit is contained in:
Vincent Untz 2014-03-13 15:31:54 +01:00
parent 80e67ed039
commit 95563f791a
1 changed files with 29 additions and 1 deletions

View File

@ -19,7 +19,23 @@
#
# FIXME: delete old resources when switching mode (or plugin!)
# FIXME: check that the stonith plugin to use exists with stonith -L
@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]
when "disabled"
@ -30,6 +46,12 @@ when "clone"
plugin = node[:pacemaker][:stonith][:clone][:plugin]
params = node[:pacemaker][:stonith][:clone][:params]
unless stonith_plugin_valid? plugin
message = "STONITH plugin #{plugin} is not available!"
Chef::Log.fatal(message)
raise message
end
if params.respond_to?('to_hash')
primitive_params = params.to_hash
elsif params.is_a?(String)
@ -60,6 +82,12 @@ when "clone"
when "per_node"
plugin = node[:pacemaker][:stonith][:per_node][:plugin]
unless stonith_plugin_valid? plugin
message = "STONITH plugin #{plugin} is not available!"
Chef::Log.fatal(message)
raise message
end
node[:pacemaker][:stonith][:per_node][:nodes].keys.each do |node_name|
stonith_resource = "stonith-#{node_name}"
params = node[:pacemaker][:stonith][:per_node][:nodes][node_name][:params]