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,14 +1,12 @@
1
1
  module ForemanTasks
2
2
  class RecurringLogicsController < ::ApplicationController
3
-
4
- before_filter :find_recurring_logic, :only => [:show, :cancel]
3
+ before_action :find_recurring_logic, :only => [:show, :cancel]
5
4
 
6
5
  def index
7
6
  @recurring_logics = filter(resource_base)
8
7
  end
9
8
 
10
- def show
11
- end
9
+ def show; end
12
10
 
13
11
  def cancel
14
12
  @recurring_logic.cancel
@@ -28,6 +26,5 @@ module ForemanTasks
28
26
  def filter(scope)
29
27
  scope.search_for(params[:search]).paginate(:page => params[:page])
30
28
  end
31
-
32
29
  end
33
30
  end
@@ -2,7 +2,7 @@ module ForemanTasks
2
2
  class TasksController < ::ApplicationController
3
3
  include Foreman::Controller::AutoCompleteSearch
4
4
 
5
- before_filter :restrict_dangerous_actions, :only => [:unlock, :force_unlock]
5
+ before_action :restrict_dangerous_actions, :only => [:unlock, :force_unlock]
6
6
 
7
7
  def show
8
8
  @task = Task.find(params[:id])
@@ -10,7 +10,7 @@ module ForemanTasks
10
10
 
11
11
  def index
12
12
  params[:order] ||= 'started_at DESC'
13
- @tasks = filter(resource_base)
13
+ @tasks = filter(resource_base)
14
14
  end
15
15
 
16
16
  def sub_tasks
@@ -21,7 +21,7 @@ module ForemanTasks
21
21
 
22
22
  def cancel_step
23
23
  task = find_dynflow_task
24
- flash[:notice] = _("Trying to cancel step %s") % params[:step_id]
24
+ flash[:notice] = _('Trying to cancel step %s') % params[:step_id]
25
25
  ForemanTasks.dynflow.world.event(task.external_id, params[:step_id].to_i, ::Dynflow::Action::Cancellable::Cancel).wait
26
26
  redirect_to foreman_tasks_task_path(task)
27
27
  end
@@ -54,7 +54,7 @@ module ForemanTasks
54
54
  task.save!
55
55
  flash[:notice] = _('The task resources were unlocked.')
56
56
  else
57
- flash[:warning] = _('The execution has to be paused.')
57
+ flash[:warning] = _('The execution has to be paused.')
58
58
  end
59
59
  redirect_to :back
60
60
  end
@@ -93,7 +93,7 @@ module ForemanTasks
93
93
  end
94
94
  end
95
95
 
96
- def resource_scope(options = {})
96
+ def resource_scope(_options = {})
97
97
  @resource_scope ||= ForemanTasks::Task.authorized("#{action_permission}_foreman_tasks")
98
98
  end
99
99
 
@@ -102,9 +102,8 @@ module ForemanTasks
102
102
  end
103
103
 
104
104
  def filter(scope)
105
- scope.search_for(params[:search], :order => params[:order]).
106
- paginate(:page => params[:page]).select('DISTINCT foreman_tasks_tasks.*')
105
+ scope.search_for(params[:search], :order => params[:order])
106
+ .paginate(:page => params[:page]).select('DISTINCT foreman_tasks_tasks.*')
107
107
  end
108
-
109
108
  end
110
109
  end
@@ -1,18 +1,17 @@
1
1
  # coding: utf-8
2
2
  module ForemanTasks
3
3
  module ForemanTasksHelper
4
-
5
4
  def recurring_logic_state(recurring_logic)
6
5
  icon, status = case recurring_logic.state
7
- when 'active'
8
- 'glyphicon-info-sign'
9
- when 'finished'
10
- ['glyphicon-ok-sign', 'status-ok']
11
- when 'cancelled'
12
- ['glyphicon-warning-sign', 'status-error']
13
- else
14
- 'glyphicon-question-sign'
15
- end
6
+ when 'active'
7
+ 'glyphicon-info-sign'
8
+ when 'finished'
9
+ ['glyphicon-ok-sign', 'status-ok']
10
+ when 'cancelled'
11
+ ['glyphicon-warning-sign', 'status-error']
12
+ else
13
+ 'glyphicon-question-sign'
14
+ end
16
15
  content_tag(:i, '&nbsp'.html_safe, :class => "glyphicon #{icon}") + content_tag(:span, recurring_logic.humanized_state, :class => status)
