foreman-tasks 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +35 -0
  3. data/.rubocop_todo.yml +138 -0
  4. data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +3 -4
  5. data/app/controllers/foreman_tasks/api/tasks_controller.rb +56 -72
  6. data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +2 -4
  7. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +2 -5
  8. data/app/controllers/foreman_tasks/tasks_controller.rb +7 -8
  9. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +44 -46
  10. data/app/helpers/foreman_tasks/tasks_helper.rb +1 -1
  11. data/app/lib/actions/action_with_sub_plans.rb +6 -8
  12. data/app/lib/actions/base.rb +6 -7
  13. data/app/lib/actions/bulk_action.rb +13 -9
  14. data/app/lib/actions/entry_action.rb +1 -3
  15. data/app/lib/actions/foreman/host/import_facts.rb +2 -5
  16. data/app/lib/actions/foreman/puppetclass/import.rb +1 -1
  17. data/app/lib/actions/helpers/args_serialization.rb +0 -1
  18. data/app/lib/actions/helpers/humanizer.rb +16 -21
  19. data/app/lib/actions/helpers/with_continuous_output.rb +0 -1
  20. data/app/lib/actions/helpers/with_delegated_action.rb +2 -2
  21. data/app/lib/actions/middleware/inherit_task_groups.rb +3 -5
  22. data/app/lib/actions/middleware/keep_current_user.rb +0 -3
  23. data/app/lib/actions/middleware/recurring_logic.rb +0 -1
  24. data/app/lib/actions/proxy_action.rb +8 -8
  25. data/app/lib/actions/serializers/active_record_serializer.rb +0 -3
  26. data/app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb +3 -3
  27. data/app/models/foreman_tasks/concerns/action_subject.rb +4 -6
  28. data/app/models/foreman_tasks/concerns/action_triggering.rb +20 -33
  29. data/app/models/foreman_tasks/concerns/host_action_subject.rb +5 -5
  30. data/app/models/foreman_tasks/lock.rb +29 -37
  31. data/app/models/foreman_tasks/recurring_logic.rb +23 -24
  32. data/app/models/foreman_tasks/task.rb +65 -39
  33. data/app/models/foreman_tasks/task/dynflow_task.rb +23 -24
  34. data/app/models/foreman_tasks/task/status_explicator.rb +3 -3
  35. data/app/models/foreman_tasks/task/summarizer.rb +3 -3
  36. data/app/models/foreman_tasks/task_group.rb +0 -2
  37. data/app/models/foreman_tasks/task_group_member.rb +0 -2
  38. data/app/models/foreman_tasks/task_groups/recurring_logic_task_group.rb +1 -4
  39. data/app/models/foreman_tasks/triggering.rb +19 -19
  40. data/app/models/setting/foreman_tasks.rb +8 -11
  41. data/app/services/foreman_tasks/proxy_selector.rb +4 -5
  42. data/app/views/foreman_tasks/tasks/_details.html.erb +1 -1
  43. data/bin/dynflow-executor +1 -1
  44. data/bin/foreman-tasks +1 -1
  45. data/config/routes.rb +1 -1
  46. data/db/migrate/20150814204140_add_task_type_value_index.rb +1 -1
  47. data/db/migrate/20160924213030_change_tasks_widget_names.rb +8 -8
  48. data/db/seeds.d/61-foreman_tasks_bookmarks.rb +3 -3
  49. data/deploy/foreman-tasks.sysconfig +6 -0
  50. data/extra/dynflow-debug.sh +12 -0
  51. data/foreman-tasks.gemspec +1 -1
  52. data/lib/foreman_tasks.rb +3 -3
  53. data/lib/foreman_tasks/authorizer_ext.rb +1 -1
  54. data/lib/foreman_tasks/cleaner.rb +14 -16
  55. data/lib/foreman_tasks/dynflow.rb +11 -9
  56. data/lib/foreman_tasks/dynflow/configuration.rb +8 -10
  57. data/lib/foreman_tasks/dynflow/console_authorizer.rb +4 -5
  58. data/lib/foreman_tasks/dynflow/daemon.rb +17 -19
  59. data/lib/foreman_tasks/dynflow/persistence.rb +5 -8
  60. data/lib/foreman_tasks/engine.rb +30 -31
  61. data/lib/foreman_tasks/task_error.rb +1 -3
  62. data/lib/foreman_tasks/tasks/cleanup.rake +7 -19
  63. data/lib/foreman_tasks/tasks/dynflow.rake +1 -1
  64. data/lib/foreman_tasks/tasks/export_tasks.rake +51 -59
  65. data/lib/foreman_tasks/test_extensions.rb +1 -1
  66. data/lib/foreman_tasks/version.rb +1 -1
  67. data/lib/tasks/gettext.rake +10 -7
  68. data/locale/action_names.rb +3 -6
  69. data/locale/en/foreman_tasks.po +189 -177
  70. data/locale/foreman_tasks.pot +177 -137
  71. data/test/controllers/api/recurring_logics_controller_test.rb +3 -5
  72. data/test/controllers/api/tasks_controller_test.rb +5 -7
  73. data/test/factories/task_factory.rb +8 -8
  74. data/test/factories/triggering_factory.rb +2 -3
  75. data/test/helpers/foreman_tasks/tasks_helper_test.rb +11 -11
  76. data/test/support/dummy_proxy_action.rb +3 -4
  77. data/test/unit/actions/action_with_sub_plans_test.rb +5 -6
  78. data/test/unit/actions/proxy_action_test.rb +5 -8
  79. data/test/unit/cleaner_test.rb +11 -12
  80. data/test/unit/dynflow_console_authorizer_test.rb +4 -4
  81. data/test/unit/proxy_selector_test.rb +3 -3
  82. data/test/unit/recurring_logic_test.rb +19 -17
  83. data/test/unit/task_groups_test.rb +3 -4
  84. data/test/unit/task_test.rb +72 -5
  85. data/test/unit/triggering_test.rb +0 -1
  86. metadata +7 -6
  87. data/app/controllers/foreman_tasks/concerns/environments_extension.rb +0 -24
