From a01427b697fc100201a118b6efcf2bc646764c3b Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 6 Feb 2014 16:14:54 +0000 Subject: [PATCH] eliminate redundant CIB object instantiation load_current_resource already instantiates a Pacemaker::CIBObject if one was found on the cluster. --- providers/colocation.rb | 3 +-- providers/primitive.rb | 15 ++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/providers/colocation.rb b/providers/colocation.rb index 748cb1b..656b71c 100644 --- a/providers/colocation.rb +++ b/providers/colocation.rb @@ -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) diff --git a/providers/primitive.rb b/providers/primitive.rb index 7c36eff..99ca86f 100644 --- a/providers/primitive.rb +++ b/providers/primitive.rb @@ -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)