17
16
  end
18
17
 
@@ -20,14 +19,14 @@ module ForemanTasks
20
19
  return 'task-status pficon-help' if task.state != 'stopped'
21
20
 
22
21
  icon_class = case task.result
23
- when 'success'
24
- 'pficon-ok'
25
- when 'error'
26
- 'pficon-error-circle-o'
27
- when 'warning'
28
- 'pficon-ok status-warn'
29
- else
30
- 'pficon-help'
22
+ when 'success'
23
+ 'pficon-ok'
24
+ when 'error'
25
+ 'pficon-error-circle-o'
26
+ when 'warning'
27
+ 'pficon-ok status-warn'
28
+ else
29
+ 'pficon-help'
31
30
  end
32
31
 
33
32
  "task-status #{icon_class}"
@@ -38,7 +37,7 @@ module ForemanTasks
38
37
  _('N/A')
39
38
  else
40
39
  content_tag :span, (time > Time.now.utc ? _('in %s') : _('%s ago')) % time_ago_in_words(time),
41
- { :'data-original-title' => time.try(:in_time_zone), :rel => 'twipsy' }
40
+ :'data-original-title' => time.try(:in_time_zone), :rel => 'twipsy'
42
41
  end
43
42
  end
44
43
 
@@ -47,14 +46,14 @@ module ForemanTasks
47
46
  _('N/A')
48
47
  else
49
48
  content_tag :span, distance_of_time_in_words(start, finish),
50
- { :'data-original-title' => number_with_delimiter((finish - start).to_i) + _(' seconds'), :rel => 'twipsy' }
49
+ :'data-original-title' => number_with_delimiter((finish - start).to_i) + _(' seconds'), :rel => 'twipsy'
51
50
  end
52
51
  end
53
52
 
54
53
  def recurring_logic_action_buttons(recurring_logic)
55
54
  buttons = []
56
55
  if authorized_for(:permission => :edit_recurring_logics, :auth_object => recurring_logic)
57
- buttons << link_to(N_("Cancel"), cancel_foreman_tasks_recurring_logic_path(recurring_logic), :method => :post, :class => 'btn btn-danger') unless %w(cancelled finished).include? recurring_logic.state
56
+ buttons << link_to(N_('Cancel'), cancel_foreman_tasks_recurring_logic_path(recurring_logic), :method => :post, :class => 'btn btn-danger') unless %w(cancelled finished).include? recurring_logic.state
58
57
  end
59
58
  button_group buttons
60
59
  end
@@ -107,7 +106,7 @@ module ForemanTasks
107
106
  end
108
107
  end
109
108
 
110
- def trigger_selector(f, triggering = Triggering.new, options = {})
109
+ def trigger_selector(f, triggering = Triggering.new, _options = {})
111
110
  render :partial => 'common/trigger_form', :locals => { :f => f, :triggering => triggering }
112
111
  end
113
112
 
@@ -116,15 +115,16 @@ module ForemanTasks
116
115
  def future_mode_fieldset(f, triggering)
117
116
  tags = []
118
117
  tags << text_f(f, :start_at_raw, :label => _('Start at'), :placeholder => 'YYYY-mm-dd HH:MM')
119
- tags << text_f(f, :start_before_raw, :label => _('Start before'), :placeholder => 'YYYY-mm-dd HH:MM', :help_inline => popover(_('Explanation'), _('Indicates that the action should be cancelled if it cannot be started before this time.')))
120
- content_tag(:fieldset, nil, :id => "trigger_mode_future", :class => "trigger_mode_form #{'hidden' unless triggering.future?}") do
118
+ tags << text_f(f, :start_before_raw, :label => _('Start before'), :placeholder => 'YYYY-mm-dd HH:MM',
119
+ :label_help => _('Indicates that the action should be cancelled if it cannot be started before this time.'))
120
+ content_tag(:fieldset, nil, :id => 'trigger_mode_future', :class => "trigger_mode_form #{'hidden' unless triggering.future?}") do
121
121
  tags.join.html_safe
122
122
  end