@@ -1,8 +1,8 @@
1
1
  module ForemanTasks
2
2
  class Task::DynflowTask < ForemanTasks::Task
3
-
4
3
  include Algebrick::TypeCheck
5
4
 
5
+ delegate :cancellable?, :progress, to: :execution_plan
6
6
  scope :for_action, ->(action_class) { where(label: action_class.name) }
7
7
 
8
8
  def update_from_dynflow(data)
@@ -11,7 +11,7 @@ module ForemanTasks
11
11
  self.started_at = utc_zone.parse(data[:started_at]) unless data[:started_at].nil?
12
12
  self.ended_at = utc_zone.parse(data[:ended_at]) unless data[:ended_at].nil?
13
13
  self.state = data[:state].to_s
14
- self.result = data[:result].to_s
14
+ self.result = map_result(data[:result])
15
15
  self.start_at = utc_zone.parse(data[:start_at]) if data[:start_at]
16
16
  self.start_before = utc_zone.parse(data[:start_before]) if data[:start_before]
17
17
  self.parent_task_id ||= begin
@@ -20,13 +20,9 @@ module ForemanTasks
20
20
  end
21
21
  end
22
22
  self.label ||= main_action.class.name
23
- changes = self.changes
24
- self.save!
25
- return changes
26
- end
27
-
28
- def cancellable?
29
- execution_plan.cancellable?
23
+ changes = self.changes
24
+ save!
25
+ changes
30
26
  end
31
27
 
32
28
  def cancel
@@ -41,10 +37,6 @@ module ForemanTasks
41
37
  action.is_a?(::Dynflow::Action::Cancellable)
42
38
  end
43
39
 
44
- def progress
45
- execution_plan.progress
46
- end
47
-
48
40
  def execution_plan
49
41
  @execution_plan ||= ForemanTasks.dynflow.world.persistence.load_execution_plan(external_id)
50
42
  end
@@ -73,9 +65,7 @@ module ForemanTasks
73
65
  end
