extract #stop_runnable_resource

This commit is contained in:
Adam Spiers
2014-02-06 16:27:48 +00:00
parent 7d071e9966
commit 8607295e05
2 changed files with 14 additions and 10 deletions

View File

@@ -22,6 +22,19 @@ class Chef
Chef::Log.info "Successfully started #{@current_cib_object}" Chef::Log.info "Successfully started #{@current_cib_object}"
end end
def stop_runnable_resource
name = new_resource.name
unless @current_resource
raise "Cannot stop non-existent #{cib_object_class.description} '#{name}'"
end
return 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)
Chef::Log.info "Successfully stopped #{@current_cib_object}"
end
def delete_runnable_resource def delete_runnable_resource
return unless @current_resource return unless @current_resource
if @current_cib_object.running? if @current_cib_object.running?

View File

@@ -48,16 +48,7 @@ action :start do
end end
action :stop do action :stop do
name = new_resource.name stop_runnable_resource
unless @current_resource
raise "Cannot stop non-existent #{cib_object_class.description} '#{name}'"
end
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)
Chef::Log.info "Successfully stopped #{@current_cib_object}"
end end
def cib_object_class def cib_object_class