app/lib/actions/entry_action.rb in foreman-tasks-3.0.6 vs app/lib/actions/entry_action.rb in foreman-tasks-4.0.0
- old
+ new
@@ -1,10 +1,12 @@
module Actions
class EntryAction < Actions::Base
include Helpers::ArgsSerialization
include Helpers::Lock
+ execution_plan_hooks.use :drop_all_locks!, :on => :stopped
+
# what locks to use on the resource? All by default, can be overriden.
# It might one or more locks available for the resource. This following
# special values are supported as well:
#
# * `:all`: lock all possible operations (all locks defined in resource's
@@ -32,16 +34,14 @@
def action_subject(resource, *additional_args)
Type! resource, ForemanTasks::Concerns::ActionSubject
input.update serialize_args(resource, *resource.all_related_resources, *additional_args)
if resource.is_a? ActiveRecord::Base
- if resource_locks == :exclusive
- exclusive_lock!(resource)
- elsif resource_locks == :link
+ if resource_locks == :link
link!(resource)
else
- lock!(resource, resource_locks)
+ exclusive_lock!(resource)
end
end
end
def humanized_input
@@ -60,8 +60,12 @@
serializer_class.new args
end
def self.serializer_class
Serializers::ActiveRecordSerializer
+ end
+
+ def drop_all_locks!(_execution_plan)
+ ForemanTasks::Lock.where(:task_id => task.id).destroy_all
end
end
end