123
123
  end
124
124
 
125
125
  def recurring_mode_fieldset(f, triggering)
126
126
  tags = []
127
- tags << selectable_f(f, :input_type, %w(cronline monthly weekly daily hourly), {}, :label => _("Repeats"), :id => 'input_type_selector')
127
+ tags << selectable_f(f, :input_type, %w(cronline monthly weekly daily hourly), {}, :label => _('Repeats'), :id => 'input_type_selector')
128
128
  tags += [
129
129
  cronline_fieldset(f, triggering),
130
130
  monthly_fieldset(f, triggering),
@@ -150,17 +150,15 @@ module ForemanTasks
150
150
  # TRANSLATORS: this translation is referring to an option which is a time interval
151
151
  _('is day of week (range: 0-6)')
152
152
  ].map { |opt| content_tag(:li, opt) }.join
153
- help = content_tag(:span, nil, :class => 'help-inline') do
154
- popover(_('Explanation'),
155
- _("Cron line format 'a b c d e', where: %s") % ("<br><ol type=\"a\">#{options}</ol>"))
156
- end
157
- content_tag(:fieldset, nil, :class => "input_type_form #{'hidden' unless triggering.input_type == :cronline}", :id => "input_type_cronline") do
158
- text_f f, :cronline, :label => _('Cron line'), :placeholder => '* * * * *', :help_inline => help
153
+
154
+ help = _("Cron line format 'a b c d e', where: %s") % "<br><ol type=\"a\">#{options}</ol>".html_safe
155
+ content_tag(:fieldset, nil, :class => "input_type_form #{'hidden' unless triggering.input_type == :cronline}", :id => 'input_type_cronline') do
156
+ text_f f, :cronline, :label => _('Cron line'), :placeholder => '* * * * *', :label_help => help
159
157
  end
160
158
  end
161
159
 
162
160
  def monthly_fieldset(f, triggering)
163
- content_tag(:fieldset, nil, :id => "input_type_monthly", :class => "input_type_form #{'hidden' unless triggering.input_type == :monthly}") do
161
+ content_tag(:fieldset, nil, :id => 'input_type_monthly', :class => "input_type_form #{'hidden' unless triggering.input_type == :monthly}") do
164
162
  text_f(f, :days, :label => _('Days'), :placeholder => '1,2...')
165
163
  end
166
164
  end
@@ -170,14 +168,14 @@ module ForemanTasks
170
168
  f.fields_for :days_of_week do |days_of_week|
171
169
  inline_checkboxes_f(days_of_week,
172
170
  :weekday,
173
- { :label => _("Days of week") },
174
- { 1 => _("Mon"),
175
- 2 => _("Tue"),
176
- 3 => _("Wed"),
177
- 4 => _("Thu"),
178
- 5 => _("Fri"),
179
- 6 => _("Sat"),
180
- 7 => _("Sun") })
171
+ { :label => _('Days of week') },
172
+ 1 => _('Mon'),
173
+ 2 => _('Tue'),
174
+ 3 => _('Wed'),
175
+ 4 => _('Thu'),
176
+ 5 => _('Fri'),
177
+ 6 => _('Sat'),
178
+ 7 => _('Sun'))
181
179
  end
182
180
  end
183
181
  end
@@ -186,16 +184,16 @@ module ForemanTasks
186
184
  tags = []
187
185
  tags << content_tag(:fieldset, nil, :id => 'time_picker', :class => "input_type_form #{'hidden' if triggering.input_type == :cronline}") do
188
186
  # TRANSLATORS: Time widget for when a task should start
189
- time_f(f, :time, { :label => _("At"), :id => 'something' }, { :time_separator => '' })
187
+ time_f(f, :time, { :label => _('At'), :id => 'something' }, :time_separator => '')
190
188
  end
191
189
  tags << number_f(f, :max_iteration, :label => _('Repeat N times'), :min => 1, :placeholder => 'N')
192
- tags << field(f, :end_time_limit_select, :label => _("Ends"), :control_group_id => "end_time_limit_select") do
193
- radio_button_f(f, :end_time_limited, :value => false, :checked=> true, :text => _("Never"), :class => 'end_time_limit_selector') +
194
- # TRANSLATORS: Button text for saying when a task should end
195
- radio_button_f(f, :end_time_limited, :value => true, :text => _("On"), :class => 'end_time_limit_selector')
190
+ tags << field(f, :end_time_limit_select, :label => _('Ends'), :control_group_id => 'end_time_limit_select') do
191
+ radio_button_f(f, :end_time_limited, :value => false, :checked => true, :text => _('Never'), :class => 'end_time_limit_selector') +
192
+ # TRANSLATORS: Button text for saying when a task should end
193
+ radio_button_f(f, :end_time_limited, :value => true, :text => _('On'), :class => 'end_time_limit_selector')
196
194
  end
197
195
  tags << content_tag(:fieldset, nil, :id => 'end_time_limit_form', :class => "input_type_form #{'hidden' unless triggering.end_time_limited}") do
198
- datetime_f f, :end_time, { :label => _("Ends at") }, { :use_month_numbers => true, :use_two_digit_numbers => true, :time_separator => '' }
196
+ datetime_f f, :end_time, { :label => _('Ends at') }, :use_month_numbers => true, :use_two_digit_numbers => true, :time_separator => ''
199
197
  end
200
198
  tags.join.html_safe
201
199
  end
@@ -11,7 +11,7 @@ module ForemanTasks
11
11
  part.to_s
12
12
  end
13
13
  end.join('; ')
14
- parts.join(" ")
14
+ parts.join(' ')
15
15
  end
16
16
 
17
17
  def format_recurring_logic_limit(thing)
@@ -1,21 +1,20 @@
1
1
  module Actions
2
-
3
2
  class Actions::ActionWithSubPlans < Actions::EntryAction
4
-
5
3
  middleware.use Actions::Middleware::KeepCurrentUser
6
4
 
7
5
  include Dynflow::Action::WithSubPlans
6
+ include Dynflow::Action::WithBulkSubPlans
8
7
 
9
- def plan(*args)
8
+ def plan(*_args)
10
9
  raise NotImplementedError
11
10
  end
12
11
 
13
12
  def humanized_output
14
13
  return unless counts_set?
15
- _("%{total} task(s), %{success} success, %{failed} fail") %
16
- { total: output[:total_count],
17
- success: output[:success_count],
18
- failed: output[:failed_count] }
14
+ _('%{total} task(s), %{success} success, %{failed} fail') %
15
+ { total: output[:total_count],
16
+ success: output[:success_count],
17
+ failed: output[:failed_count] }
19
18
  end
20
19
 
21
20
  def run_progress
@@ -25,6 +24,5 @@ module Actions
25
24
  0.1
26
25
  end
27
26
  end
28
-
29
27
  end
30
28
  end
@@ -1,6 +1,5 @@
1
1
  module Actions
2
2
  class Base < Dynflow::Action
3
-
4
3
  def task
5
4
  @task ||= ::ForemanTasks::Task::DynflowTask.where(:external_id => execution_plan_id).first!
6
5
  end
@@ -8,7 +7,7 @@ module Actions
8
7
  # This method says what data form input gets into the task details in Rest API
9
8
  # By default, it sends the whole input there.
10
9
  def task_input
11
- self.input
10
+ input
12
11
  end
13
12
 
14
13
  # This method says what data form output gets into the task details in Rest API
@@ -16,7 +15,7 @@ module Actions
16
15
  # perhaps also aggraget data from subactions if needed (using +all_actions+) method
17
16
  # of Dynflow::Action::Presenter
18
17
  def task_output
19
- self.output
18
+ output
20
19
  end
21
20
 
22
21
  # This method should return humanized description of the action, e.g. "Install package"
@@ -27,7 +26,7 @@ module Actions
27
26
  # This method should return String or Array<String> describing input for the task
28
27
  def humanized_input
29
28
  if task_input.blank?
30
- ""
29
+ ''
31
30
  else
32
31
  task_input.pretty_inspect
33
32
  end
@@ -38,7 +37,7 @@ module Actions
38
37
  # description of restuls of the action
39
38
  def humanized_output
40
39
  if task_output.blank?
41
- ""
40
+ ''
42
41
  else
43
42
  task_output.pretty_inspect
44
43
  end
@@ -52,8 +51,8 @@ module Actions
52
51
  end
53
52
 