74
66
 
75
67
  def cli_example
76
- if main_action.respond_to?(:cli_example)
77
- main_action.cli_example
78
- end
68
+ main_action.cli_example if main_action.respond_to?(:cli_example)
79
69
  end
80
70
 
81
71
  def main_action
@@ -104,30 +94,39 @@ module ForemanTasks
104
94
  def self.consistency_check
105
95
  fixed_count = 0
106
96
  logger = Foreman::Logging.logger('foreman-tasks')
107
- self.running.each do |task|
97
+ running.each do |task|
108
98
  begin
109
99
  changes = task.update_from_dynflow(task.execution_plan.to_hash)
110
100
  unless changes.empty?
111
101
  fixed_count += 1
112
- logger.warn("Task %s updated at consistency check: %s" % [task.id, changes.inspect])
102
+ logger.warn('Task %s updated at consistency check: %s' % [task.id, changes.inspect])
113
103
  end
114
104
  rescue => e
115
105
  Foreman::Logging.exception("Failed at consistency check for task #{task.id}", e, :logger => 'foreman-tasks')
116
106
  end
117
107
  end
118
- return fixed_count
108
+ fixed_count
119
109
  end
120
110
 
121
111
  def self.new_for_execution_plan(execution_plan_id, data)
122
- self.new(:external_id => execution_plan_id,
123
- :state => data[:state].to_s,
124
- :result => data[:result].to_s)
112
+ new(:external_id => execution_plan_id,
113
+ :state => data[:state].to_s,
114
+ :result => data[:result].to_s)
125
115
  end
126
116
 
127
- private
128
-
129
117
  def self.model_name
130
118
  superclass.model_name
131
119
  end
120
+
121
+ private
122
+
123
+ def map_result(result)
124
+ result = :cancelled if result == :error && cancelled?
125
+ result.to_s
126
+ end
127
+
128
+ def cancelled?
129
+ execution_plan.errors.map(&:exception).any? { |exception| exception.class == ::ForemanTasks::Task::TaskCancelledException }
130
+ end
132
131
  end
133
132
  end
@@ -3,9 +3,9 @@ module ForemanTasks
3
3
  ANY = 1
4
4
  ERRONEOUS_STATUSES = [
5
5
  { :state => 'paused', :result => ANY },
6
- { :state => ANY, :result => 'error'},
7
- { :state => ANY, :result => 'warning'}
8
- ]
6
+ { :state => ANY, :result => 'error' },
7
+ { :state => ANY, :result => 'warning' }
8
+ ].freeze
9
9
  def is_erroneous(task)
10
10
  remainder = ERRONEOUS_STATUSES.select do |status|
11
11
  (status[:state] == ANY || status[:state] == task.state) &&
@@ -1,13 +1,13 @@
1
1
  module ForemanTasks
2
2
  class Task::Summarizer
3
- def summarize_by_status(since=nil)
3
+ def summarize_by_status(since = nil)
4
4
  result = ::ForemanTasks::Task.select('count(state) AS count, state, result').group(:state, :result).order(:state)
5
5
  result = result.where('started_at > ?', since) if since
6
6
  result
7
7
  end
8
8
 
9
- def latest_tasks_in_errors_warning(limit=5)
10
- ::ForemanTasks::Task.where('result in (?)', ['error', 'warning']).order('started_at DESC').limit(limit)
9
+ def latest_tasks_in_errors_warning(limit = 5)
10
+ ::ForemanTasks::Task.where('result in (?)', %w(error warning)).order('started_at DESC').limit(limit)
11
11
  end
12
12
  end
13
13
  end
@@ -1,6 +1,5 @@
1
1
  module ForemanTasks
2
2
  class TaskGroup < ActiveRecord::Base
3
-
4
3
  has_many :task_group_members
5
4
  has_many :tasks, :through => :task_group_members
6
5
 
@@ -11,6 +10,5 @@ module ForemanTasks
11
10
  def resource
12
11
  raise NotImplementedError
13
12
  end
14
-
15
13
  end
16
14
  end
@@ -1,8 +1,6 @@
1
1
  module ForemanTasks
2
2
  class TaskGroupMember < ActiveRecord::Base
3
-
4
3
  belongs_to :task_group
5
4
  belongs_to :task
6
-
7
5
  end
8
6
  end
@@ -1,16 +1,13 @@
1
1
  module ForemanTasks
2
2
  module TaskGroups
3
3
  class RecurringLogicTaskGroup < ::ForemanTasks::TaskGroup
4
-
5
4
  has_one :recurring_logic, :foreign_key => :task_group_id
6
5
 
7
- alias_method :resource, :recurring_logic
6
+ alias resource recurring_logic
8
7
 
9
8
  def resource_name
10
9
  N_('Recurring logic')
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
16
-
@@ -2,8 +2,8 @@ module ForemanTasks
2
2
  class Triggering < ActiveRecord::Base
3
3
  PARAMS = [:start_at_raw, :start_before_raw, :max_iteration, :input_type,
4
4
  :cronline, :days, :days_of_week, :time, :end_time_limited,
5
- :end_time]
6
- attr_accessor *PARAMS
5
+ :end_time].freeze
6
+ attr_accessor(*PARAMS)
7
7
 
8
8
  before_save do
9
9
  if future?
@@ -14,34 +14,34 @@ module ForemanTasks
14
14
  end
15
15
  end
16
16
 
17
- ALLOWED_MODES = [:immediate, :future, :recurring]
18
- ALLOWED_INPUT_TYPES = [:cronline, :monthly, :weekly, :daily, :hourly]
17
+ ALLOWED_MODES = [:immediate, :future, :recurring].freeze
18
+ ALLOWED_INPUT_TYPES = [:cronline, :monthly, :weekly, :daily, :hourly].freeze
19
19
 
20
- TIME_FORMAT = "%Y-%m-%d %H:%M"
20
+ TIME_FORMAT = '%Y-%m-%d %H:%M'.freeze
21
21
  TIME_REGEXP = /\A\d{4}-\d{2}-\d{2} \d{2}:\d{2}\Z/
22
22
  DAYS_REGEXP = /\A(\s*\d{1,2}\s*)(,\s*\d{1,2}\s*)*\Z/
23
23
 
24
24
  has_one :recurring_logic, :foreign_key => :triggering_id
25
25
 
26
26
  validates :mode, :inclusion => { :in => ALLOWED_MODES,
27
- :message => _("%{value} is not allowed triggering mode") }
27
+ :message => _('%{value} is not allowed triggering mode') }
28
28
  validates :input_type, :if => :recurring?,
29
- :inclusion => { :in => ALLOWED_INPUT_TYPES,
30
- :message => _("%{value} is not allowed input type") }
31
- validates_format_of :start_at_raw, :with => TIME_REGEXP, :if => :future?,
32
- :message => _("%{value} is wrong format")
33
- validates_format_of :start_before_raw, :with => TIME_REGEXP, :if => :future?,
34
- :message => _("%{value} is wrong format"), :allow_blank => true
35
- validates_format_of :days, :with => DAYS_REGEXP,
36
- :if => Proc.new { |t| t.recurring? && t.input_type == :monthly }
29
+ :inclusion => { :in => ALLOWED_INPUT_TYPES,
30
+ :message => _('%{value} is not allowed input type') }
31
+ validates :start_at_raw, format: { :with => TIME_REGEXP, :if => :future?,
32
+ :message => _('%{value} is wrong format') }
33
+ validates :start_before_raw, format: { :with => TIME_REGEXP, :if => :future?,
34
+ :message => _('%{value} is wrong format'), :allow_blank => true }
35
+ validates :days, format: { :with => DAYS_REGEXP,
36
+ :if => proc { |t| t.recurring? && t.input_type == :monthly } }
37
37
  validate :can_start_recurring, :if => :recurring?
38
38
  validate :can_start_future, :if => :future?
39
39
 
40
40
  def self.new_from_params(params = {})
41
- self.new(params.except(:mode, :start_at, :start_before)).tap do |triggering|
41
+ new(params.except(:mode, :start_at, :start_before)).tap do |triggering|
42
42
  triggering.mode = params.fetch(:mode, :immediate).to_sym
43
43
  triggering.input_type = params.fetch(:input_type, :daily).to_sym
44
- triggering.end_time_limited = params[:end_time_limited] == "true"
44
+ triggering.end_time_limited = params[:end_time_limited] == 'true'
45
45
  triggering.start_at_raw ||= Time.zone.now.strftime(TIME_FORMAT)
46
46
  triggering.recurring_logic = ::ForemanTasks::RecurringLogic.new_from_triggering(triggering) if triggering.recurring?
47
47
  end
@@ -102,14 +102,14 @@ module ForemanTasks
102
102
  private
103
103
 
104
104
  def can_start_recurring
105
- self.errors.add(:input_type, _('No task could be started')) unless recurring_logic.valid?
106
- self.errors.add(:cronline, _('%s is not valid format of cron line') % (cronline)) unless recurring_logic.valid_cronline?
105
+ errors.add(:input_type, _('No task could be started')) unless recurring_logic.valid?
106
+ errors.add(:cronline, _('%s is not valid format of cron line') % cronline) unless recurring_logic.valid_cronline?
107
107
  end
108
108
 
109
109
  def can_start_future
110
110
  parse_start_before!
111
111
  parse_start_at!
112
- self.errors.add(:start_before_raw, _('The task could not be started')) if !start_before.nil? && start_before < start_at
112
+ errors.add(:start_before_raw, _('The task could not be started')) if !start_before.nil? && start_before < start_at
113
113
  end
114
114
  end
115
115
  end
@@ -1,22 +1,19 @@
1
1
  class Setting::ForemanTasks < Setting
2
-
3
2
  def self.load_defaults
4
3
  # Check the table exists
5
4
  return unless super
6
5
 
7
- self.transaction do
6
+ transaction do
8
7
  [
9
- self.set('dynflow_allow_dangerous_actions', N_("Allow unlocking actions which can have dangerous consequences."), false),
10
- self.set('dynflow_enable_console', N_("Enable the dynflow console (/foreman_tasks/dynflow) for debugging"), true),
11
- self.set('dynflow_console_require_auth', N_("Require user to be authenticated as user with admin rights when accessing dynflow console"), true),
12
- self.set('foreman_tasks_proxy_action_retry_count', N_("Number of attempts to start a task on the smart proxy before failing"), 4),
13
- self.set('foreman_tasks_proxy_action_retry_interval', N_("Time in seconds between retries"), 15),
14
- self.set('foreman_tasks_proxy_action_start_timeout', N_("Time in second during which a task has to be started on the proxy"), 60)
15
- ].each { |s| self.create! s.update(:category => "Setting::ForemanTasks")}
8
+ set('dynflow_allow_dangerous_actions', N_('Allow unlocking actions which can have dangerous consequences.'), false),
9
+ set('dynflow_enable_console', N_('Enable the dynflow console (/foreman_tasks/dynflow) for debugging'), true),
10
+ set('dynflow_console_require_auth', N_('Require user to be authenticated as user with admin rights when accessing dynflow console'), true),
11
+ set('foreman_tasks_proxy_action_retry_count', N_('Number of attempts to start a task on the smart proxy before failing'), 4),
12
+ set('foreman_tasks_proxy_action_retry_interval', N_('Time in seconds between retries'), 15),
13
+ set('foreman_tasks_proxy_action_start_timeout', N_('Time in second during which a task has to be started on the proxy'), 60)
14
+ ].each { |s| create! s.update(:category => 'Setting::ForemanTasks') }
16
15
  end
17
16
 
18
17
  true
19
-
20
18
  end
21
-
22
19
  end
@@ -1,6 +1,5 @@
1
1
  module ForemanTasks
2
2
  class ProxySelector
3
-
4
3
  attr_reader :offline
5
4
 
6
5
  def initialize
@@ -12,7 +11,7 @@ module ForemanTasks
12
11
  [:subnet, :fallback, :global]
13
12
  end
14
13
 
15
- def available_proxies(*args)
14
+ def available_proxies(*_args)
16
15
  raise NotImplementedError
17
16
  end
18
17
 
@@ -34,8 +33,8 @@ module ForemanTasks
34
33
  def select_by_jobs_count(proxies)
35
34
  exclude = @tasks.keys + @offline
36
35
  @tasks.merge!(get_counts(proxies - exclude))
37
- next_proxy = @tasks.select { |proxy, _| proxies.include?(proxy) }.
38
- min_by { |_, job_count| job_count }.try(:first)
36
+ next_proxy = @tasks.select { |proxy, _| proxies.include?(proxy) }
37
+ .min_by { |_, job_count| job_count }.try(:first)
39
38
  @tasks[next_proxy] += 1 if next_proxy.present?
40
39
  next_proxy
41
40
  end
@@ -43,7 +42,7 @@ module ForemanTasks
43
42
  private
44
43
 
45
44
  def get_counts(proxies)
46
- proxies.inject({}) do |result, proxy|
45
+ proxies.each_with_object({}) do |proxy, result|
47
46
  begin
48
47
  proxy_api = ProxyAPI::ForemanDynflow::DynflowProxy.new(:url => proxy.url)
49
48
  result[proxy] = proxy_api.tasks_count('running')
@@ -168,7 +168,7 @@
168
168
  aria-valuemin="0"
169
169
  aria-valuemax="100"
170
170
  style="width: <%= progress %>%;">
171
- <span><%= progress %>% Complete</span>
171
+ <span><%= progress.round %>% Complete</span>
172
172
  </div>
173
173
  </div>
174
174
  </div>
data/bin/dynflow-executor CHANGED
@@ -8,7 +8,7 @@ opts = OptionParser.new do |opts|
8
8
  opts.banner = <<BANNER
9
9
  Run Dynflow executor for Foreman tasks.
10
10
 
11
- Usage: #{File.basename($0)} [options] ACTION"
11
+ Usage: #{File.basename($PROGRAM_NAME)} [options] ACTION"
12
12
 
13
13
  ACTION can be one of:
14
14
 
data/bin/foreman-tasks CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- foreman_root = "/usr/share/foreman"
3
+ foreman_root = '/usr/share/foreman'
4
4
  require File.expand_path('./config/application', foreman_root)
5
5
  ForemanTasks::Dynflow::Daemon.new.run_background(ARGV.last, :foreman_root => foreman_root)
data/config/routes.rb CHANGED
@@ -39,7 +39,7 @@ Foreman::Application.routes.draw do
39
39
 
40
40
  if ForemanTasks.dynflow.required?
41
41
  require 'dynflow/web'
42
- mount ForemanTasks.dynflow.web_console => "/dynflow"
42
+ mount ForemanTasks.dynflow.web_console => '/dynflow'
43
43
  end
44
44
  end
45
45
  end
@@ -1,5 +1,5 @@
1
1
  class AddTaskTypeValueIndex < ActiveRecord::Migration
2
2
  def change
3
- add_index :foreman_tasks_tasks, [:type, :label]
3
+ add_index :foreman_tasks_tasks, [:type, :label]
4
4
  end
5
5
  end
@@ -1,15 +1,15 @@
1
1
  class ChangeTasksWidgetNames < ActiveRecord::Migration
2
2
  def up
3
- Widget.where(:name => 'Tasks Status table').\
4
- update_all(:name => 'Task Status')
5
- Widget.where(:name => 'Tasks in Error/Warning').\
6
- update_all(:name => 'Latest Warning/Error Tasks')
3
+ Widget.where(:name => 'Tasks Status table')\
4
+ .update_all(:name => 'Task Status')
5
+ Widget.where(:name => 'Tasks in Error/Warning')\
6
+ .update_all(:name => 'Latest Warning/Error Tasks')
7
7
  end
8
8
 
9
9
  def down
