extract #start_runnable_resource

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

View File

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

View File

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