foreman-tasks 9.2.3 → 10.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cd550a681ae53c5133f3017a5f8bee019a119cd0bdfb23d8b64c830304cd5c1
4
- data.tar.gz: 195c7013c5c9c7ad31064cf3552fe10f6084a100b2903dc1753e10c62f2ef31f
3
+ metadata.gz: 4a7506ccab551c52f9408df7fcfca78e6a565753bc35ca7263bd2265a5aa95bf
4
+ data.tar.gz: 2a6a714e7cfc082139d7fd73f1f7c2547817e4e9ace0b02c681bad6b8f63043b
5
5
  SHA512:
6
- metadata.gz: 93df3af963db3e2ac838954834bd54ef3d2ac21778fc1940bdb7971bb2f2de9e0bd7ed4abe6f7cbf9338cd636f7f3d4160b3eec25ca5eb5c7ca1586479fe13c1
7
- data.tar.gz: 9c13f2ad52f111a01c501294f3a43e75188401b2d48fecaa39fdea214db3ea8ac1751828d5ce27d8c564a53741ffceff121cf3c0d918f3f5d41d890a66f43fcb
6
+ metadata.gz: 3c1f0897789b528c739a77a21b39b2471f841759472c2755228b288e698485c11aee37224106c96725cd858d98c970fbe71948adceeb1553b83931a75e817676
7
+ data.tar.gz: fe5eb0b8a95b15ada47a46b4839c79e5b45d43042a28ca13fd1ad318a1dbeb7afe0257138eea96b3006613baf4fe0ec7d51c98854347b1a5f908cea6eefabf77
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ locale/*/*.po.time_stamp
16
16
  node_modules
17
17
  package-lock.json
18
18
  coverage/
19
+ locale/action_names.rb
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
-
5
- gem 'theforeman-rubocop', '~> 0.1.0'
@@ -1,6 +1,6 @@
1
1
  module Actions
2
2
  module Middleware
3
- class KeepCurrentRequestID < Dynflow::Middleware
3
+ class KeepCurrentRequestId < Dynflow::Middleware
4
4
  def delay(*args)
5
5
  pass(*args).tap { store_current_request_id }
6
6
  end
@@ -33,4 +33,5 @@ same resource. It also optionally provides Dynflow infrastructure for using it f
33
33
 
34
34
  s.add_development_dependency 'factory_bot_rails', '~> 4.8.0'
35
35
  s.add_development_dependency 'sqlite3'
36
+ s.add_development_dependency 'theforeman-rubocop', '~> 0.1.0'
36
37
  end
@@ -252,7 +252,7 @@ module ForemanTasks
252
252
 
253
253
  def prepare_filter
254
254
  filter_parts = [filter]
255
- filter_parts << %(started_at < "#{after.ago.to_s(:db)}") if after > 0
255
+ filter_parts << %(started_at < "#{after.ago.to_formatted_s(:db)}") if after > 0
256
256
  filter_parts << "state ^ (#{states.join(',')})" if states.any?
257
257
  filter_parts.select(&:present?).map { |segment| "(#{segment})" }.join(' AND ')
258
258
  end
@@ -16,116 +16,118 @@ module ForemanTasks
16
16
  SETTINGS[:foreman_tasks] = { :assets => { :precompile => assets_to_precompile } }
17
17
  end
18
18
 
19
- initializer 'foreman_tasks.register_plugin', :before => :finisher_hook do |_app|
20
- Foreman::Plugin.register :"foreman-tasks" do
21
- requires_foreman '>= 3.9'
22
- divider :top_menu, :parent => :monitor_menu, :last => true, :caption => N_('Foreman Tasks')
23
- menu :top_menu, :tasks,
24
- :url_hash => { :controller => 'foreman_tasks/tasks', :action => :index },
25
- :caption => N_('Tasks'),
26
- :parent => :monitor_menu,
27
- :last => true
28
-
29
- menu :top_menu, :recurring_logics,
30
- :url_hash => { :controller => 'foreman_tasks/recurring_logics', :action => :index },
31
- :caption => N_('Recurring Logics'),
32
- :parent => :monitor_menu,
33
- :last => true
34
-
35
- security_block :foreman_tasks do |_map|
36
- permission :view_foreman_tasks, { :'foreman_tasks/tasks' => [:auto_complete_search, :sub_tasks, :index, :summary, :summary_sub_tasks, :show],
37
- :'foreman_tasks/react' => [:index],
38
- :'foreman_tasks/api/tasks' => [:bulk_search, :show, :index, :summary, :summary_sub_tasks, :details, :sub_tasks] }, :resource_type => 'ForemanTasks::Task'
39
- permission :edit_foreman_tasks, { :'foreman_tasks/tasks' => [:resume, :unlock, :force_unlock, :cancel_step, :cancel, :abort],
40
- :'foreman_tasks/api/tasks' => [:bulk_resume, :bulk_cancel, :bulk_stop] }, :resource_type => 'ForemanTasks::Task'
41
-
42
- permission :create_recurring_logics, {}, :resource_type => 'ForemanTasks::RecurringLogic'
43
-
44
- permission :view_recurring_logics, { :'foreman_tasks/recurring_logics' => [:auto_complete_search, :index, :show],
45
- :'foreman_tasks/api/recurring_logics' => [:index, :show] }, :resource_type => 'ForemanTasks::RecurringLogic'
46
-
47
- permission :edit_recurring_logics, { :'foreman_tasks/recurring_logics' => [:cancel, :enable, :disable, :clear_cancelled],
48
- :'foreman_tasks/api/recurring_logics' => [:cancel, :update, :bulk_destroy] }, :resource_type => 'ForemanTasks::RecurringLogic'
49
- end
19
+ initializer 'foreman_tasks.register_plugin', :before => :finisher_hook do |app|
20
+ app.reloader.to_prepare do
21
+ Foreman::Plugin.register :"foreman-tasks" do
22
+ requires_foreman '>= 3.13'
23
+ divider :top_menu, :parent => :monitor_menu, :last => true, :caption => N_('Foreman Tasks')
24
+ menu :top_menu, :tasks,
25
+ :url_hash => { :controller => 'foreman_tasks/tasks', :action => :index },
26
+ :caption => N_('Tasks'),
27
+ :parent => :monitor_menu,
28
+ :last => true
29
+
30
+ menu :top_menu, :recurring_logics,
31
+ :url_hash => { :controller => 'foreman_tasks/recurring_logics', :action => :index },
32
+ :caption => N_('Recurring Logics'),
33
+ :parent => :monitor_menu,
34
+ :last => true
35
+
36
+ security_block :foreman_tasks do |_map|
37
+ permission :view_foreman_tasks, { :'foreman_tasks/tasks' => [:auto_complete_search, :sub_tasks, :index, :summary, :summary_sub_tasks, :show],
38
+ :'foreman_tasks/react' => [:index],
39
+ :'foreman_tasks/api/tasks' => [:bulk_search, :show, :index, :summary, :summary_sub_tasks, :details, :sub_tasks] }, :resource_type => 'ForemanTasks::Task'
40
+ permission :edit_foreman_tasks, { :'foreman_tasks/tasks' => [:resume, :unlock, :force_unlock, :cancel_step, :cancel, :abort],
41
+ :'foreman_tasks/api/tasks' => [:bulk_resume, :bulk_cancel, :bulk_stop] }, :resource_type => 'ForemanTasks::Task'
42
+
43
+ permission :create_recurring_logics, {}, :resource_type => 'ForemanTasks::RecurringLogic'
44
+
45
+ permission :view_recurring_logics, { :'foreman_tasks/recurring_logics' => [:auto_complete_search, :index, :show],
46
+ :'foreman_tasks/api/recurring_logics' => [:index, :show] }, :resource_type => 'ForemanTasks::RecurringLogic'
47
+
48
+ permission :edit_recurring_logics, { :'foreman_tasks/recurring_logics' => [:cancel, :enable, :disable, :clear_cancelled],
49
+ :'foreman_tasks/api/recurring_logics' => [:cancel, :update, :bulk_destroy] }, :resource_type => 'ForemanTasks::RecurringLogic'
50
+ end
50
51
 
51
- add_all_permissions_to_default_roles
52
-
53
- settings do
54
- category(:tasks, N_('Tasks')) do
55
- setting('foreman_tasks_sync_task_timeout',
56
- type: :integer,
57
- description: N_('Number of seconds to wait for synchronous task to finish.'),
58
- default: 120,
59
- full_name: N_('Sync task timeout'))
60
- setting('dynflow_enable_console',
61
- type: :boolean,
62
- description: N_('Enable the dynflow console (/foreman_tasks/dynflow) for debugging'),
63
- default: true,
64
- full_name: N_('Enable dynflow console'))
65
- setting('dynflow_console_require_auth',
66
- type: :boolean,
67
- description: N_('Require user to be authenticated as user with admin rights when accessing dynflow console'),
68
- default: true,
69
- full_name: N_('Require auth for dynflow console'))
70
- setting('foreman_tasks_proxy_action_retry_count',
71
- type: :integer,
72
- description: N_('Number of attempts to start a task on the smart proxy before failing'),
73
- default: 4,
74
- full_name: N_('Proxy action retry count'))
75
- setting('foreman_tasks_proxy_action_retry_interval',
76
- type: :integer,
77
- description: N_('Time in seconds between retries'),
78
- default: 15,
79
- full_name: N_('Proxy action retry interval'))
80
- setting('foreman_tasks_proxy_batch_trigger',
81
- type: :boolean,
82
- description: N_('Allow triggering tasks on the smart proxy in batches'),
83
- default: true,
84
- full_name: N_('Allow proxy batch tasks'))
85
- setting('foreman_tasks_proxy_batch_size',
86
- type: :integer,
87
- description: N_('Number of tasks which should be sent to the smart proxy in one request, if foreman_tasks_proxy_batch_trigger is enabled'),
88
- default: 100,
89
- full_name: N_('Proxy tasks batch size'))
90
- setting('foreman_tasks_troubleshooting_url',
91
- type: :string,
92
- description: N_('Url pointing to the task troubleshooting documentation. '\
93
- 'It should contain %{label} placeholder, that will be replaced with normalized task label '\
94
- '(restricted to only alphanumeric characters)). %{version} placeholder is also available.'),
95
- default: nil,
96
- full_name: N_('Tasks troubleshooting URL'))
97
- setting('foreman_tasks_polling_multiplier',
98
- type: :integer,
99
- description: N_('Polling multiplier which is used to multiply the default polling intervals. '\
100
- 'This can be used to prevent polling too frequently for long running tasks.'),
101
- default: 1,
102
- full_name: N_("Polling intervals multiplier"),
103
- validate: { numericality: { greater_than: 0 } })
52
+ add_all_permissions_to_default_roles
53
+
54
+ settings do
55
+ category(:tasks, N_('Tasks')) do
56
+ setting('foreman_tasks_sync_task_timeout',
57
+ type: :integer,
58
+ description: N_('Number of seconds to wait for synchronous task to finish.'),
59
+ default: 120,
60
+ full_name: N_('Sync task timeout'))
61
+ setting('dynflow_enable_console',
62
+ type: :boolean,
63
+ description: N_('Enable the dynflow console (/foreman_tasks/dynflow) for debugging'),
64
+ default: true,
65
+ full_name: N_('Enable dynflow console'))
66
+ setting('dynflow_console_require_auth',
67
+ type: :boolean,
68
+ description: N_('Require user to be authenticated as user with admin rights when accessing dynflow console'),
69
+ default: true,
70
+ full_name: N_('Require auth for dynflow console'))
71
+ setting('foreman_tasks_proxy_action_retry_count',
72
+ type: :integer,
73
+ description: N_('Number of attempts to start a task on the smart proxy before failing'),
74
+ default: 4,
75
+ full_name: N_('Proxy action retry count'))
76
+ setting('foreman_tasks_proxy_action_retry_interval',
77
+ type: :integer,
78
+ description: N_('Time in seconds between retries'),
79
+ default: 15,
80
+ full_name: N_('Proxy action retry interval'))
81
+ setting('foreman_tasks_proxy_batch_trigger',
82
+ type: :boolean,
83
+ description: N_('Allow triggering tasks on the smart proxy in batches'),
84
+ default: true,
85
+ full_name: N_('Allow proxy batch tasks'))
86
+ setting('foreman_tasks_proxy_batch_size',
87
+ type: :integer,
88
+ description: N_('Number of tasks which should be sent to the smart proxy in one request, if foreman_tasks_proxy_batch_trigger is enabled'),
89
+ default: 100,
90
+ full_name: N_('Proxy tasks batch size'))
91
+ setting('foreman_tasks_troubleshooting_url',
92
+ type: :string,
93
+ description: N_('Url pointing to the task troubleshooting documentation. '\
94
+ 'It should contain %{label} placeholder, that will be replaced with normalized task label '\
95
+ '(restricted to only alphanumeric characters)). %{version} placeholder is also available.'),
96
+ default: nil,
97
+ full_name: N_('Tasks troubleshooting URL'))
98
+ setting('foreman_tasks_polling_multiplier',
99
+ type: :integer,
100
+ description: N_('Polling multiplier which is used to multiply the default polling intervals. '\
101
+ 'This can be used to prevent polling too frequently for long running tasks.'),
102
+ default: 1,
103
+ full_name: N_("Polling intervals multiplier"),
104
+ validate: { numericality: { greater_than: 0 } })
105
+ end
104
106
  end
105
- end
106
107
 
107
- register_graphql_query_field :task, '::Types::Task', :record_field
108
- register_graphql_query_field :tasks, '::Types::Task', :collection_field
109
- register_graphql_query_field :recurring_logic, '::Types::RecurringLogic', :record_field
110
- register_graphql_query_field :recurring_logics, '::Types::RecurringLogic', :collection_field
108
+ register_graphql_query_field :task, '::Types::Task', :record_field
109
+ register_graphql_query_field :tasks, '::Types::Task', :collection_field
110
+ register_graphql_query_field :recurring_logic, '::Types::RecurringLogic', :record_field
111
+ register_graphql_query_field :recurring_logics, '::Types::RecurringLogic', :collection_field
111
112
 
112
- register_graphql_mutation_field :cancel_recurring_logic, '::Mutations::RecurringLogics::Cancel'
113
+ register_graphql_mutation_field :cancel_recurring_logic, '::Mutations::RecurringLogics::Cancel'
113
114
 
114
- logger :dynflow, :enabled => true
115
- logger :action, :enabled => true
115
+ logger :dynflow, :enabled => true
116
+ logger :action, :enabled => true
116
117
 
117
- role 'Tasks Manager', [:view_foreman_tasks, :edit_foreman_tasks],
118
- 'Role granting permissions to inspect, cancel, resume and unlock tasks'
119
- role 'Tasks Reader', [:view_foreman_tasks],
120
- 'Role granting permissions to inspect tasks'
118
+ role 'Tasks Manager', [:view_foreman_tasks, :edit_foreman_tasks],
119
+ 'Role granting permissions to inspect, cancel, resume and unlock tasks'
120
+ role 'Tasks Reader', [:view_foreman_tasks],
121
+ 'Role granting permissions to inspect tasks'
121
122
 
122
- widget 'foreman_tasks/tasks/dashboard/tasks_status', :sizex => 6, :sizey => 1, :name => N_('Task Status')
123
- widget 'foreman_tasks/tasks/dashboard/latest_tasks_in_error_warning', :sizex => 6, :sizey => 1, :name => N_('Latest Warning/Error Tasks')
123
+ widget 'foreman_tasks/tasks/dashboard/tasks_status', :sizex => 6, :sizey => 1, :name => N_('Task Status')
124
+ widget 'foreman_tasks/tasks/dashboard/latest_tasks_in_error_warning', :sizex => 6, :sizey => 1, :name => N_('Latest Warning/Error Tasks')
124
125
 
125
- register_gettext domain: "foreman_tasks"
126
+ register_gettext domain: "foreman_tasks"
126
127
 
127
- ForemanTasks.dynflow.eager_load_actions!
128
- extend_observable_events(::Dynflow::Action.descendants.select { |klass| klass <= ::Actions::ObservableAction }.map(&:namespaced_event_names))
128
+ ForemanTasks.dynflow.eager_load_actions!
129
+ extend_observable_events(::Dynflow::Action.descendants.select { |klass| klass <= ::Actions::ObservableAction }.map(&:namespaced_event_names))
130
+ end
129
131
  end
130
132
  end
131
133
 
@@ -160,7 +162,7 @@ module ForemanTasks
160
162
  world.middleware.use Actions::Middleware::KeepCurrentTaxonomies
161
163
  world.middleware.use Actions::Middleware::KeepCurrentUser, :before => ::Dynflow::Middleware::Common::Transaction
162
164
  world.middleware.use Actions::Middleware::KeepCurrentTimezone
163
- world.middleware.use Actions::Middleware::KeepCurrentRequestID
165
+ world.middleware.use Actions::Middleware::KeepCurrentRequestId
164
166
  world.middleware.use ::Actions::Middleware::LoadSettingValues
165
167
  ForemanTasks.register_scheduled_task(Actions::CheckLongRunningTasks, ENV['FOREMAN_TASKS_CHECK_LONG_RUNNING_TASKS_CRONLINE'] || '0 0 * * *')
166
168
  end
@@ -310,15 +310,15 @@ namespace :foreman_tasks do
310
310
  SKIP_ERRORS = ['true', '1', 'y', 'yes'].include? (ENV['SKIP_FAILED'] || '').downcase
311
311
 
312
312
  filter = if ENV['TASK_SEARCH'].nil? && ENV['TASK_DAYS'].nil?
313
- "started_at > \"#{7.days.ago.to_s(:db)}\" || " \
314
- "(result != success && started_at > \"#{60.days.ago.to_s(:db)})\""
313
+ "started_at > \"#{7.days.ago.to_formatted_s(:db)}\" || " \
314
+ "(result != success && started_at > \"#{60.days.ago.to_formatted_s(:db)})\""
315
315
  else
316
316
  ENV['TASK_SEARCH'] || ''
317
317
  end
318
318
 
319
319
  if (days = ENV['TASK_DAYS'])
320
320
  filter += ' && ' unless filter == ''
321
- filter += "started_at > \"#{days.to_i.days.ago.to_s(:db)}\""
321
+ filter += "started_at > \"#{days.to_i.days.ago.to_formatted_s(:db)}\""
322
322
  end
323
323
 
324
324
  format = ENV['TASK_FORMAT'] || 'html'
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '9.2.3'.freeze
2
+ VERSION = '10.0.1'.freeze
3
3
  end
@@ -8,22 +8,33 @@ if gettext_find_task
8
8
  namespace :gettext do
9
9
  task :store_action_names => :environment do
10
10
  storage_file = "#{locale_path}/action_names.rb"
11
- puts "writing action translations to: #{storage_file}"
12
-
13
- klasses = Actions::EntryAction
14
- .subclasses
15
- .uniq
16
- .select do |action|
17
- src, = Object.const_source_location(action.to_s)
18
- src.start_with? @engine.root.to_s
11
+ method_names = [:plan, :run, :finalize]
12
+ instances = Actions::EntryAction
13
+ .descendants
14
+ .uniq
15
+ .map(&:allocate)
16
+ .select do |action|
17
+ method_names.any? do |method_name|
18
+ if action.respond_to?(method_name)
19
+ src, = action.method(method_name).source_location
20
+ src.start_with? @engine.root.to_s
21
+ end
22
+ end
19
23
  end
20
24
 
21
- File.write storage_file,
22
- "# Autogenerated!\n" +
23
- klasses
24
- .map { |klass| %[_("#{klass.allocate.humanized_name}")] }
25
- .sort
26
- .join("\n") + "\n"
25
+ if instances.any?
26
+ puts "writing action translations to: #{storage_file}"
27
+
28
+ File.write storage_file,
29
+ "# Autogenerated!\n" +
30
+ instances
31
+ .map { |instance| %[_("#{instance.humanized_name}")] }
32
+ .sort
33
+ .join("\n") + "\n"
34
+ elsif File.exist? storage_file
35
+ puts "Removing empty action translations file: #{storage_file}"
36
+ File.delete storage_file
37
+ end
27
38
  end
28
39
  end
29
40
 
@@ -1,9 +1,9 @@
1
1
  require 'foreman_tasks_test_helper'
2
2
 
3
3
  module ForemanTasks
4
- class KeepCurrentRequestIDTest < ActiveSupport::TestCase
4
+ class KeepCurrentRequestIdTest < ActiveSupport::TestCase
5
5
  class DummyAction < Actions::EntryAction
6
- middleware.use ::Actions::Middleware::KeepCurrentRequestID
6
+ middleware.use ::Actions::Middleware::KeepCurrentRequestId
7
7
 
8
8
  def plan(plan = false)
9
9
  plan_self if plan
@@ -18,7 +18,7 @@ module ForemanTasks
18
18
  end
19
19
  end
20
20
 
21
- describe Actions::Middleware::KeepCurrentRequestID do
21
+ describe Actions::Middleware::KeepCurrentRequestId do
22
22
  include ::Dynflow::Testing
23
23
 
24
24
  before { @old_id = ::Logging.mdc['request'] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.2.3
4
+ version: 10.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-24 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: theforeman-rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.0
97
111
  description: |
98
112
  The goal of this plugin is to unify the way of showing task statuses across the Foreman instance.
99
113
  It defines Task model for keeping the information about the tasks and Lock for assigning the tasks
@@ -304,7 +318,6 @@ files:
304
318
  - lib/foreman_tasks/version.rb
305
319
  - lib/tasks/gettext.rake
306
320
  - locale/Makefile
307
- - locale/action_names.rb
308
321
  - locale/de/LC_MESSAGES/foreman_tasks.mo
309
322
  - locale/de/foreman_tasks.po
310
323
  - locale/en/LC_MESSAGES/foreman_tasks.mo
@@ -1,6 +0,0 @@
1
- # Autogenerated!
2
- _("Action with sub plans")
3
- _("Check for long running tasks")
4
- _("Deliver notifications about long running tasks")
5
- _("Import Puppet classes")
6
- _("Import facts")