extract #stop_runnable_resource
This commit is contained in:
@@ -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?
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user