10
- Widget.where(:name => 'Task Status').\
11
- update_all(:name => 'Tasks Status table')
12
- Widget.where(:name => 'Latest Warning/Error Tasks').\
13
- update_all(:name => 'Tasks in Error/Warning')
10
+ Widget.where(:name => 'Task Status')\
11
+ .update_all(:name => 'Tasks Status table')
12
+ Widget.where(:name => 'Latest Warning/Error Tasks')\
13
+ .update_all(:name => 'Tasks in Error/Warning')
14
14
  end
15
15
  end
@@ -1,12 +1,12 @@
1
1
  Bookmark.without_auditing do
2
2
  [
3
- { :name => "running", :query => "state = running" },
4
- { :name => "failed", :query => "state = paused or result = error or result = warning" }
3
+ { :name => 'running', :query => 'state = running' },
4
+ { :name => 'failed', :query => 'state = paused or result = error or result = warning' }
5
5
 
6
6
  ].each do |item|
7
7
  next if Bookmark.where(:name => item[:name]).first
8
8
  next if audit_modified? Bookmark, item[:name]
9
- b = Bookmark.create({:controller => "foreman_tasks_tasks", :public => true}.merge(item))
9
+ b = Bookmark.create({ :controller => 'foreman_tasks_tasks', :public => true }.merge(item))
10
10
  raise "Unable to create bookmark: #{format_errors b}" if b.nil? || b.errors.any?
11
11
  end
12
12
  end
@@ -6,3 +6,9 @@ FOREMAN_LOGGING=warn
6
6
  FOREMAN_LOGGING_SQL=warn
7
7
  FOREMAN_TASK_PARAMS="-p foreman"
8
8
  FOREMAN_LOG_DIR=/var/log/foreman
9
+
10
+ RUBY_GC_MALLOC_LIMIT=4000100
11
+ RUBY_GC_MALLOC_LIMIT_MAX=16000100
12
+ RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.1
13
+ RUBY_GC_OLDMALLOC_LIMIT=16000100
14
+ RUBY_GC_OLDMALLOC_LIMIT_MAX=16000100
@@ -3,5 +3,17 @@
3
3
  # This file provides additional debug information for foreman-debug tool and is
4
4
  # symlinked as /usr/share/foreman/script/foreman-debug.d/60-dynflow_debug
5
5
 
6
+ export_csv() {
7
+ echo "COPY ($1) TO STDOUT WITH CSV;" | su - postgres -c '/usr/bin/psql -d foreman' > $2
8
+ }
9
+
6
10
  add_files /var/log/foreman/dynflow_executor*.log*
7
11
  add_files /var/log/foreman/dynflow_executor*.output*
12
+
13
+ # Foreman Tasks fast export (for HTML version use foreman-rake foreman_tasks:export_tasks)
14
+ export_csv "select dynflow_execution_plans.* from foreman_tasks_tasks join dynflow_execution_plans on (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-6} months'::interval" "$DIR/dynflow_execution_plans.csv"
15
+ export_csv "select dynflow_actions.* from foreman_tasks_tasks join dynflow_actions on (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-6} months'::interval" "$DIR/dynflow_actions.csv"
16
+ export_csv "select dynflow_steps.* from foreman_tasks_tasks join dynflow_steps on (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-6} months'::interval" "$DIR/dynflow_steps.csv"
17
+ export_csv "select * from dynflow_schema_info" "$DIR/dynflow_schema_info.csv"
18
+ export_csv "select * from foreman_tasks_tasks" "$DIR/foreman_tasks_tasks.csv"
19
+
@@ -29,7 +29,7 @@ DESC
29
29
  s.extra_rdoc_files = Dir['README*', 'LICENSE']
30
30
 
31
31
  s.add_dependency "foreman-tasks-core"
32
- s.add_dependency "dynflow", '~> 0.8.17'
32
+ s.add_dependency "dynflow", '~> 0.8.22'
33
33
  s.add_dependency "sequel" # for Dynflow process persistence
34
34
  s.add_dependency "sinatra" # for Dynflow web console
35
35
  s.add_dependency "daemons" # for running remote executor