Sha256: 7ea689b521f713fca20f998e75db8b21823d3fdea9046530b6b0ee11682bbe59
Contents?: true
Size: 1.4 KB
Versions: 11
Compression:
Stored size: 1.4 KB
Contents
module ForemanTasks # wrap the dynflow persistence to reflect the changes to execution plan # in the Task model. This is probably a temporary solution and # Dynflow will probably get more events-based API but it should be enought # for start, until the requiements on the API are clear enough. class Dynflow::Persistence < ::Dynflow::PersistenceAdapters::Sequel def save_execution_plan(execution_plan_id, value) super.tap do begin on_execution_plan_save(execution_plan_id, value) rescue => e ForemanTasks.dynflow.world.logger.error('Error on on_execution_plan_save event') ForemanTasks.dynflow.world.logger.error(e.message) ForemanTasks.dynflow.world.logger.error(e.backtrace.join("\n")) end end end def on_execution_plan_save(execution_plan_id, data) # We can load the data unless the execution plan was properly planned and saved # including its steps if data[:state] == :planning task = ::ForemanTasks::Task::DynflowTask.new task.update_from_dynflow(data) Lock.owner!(::User.current, task.id) if ::User.current elsif data[:state] != :pending if task = ::ForemanTasks::Task::DynflowTask.find_by_external_id(execution_plan_id) unless task.state.to_s == data[:state].to_s task.update_from_dynflow(data) end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems