foreman-tasks 0.10.6 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8c05ea538a9cdd681bcd80073a82d7fdd8aa15f
4
- data.tar.gz: cdfc54af9ee6edfe6165e744fb5b4b5eea22209a
3
+ metadata.gz: 0a0751a80db307b33d589a66517a407b71d125aa
4
+ data.tar.gz: 1df0beb219ea10aa2e3a498f0794f95ed241b9ee
5
5
  SHA512:
6
- metadata.gz: 31dad9d8f904055a9a17b6a7d06e73d1b0e6ed9eaf3e6702845e3edaf6318ce80d2948b558759ca808b800965dcde2564491c6cae8e8325988cc2ed4acaf29f5
7
- data.tar.gz: db3c8119caec600812d8353f30be0ed80d965ece6255f6191725804188e7459d9c5651fa758f16d6b1d3f62caf442872925f0da0e0bf05aff4b548f1757beeb8
6
+ metadata.gz: 50b67165fdaab0a560a0c5954423808a78eeeeedf6aeb7e16f236f178c59ec76251691f7fa57d37161184399b7b4795afabb2275db54f55ae4eeecc1f581c114
7
+ data.tar.gz: a061ad464f3954f0114c5d3c5c83a7a66a1295595672605b49f3918a179dfce73e4c210515a5653a180914efcedfcc31c95d02c013d3c9fbe5f3e52d75111856
@@ -1,6 +1,7 @@
1
1
  module ForemanTasks
2
2
  class TasksController < ::ApplicationController
3
3
  include Foreman::Controller::AutoCompleteSearch
4
+ include Foreman::Controller::CsvResponder
4
5
 
5
6
  before_action :restrict_dangerous_actions, :only => [:unlock, :force_unlock]
6
7
 
@@ -11,6 +12,14 @@ module ForemanTasks
11
12
  def index
12
13
  params[:order] ||= 'started_at DESC'
13
14
  @tasks = filter(resource_base)
15
+ respond_to do |format|
16
+ format.html do
17
+ render :index
18
+ end
19
+ format.csv do
20
+ csv_response(@tasks, [:to_label, :state, :result, 'started_at.in_time_zone', 'ended_at.in_time_zone', :username], ['Action', 'State', 'Result', 'Started At', 'Ended At', 'User'])
21
+ end
22
+ end
14
23
  end
15
24
 
16
25
  def sub_tasks
@@ -1,17 +1,7 @@
1
1
  module ForemanTasks
2
2
  module TasksHelper
3
- def format_task_input(task, include_action = false)
4
- return '-' unless task
5
- parts = []
6
- parts << task.get_humanized(:name) if include_action
7
- parts << Array(task.get_humanized(:input)).map do |part|
8
- if part.is_a? Array
9
- part[1][:text]
10
- else
11
- part.to_s
12
- end
13
- end.join('; ')
14
- parts.join(' ')
3
+ def format_task_input(task)
4
+ task ? task.to_label : '-'
15
5
  end
16
6
 
17
7
  def format_recurring_logic_limit(thing)
@@ -202,6 +202,19 @@ module ForemanTasks
202
202
  result.symbolize_keys
203
203
  end
204
204
 
205
+ def to_label
206
+ parts = []
207
+ parts << get_humanized(:name)
208
+ parts << Array(get_humanized(:input)).map do |part|
209
+ if part.is_a? Array
210
+ part[1][:text]
211
+ else
212
+ part.to_s
213
+ end
214
+ end.join('; ')
215
+ parts.join(' ')
216
+ end
217
+
205
218
  protected
206
219
 
207
220
  def generate_id
@@ -18,7 +18,7 @@
18
18
  <tr>
19
19
  <td><%= link_to(recurring_logic.cron_line, foreman_tasks_recurring_logic_path(recurring_logic)) %></td>
20
20
  <td><%= link_to(recurring_logic.tasks.count, foreman_tasks_tasks_url(:search => "task_group.id = #{recurring_logic.task_group.id}")) %></td>
21
- <td><%= format_task_input(recurring_logic.tasks.first, true) %></td>
21
+ <td><%= format_task_input(recurring_logic.tasks.first) %></td>
22
22
  <td><%= recurring_logic.tasks.order(:started_at).where('started_at IS NOT NULL').last.try(:started_at) || "-" %></td>
23
23
  <td><%= recurring_logic_next_occurrence recurring_logic %></td>
24
24
  <td><%= recurring_logic.iteration %></td>
@@ -10,7 +10,7 @@
10
10
  </tr>
11
11
  <tr>
12
12
  <th><%= N_("Action") %></th>
13
- <td><%= format_task_input(recurring_logic.tasks.last, true) %></td>
13
+ <td><%= format_task_input(recurring_logic.tasks.last) %></td>
14
14
  </tr>
15
15
  <tr>
16
16
  <th><%= N_("Last occurrence") %></th>
@@ -89,8 +89,7 @@
89
89
  <div class="col-md-6">
90
90
  <div>
91
91
  <span class="param-name list-group-item-heading"><%= _("Name") %>:</span>
92
- <% task_label = format_task_input(@task, true) %>
93
- <span class="param-value" data-original-title="<%= task_label %>" rel="twipsy"> <%= truncate(task_label, :length => 50) %></span>
92
+ <span class="param-value" data-original-title="<%= @task.to_label %>" rel="twipsy"> <%= truncate(@task.to_label, :length => 50) %></span>
94
93
  </div>
95
94
  <div>
96
95
  <span class="param-name list-group-item-heading"><%= _("Result") %>:</span>
@@ -1,5 +1,5 @@
1
1
  <% title _("Tasks") %>
2
- <% title_actions SETTINGS[:version].short <= '1.13' ? help_path : help_button %>
2
+ <% title_actions csv_link, help_button %>
3
3
  <% stylesheet 'foreman_tasks/tasks' %>
4
4
 
5
5
  <script>
@@ -27,7 +27,7 @@ $(document).on('click', ".table-two-pane td.two-pane-link", function(e) {
27
27
  <% for task in @tasks %>
28
28
  <tr>
29
29
  <td class="task-id two-pane-link ellipsis">
30
- <%= link_to_if_authorized(format_task_input(task, true),
30
+ <%= link_to_if_authorized(task.to_label,
31
31
  hash_for_foreman_tasks_task_path(:id => task)) %>
32
32
  </td>
33
33
  <td class="ellipsis"><%= task.state %></td>
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ class ArgvParser
6
+ attr_reader :options, :command
7
+
8
+ def initialize(argv, file)
9
+ @options = { foreman_root: Dir.pwd }
10
+
11
+ opts = OptionParser.new do |opts|
12
+ opts.banner = banner(file)
13
+
14
+ opts.on('-h', '--help', 'Show this message') do
15
+ puts opts
16
+ exit 1
17
+ end
18
+ opts.on('-f', '--foreman-root=PATH', "Path to Foreman Rails root path. By default '#{@options[:foreman_root]}'") do |path|
19
+ @options[:foreman_root] = path
20
+ end
21
+ opts.on('-c', '--executors-count=COUNT', 'Number of parallel executors to spawn. Overrides EXECUTORS_COUNT environment varaible.') do |count|
22
+ @options[:executors_count] = count.to_i
23
+ end
24
+ opts.on('-m', '--memory-limit=SIZE', 'Limits the amount of memory an executor can consume. Overrides EXECUTOR_MEMORY_LIMIT environment varaible. You can use kb, mb, gb') do |size|
25
+ @options[:memory_limit] = size
26
+ end
27
+ opts.on('--executor-memory-init-delay=SECONDS', 'Start memory polling after SECONDS. Overrides EXECUTOR_MEMORY_MONITOR_DELAY environment varaible.') do |seconds|
28
+ @options[:memory_init_delay] = seconds.to_i
29
+ end
30
+ opts.on('--executor-memory-polling-interval=SECONDS', 'Check for memory useage every SECONDS sec. Overrides EXECUTOR_MEMORY_MONITOR_INTERVAL environment varaible.') do |seconds|
31
+ @options[:memory_polling_interval] = seconds.to_i
32
+ end
33
+ end
34
+
35
+ args = opts.parse!(argv)
36
+ @command = args.first || 'run'
37
+ end
38
+
39
+ def banner(file)
40
+ banner = <<BANNER
41
+ Run Dynflow executor for Foreman tasks.
42
+
43
+ Usage: #{File.basename(file)} [options] ACTION"
44
+
45
+ ACTION can be one of:
46
+
47
+ * start - start the executor on background. It creates these files
48
+ in tmp/pid directory:
49
+
50
+ * dynflow_executor_monitor.pid - pid of monitor ensuring
51
+ the executor keeps running
52
+ * dynflow_executor.pid - pid of the executor itself
53
+ * dynflow_executor.output - stdout of the executor
54
+ * stop - stops the running executor
55
+ * restart - restarts the running executor
56
+ * run - run the executor in foreground
57
+
58
+ BANNER
59
+ banner
60
+ end
61
+ end
62
+
63
+ # run the script if it's executed explicitly
64
+ if $PROGRAM_NAME == __FILE__
65
+ parser = ArgvParser.new(ARGV, $PROGRAM_NAME)
66
+
67
+ Dir.chdir(parser.options[:foreman_root])
68
+ app_file = File.expand_path('./config/application', parser.options[:foreman_root])
69
+ require app_file
70
+
71
+ Dynflow::Rails::Daemon.new.run_background(parser.command, parser.options)
72
+ end
data/bin/foreman-tasks ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ foreman_root = '/usr/share/foreman'
4
+ Dir.chdir(foreman_root)
5
+ require File.expand_path('./config/application', foreman_root)
6
+ Dynflow::Rails::Daemon.new.run_background(ARGV.last, :foreman_root => foreman_root)
@@ -0,0 +1,16 @@
1
+ [Unit]
2
+ Description=Foreman jobs daemon
3
+ Documentation=https://github.com/theforeman/foreman-tasks
4
+ After=network.target remote-fs.target nss-lookup.target
5
+
6
+ [Service]
7
+ Type=forking
8
+ User=foreman
9
+ TimeoutSec=600
10
+ WorkingDirectory=/usr/share/foreman
11
+ ExecStart=/usr/bin/foreman-tasks start
12
+ ExecStop=/usr/bin/foreman-tasks stop
13
+ EnvironmentFile=-/etc/sysconfig/foreman-tasks
14
+
15
+ [Install]
16
+ WantedBy=multi-user.target
@@ -0,0 +1,26 @@
1
+ FOREMAN_USER=foreman
2
+ BUNDLER_EXT_HOME=/usr/share/foreman
3
+ RAILS_RELATIVE_URL_ROOT=$FOREMAN_PREFIX
4
+ RAILS_ENV=production
5
+ FOREMAN_LOGGING=warn
6
+ FOREMAN_LOGGING_SQL=warn
7
+ FOREMAN_TASK_PARAMS="-p foreman"
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
15
+
16
+ #Set the number of executors you want to run
17
+ #EXECUTORS_COUNT=1
18
+
19
+ #Set memory limit for executor process, before it's restarted automatically
20
+ #EXECUTOR_MEMORY_LIMIT=2gb
21
+
22
+ #Set delay before first memory polling to let executor initialize (in sec)
23
+ #EXECUTOR_MEMORY_MONITOR_DELAY=7200 #default: 2 hours
24
+
25
+ #Set memory polling interval, process memory will be checked every N seconds.
26
+ #EXECUTOR_MEMORY_MONITOR_INTERVAL=60
@@ -206,7 +206,6 @@ namespace :foreman_tasks do
206
206
 
207
207
  def self.copy_assets(tmp_dir)
208
208
  ['vendor/bootstrap/js/bootstrap.js',
209
- 'vendor/google-code-prettify/run_prettify.js',
210
209
  'vendor/jquery/jquery.js',
211
210
  'vendor/jquery/jquery.js',
212
211
  'javascripts/application.js',
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.10.6'.freeze
2
+ VERSION = '0.10.7'.freeze
3
3
  end
@@ -11,12 +11,11 @@ module ForemanTasks
11
11
  end
12
12
 
13
13
  it 'formats the task input properly' do
14
- format_task_input(@task).must_equal("user 'Anonymous Admin'")
15
- format_task_input(@task, true).must_equal("Create user 'Anonymous Admin'")
14
+ format_task_input(@task).must_equal("Create user 'Anonymous Admin'")
16
15
  end
17
16
 
18
17
  it 'displays the dash if task is nil' do
19
- format_task_input(nil, true).must_equal('-')
18
+ format_task_input(nil).must_equal('-')
20
19
  end
21
20
  end
22
21
 
@@ -36,8 +35,7 @@ module ForemanTasks
36
35
 
37
36
  it 'formats the task input properly' do
38
37
  response = "product 'product-2'; organization 'test-0'"
39
- format_task_input(@task).must_equal(response)
40
- format_task_input(@task, true).must_equal("Create #{response}")
38
+ format_task_input(@task).must_equal("Create #{response}")
41
39
  end
42
40
  end
43
41
  end
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: 0.10.6
4
+ version: 0.10.7
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: 2017-11-01 00:00:00.000000000 Z
11
+ date: 2017-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core
@@ -182,6 +182,8 @@ files:
182
182
  - app/views/foreman_tasks/tasks/dashboard/_tasks_status.html.erb
183
183
  - app/views/foreman_tasks/tasks/index.html.erb
184
184
  - app/views/foreman_tasks/tasks/show.html.erb
185
+ - bin/dynflow-executor
186
+ - bin/foreman-tasks
185
187
  - config/foreman-tasks.yaml.example
186
188
  - config/routes.rb
187
189
  - db/migrate/20131205204140_create_foreman_tasks.rb
@@ -200,6 +202,8 @@ files:
200
202
  - db/seeds.d/20-foreman_tasks_permissions.rb
201
203
  - db/seeds.d/60-dynflow_proxy_feature.rb
202
204
  - db/seeds.d/61-foreman_tasks_bookmarks.rb
205
+ - deploy/foreman-tasks.service
206
+ - deploy/foreman-tasks.sysconfig
203
207
  - extra/dynflow-debug.sh
204
208
  - extra/dynflow-executor.example
205
209
  - foreman-tasks.gemspec