diff --git a/app/models/foreman_tasks/concerns/action_triggering.rb b/app/models/foreman_tasks/concerns/action_triggering.rb index 53352b8f9..6cd02eadc 100644 --- a/app/models/foreman_tasks/concerns/action_triggering.rb +++ b/app/models/foreman_tasks/concerns/action_triggering.rb @@ -23,12 +23,12 @@ def update_action; end # @override def destroy_action; end - def save(*args) - dynflow_task_wrap(:save) { super(*args) } + def save(...) + dynflow_task_wrap(:save) { super(...) } end - def save!(*args) - dynflow_task_wrap(:save) { super(*args) } + def save!(...) + dynflow_task_wrap(:save) { super(...) } end def destroy @@ -37,14 +37,14 @@ def destroy # In order to use host._changed?, we must assign_attributes to # the host record for these update and update! methods. - def update(*args) - assign_attributes(*args) + def update(...) + assign_attributes(...) dynflow_task_wrap(:save) { save } end alias update_attributes update - def update!(*args) - assign_attributes(*args) + def update!(...) + assign_attributes(...) dynflow_task_wrap(:save) { save! } end alias update_attributes! update! @@ -88,9 +88,9 @@ def plan_hook_action # We do it separately from the execution phase, because the transaction # of planning phase is expected to be commited when execution occurs. Also # we want to be able to rollback the whole db operation when planning fails. - def plan_action(action_class, *args) + def plan_action(action_class, *args, **kwargs) return if ForemanTasks.dynflow.config.disable_active_record_actions - @execution_plan = ::ForemanTasks.dynflow.world.plan(action_class, *args) + @execution_plan = ::ForemanTasks.dynflow.world.plan(action_class, *args, **kwargs) raise @execution_plan.errors.first if @execution_plan.error? end diff --git a/lib/foreman_tasks.rb b/lib/foreman_tasks.rb index c4cfb9e83..5786e5b88 100644 --- a/lib/foreman_tasks.rb +++ b/lib/foreman_tasks.rb @@ -16,14 +16,14 @@ def self.dynflow @dynflow ||= ForemanTasks::Dynflow.new(nil, ForemanTasks::Dynflow::Configuration.new) end - def self.trigger(action, *args, &block) - dynflow.world.trigger action, *args, &block + def self.trigger(action, *args, **kwargs, &block) + dynflow.world.trigger action, *args, **kwargs, &block end - def self.trigger_task(async, action, *args, &block) + def self.trigger_task(async, action, *args, **kwargs, &block) rails_safe_trigger_task do Match! async, true, false - match trigger(action, *args, &block), + match trigger(action, *args, **kwargs, &block), (on ::Dynflow::World::PlaningFailed.call(error: ~any) do |error| raise error end), @@ -47,18 +47,18 @@ def self.rails_safe_trigger_task end end - def self.async_task(action, *args, &block) - trigger_task true, action, *args, &block + def self.async_task(action, *args, **kwargs, &block) + trigger_task true, action, *args, **kwargs, &block end - def self.sync_task(action, *args, &block) - trigger_task(false, action, *args, &block).tap do |task| + def self.sync_task(action, *args, **kwargs, &block) + trigger_task(false, action, *args, **kwargs, &block).tap do |task| raise TaskError, task if task.execution_plan.error? || task.execution_plan.result == :warning end end - def self.delay(action, delay_options, *args) - result = dynflow.world.delay action, delay_options, *args + def self.delay(action, delay_options, *args, **kwargs) + result = dynflow.world.delay action, delay_options, *args, **kwargs ForemanTasks::Task::DynflowTask.where(:external_id => result.id).first! end