54
53
  def already_running?
55
- ForemanTasks::Task::DynflowTask.for_action(self.class).
56
- running.where('external_id != ?', execution_plan_id).any?
54
+ ForemanTasks::Task::DynflowTask.for_action(self.class)
55
+ .running.where('external_id != ?', execution_plan_id).any?
57
56
  end
58
57
 
59
58
  def serializer_class
@@ -1,5 +1,4 @@
1
1
  module Actions
2
-
3
2
  class BulkAction < Actions::ActionWithSubPlans
4
3
  # == Parameters:
5
4
  # actions_class::
@@ -22,9 +21,9 @@ module Actions
22
21
 
23
22
  def humanized_name
24
23
  if task.sub_tasks.first
25
- task.sub_tasks.first.humanized[:action]
24
+ task.sub_tasks.first.humanized[:action]
26
25
  else
27
- _("Bulk action")
26
+ _('Bulk action')
28
27
  end
29
28
  end
30
29
 
@@ -36,7 +35,7 @@ module Actions
36
35
  a_sub_task = task.sub_tasks.first
37
36
  if a_sub_task
38
37
  [a_sub_task.humanized[:action].to_s.downcase] +
39
- Array(a_sub_task.humanized[:input]) + ['...']
38
+ Array(a_sub_task.humanized[:input]) + ['...']
40
39
  end
41
40
  end
42
41
 
@@ -45,7 +44,7 @@ module Actions
45
44
  def create_sub_plans
46
45
  action_class = input[:action_class].constantize
47
46
  target_class = input[:target_class].constantize
48
- targets = target_class.where(:id => input[:target_ids])
47
+ targets = target_class.where(:id => current_batch)
49
48
 
50
49
  targets.map do |target|
51
50
  trigger(action_class, target, *input[:args])
@@ -53,13 +52,18 @@ module Actions
53
52
  end
54
53
 
55
54
  def check_targets!(targets)
56
- if targets.empty?
57
- fail ::Foreman::Exception.new(N_("Empty bulk action"))
58
- end
55
+ raise Foreman::Exception, N_('Empty bulk action') if targets.empty?
59
56
  if targets.map(&:class).uniq.length > 1
60
- fail ::Foreman::Exception.new(N_("The targets are of different types"))
57
+ raise Foreman::Exception, N_('The targets are of different types')
61
58
  end
62
59
  end
63
60
 
61
+ def batch(from, size)
62
+ input[:target_ids].slice(from, size)
63
+ end
64
+
65
+ def total_count
66
+ input[:target_ids].count
67
+ end
64
68
  end
65
69
  end
@@ -1,5 +1,4 @@
1
1
  module Actions
2
-
3
2
  class EntryAction < Actions::Base
4
3
  include Helpers::ArgsSerialization
5
4
  include Helpers::Lock
@@ -57,12 +56,11 @@ module Actions
57
56
  end
58
57
 
59
58
  def delay(_schedule_options, *args)
60
- self.serializer_class.new args
59
+ serializer_class.new args
61
60
  end
62
61
 
63
62
  def self.serializer_class
64
63
  Serializers::ActiveRecordSerializer
65
64
  end
66
-
67
65
  end
68
66
  end
@@ -1,14 +1,12 @@
1
1
  module Actions
2
2
  module Foreman
3
3
  module Host
4
-
5
4
  class ImportFacts < Actions::EntryAction
6
-
7
5
  def resource_locks
8
6
  :import_facts
9
7
  end
10
8
 
11
- def plan(host_type, host_name, facts, certname, proxy_id)
9
+ def plan(_host_type, host_name, facts, certname, proxy_id)
12
10
  facts['domain'].try(:downcase!)
13
11
  host = ::Host::Base.import_host(host_name, certname, facts, proxy_id)
14
12
  action_subject(host, :facts => facts)
@@ -37,7 +35,7 @@ module Actions
37
35
  end
38
36
 
39
37
  def humanized_name
40
- _("Import facts")
38
+ _('Import facts')
41
39
  end
42
40
 
43
41
  def humanized_input
@@ -48,7 +46,6 @@ module Actions
48
46
  def self.cleanup_after
49
47
  '30d'
50
48
  end
51
-
52
49
  end
53
50
  end
54
51
  end