Sha256: 4ca24ac604a2ec85c7afaa589740634a969bb9b39bf55b153ba34a1f2afea4eb
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 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) # clear connection only if not running in some active record transaction already clear_connections = ActiveRecord::Base.connection.open_transactions == 0 super.tap do begin on_execution_plan_save(execution_plan_id, value) rescue => e Foreman::Logging.exception("Error on on_execution_plan_save event", e, :logger => Foreman::Logging.logger('foreman-tasks/dynflow')) end end ensure ::ActiveRecord::Base.clear_active_connections! if clear_connections 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman-tasks-0.7.3 | lib/foreman_tasks/dynflow/persistence.rb |
foreman-tasks-0.7.2 | lib/foreman_tasks/dynflow/persistence.rb |