eliminate redundant CIB object instantiation

load_current_resource already instantiates a Pacemaker::CIBObject
if one was found on the cluster.
This commit is contained in:
Adam Spiers 2014-02-06 16:14:54 +00:00
parent 14ed45310e
commit a01427b697
2 changed files with 7 additions and 11 deletions

View File

@ -36,8 +36,7 @@ end
action :delete do
name = new_resource.name
next unless @current_resource
rsc = cib_object_class.new(name)
execute rsc.delete_command do
execute @current_cib_object.delete_command do
action :nothing
end.run_action(:run)
new_resource.updated_by_last_action(true)

View File

@ -42,11 +42,10 @@ end
action :delete do
name = new_resource.name
next unless @current_resource
rsc = cib_object_class.new(name)
if rsc.running?
if @current_cib_object.running?
raise "Cannot delete running #{@current_cib_object}"
end
execute rsc.delete_command do
execute @current_cib_object.delete_command do
action :nothing
end.run_action(:run)
new_resource.updated_by_last_action(true)
@ -58,9 +57,8 @@ action :start do
unless @current_resource
raise "Cannot start non-existent #{cib_object_class.description} '#{name}'"
end
rsc = cib_object_class.new(name)
next if rsc.running?
execute rsc.start_command do
next if @current_cib_object.running?
execute @current_cib_object.start_command do
action :nothing
end.run_action(:run)
new_resource.updated_by_last_action(true)
@ -72,9 +70,8 @@ action :stop do
unless @current_resource
raise "Cannot stop non-existent #{cib_object_class.description} '#{name}'"
end
rsc = cib_object_class.new(name)
next unless rsc.running?
execute rsc.stop_command do
next unless @current_cib_object.running?
execute @current_cib_object.stop_command do
action :nothing
end.run_action(:run)
new_resource.updated_by_last_action(true)