foreman_remote_execution 0.2.3 → 0.3.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/.gitignore +2 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +16 -5
  5. data/.tx/config +1 -1
  6. data/app/assets/javascripts/template_invocation.js +14 -1
  7. data/app/assets/stylesheets/job_invocations.css.scss +0 -13
  8. data/app/assets/stylesheets/template_invocation.css.scss +7 -13
  9. data/app/controllers/api/v2/foreign_input_sets_controller.rb +1 -1
  10. data/app/controllers/api/v2/job_invocations_controller.rb +12 -18
  11. data/app/controllers/api/v2/remote_execution_features_controller.rb +38 -0
  12. data/app/controllers/api/v2/template_inputs_controller.rb +1 -0
  13. data/app/controllers/job_invocations_controller.rb +3 -13
  14. data/app/controllers/job_templates_controller.rb +1 -1
  15. data/app/controllers/remote_execution_features_controller.rb +19 -0
  16. data/app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb +1 -22
  17. data/app/helpers/remote_execution_helper.rb +30 -12
  18. data/app/lib/actions/remote_execution/helpers/live_output.rb +2 -2
  19. data/app/lib/actions/remote_execution/run_host_job.rb +7 -4
  20. data/app/lib/actions/remote_execution/run_hosts_job.rb +14 -0
  21. data/app/lib/actions/remote_execution/run_proxy_command.rb +2 -2
  22. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +5 -4
  23. data/app/models/concerns/foreman_remote_execution/subnet_extensions.rb +1 -0
  24. data/app/models/input_template_renderer.rb +14 -3
  25. data/app/models/job_invocation.rb +6 -15
  26. data/app/models/job_invocation_composer.rb +131 -21
  27. data/app/models/job_template.rb +77 -22
  28. data/app/models/job_template_effective_user.rb +0 -2
  29. data/app/models/remote_execution_feature.rb +34 -0
  30. data/app/models/setting/remote_execution.rb +4 -1
  31. data/app/models/targeting.rb +2 -2
  32. data/app/models/template_input.rb +17 -13
  33. data/app/views/api/v2/remote_execution_features/base.json.rabl +3 -0
  34. data/app/views/api/v2/remote_execution_features/index.json.rabl +3 -0
  35. data/app/views/api/v2/remote_execution_features/main.json.rabl +3 -0
  36. data/app/views/api/v2/remote_execution_features/show.json.rabl +3 -0
  37. data/app/views/job_invocations/_form.html.erb +51 -40
  38. data/app/views/job_invocations/_preview_hosts_list.html.erb +1 -1
  39. data/app/views/job_invocations/_tab_hosts.html.erb +6 -3
  40. data/app/views/job_invocations/index.html.erb +11 -11
  41. data/app/views/job_templates/_custom_tabs.html.erb +4 -4
  42. data/app/views/job_templates/index.html.erb +5 -5
  43. data/app/views/overrides/nics/_execution_interface.html.erb +9 -1
  44. data/app/views/remote_execution_features/_form.html.erb +24 -0
  45. data/app/views/remote_execution_features/index.html.erb +21 -0
  46. data/app/views/remote_execution_features/show.html.erb +3 -0
  47. data/app/views/template_inputs/_form.html.erb +1 -0
  48. data/app/views/template_inputs/_invocation_form.html.erb +7 -0
  49. data/app/views/templates/package_action.erb +17 -5
  50. data/app/views/templates/power_action.erb +22 -0
  51. data/app/views/templates/puppet_run_once.erb +1 -1
  52. data/config/routes.rb +4 -0
  53. data/db/migrate/20160113162007_expand_all_template_invocations.rb +1 -1
  54. data/db/migrate/20160118124600_create_remote_execution_features.rb +14 -0
  55. data/db/migrate/20160125155108_make_job_template_name_unique.rb +12 -0
  56. data/db/migrate/20160127134031_add_advanced_to_template_input.rb +11 -0
  57. data/db/migrate/20160127162711_reword_puppet_template_description.rb +9 -0
  58. data/db/migrate/20160203104056_add_concurrency_options_to_job_invocation.rb +6 -0
  59. data/db/seeds.d/70-job_templates.rb +2 -1
  60. data/doc/plugins/div_tag.rb +1 -1
  61. data/doc/plugins/plantuml.rb +1 -1
  62. data/doc/plugins/tags.rb +7 -8
  63. data/doc/plugins/toc.rb +0 -1
  64. data/foreman_remote_execution.gemspec +1 -1
  65. data/lib/foreman_remote_execution/engine.rb +10 -2
  66. data/lib/foreman_remote_execution/version.rb +1 -1
  67. data/locale/action_names.rb +8 -0
  68. data/locale/en/foreman_remote_execution.po +767 -11
  69. data/locale/foreman_remote_execution.pot +1026 -8
  70. data/test/functional/api/v2/foreign_input_sets_controller_test.rb +1 -1
  71. data/test/functional/api/v2/job_invocations_controller_test.rb +0 -9
  72. data/test/functional/api/v2/job_templates_controller_test.rb +11 -11
  73. data/test/functional/api/v2/remote_execution_features_controller_test.rb +35 -0
  74. data/test/functional/api/v2/template_inputs_controller_test.rb +1 -1
  75. data/test/unit/actions/run_hosts_job_test.rb +48 -7
  76. data/test/unit/actions/run_proxy_command_test.rb +1 -1
  77. data/test/unit/concerns/host_extensions_test.rb +11 -0
  78. data/test/unit/input_template_renderer_test.rb +4 -4
  79. data/test/unit/job_invocation_composer_test.rb +52 -2
  80. data/test/unit/job_invocation_test.rb +1 -1
  81. data/test/unit/job_template_test.rb +126 -3
  82. data/test/unit/remote_execution_feature_test.rb +42 -0
  83. data/test/unit/targeting_test.rb +4 -4
  84. metadata +26 -7
  85. data/app/views/job_invocation_task_groups/_job_invocation_task_group.html.erb +0 -31
  86. data/app/views/unattended/snippets/_remote_execution_ssh_keys.erb +0 -18
  87. data/db/seeds.d/80-provision_templates.rb +0 -21
@@ -0,0 +1,42 @@
1
+ require 'test_plugin_helper'
2
+
3
+ describe RemoteExecutionFeature do
4
+
5
+ let(:install_feature) do
6
+ RemoteExecutionFeature.register(:katello_install_package, N_('Katello: Install package'),
7
+ :description => 'Install package via Katello user interface',
8
+ :provided_inputs => ['package'])
9
+ end
10
+
11
+ let(:package_template) do
12
+ FactoryGirl.create(:job_template).tap do |job_template|
13
+ job_template.job_category = 'Package Action'
14
+ job_template.name = 'Package Action - SSH Default'
15
+ job_template.template_inputs.create(:name => 'package', :input_type => 'user')
16
+ end
17
+ end
18
+
19
+ let(:host) { FactoryGirl.create(:host) }
20
+
21
+ before do
22
+ User.current = users :admin
23
+ install_feature.update_attributes!(:job_template_id => package_template.id)
24
+ end
25
+
26
+ describe 'composer' do
27
+ it 'prepares composer for given feature based on the mapping' do
28
+ composer = JobInvocationComposer.for_feature(:katello_install_package, host, :package => 'zsh')
29
+ assert composer.valid?
30
+ composer.pattern_template_invocations.size.must_equal 1
31
+ template_invocation = composer.pattern_template_invocations.first
32
+ template_invocation.template.must_equal package_template
33
+ template_invocation.input_values.size.must_equal 1
34
+
35
+ input_value = template_invocation.input_values.first
36
+ input_value.value.must_equal 'zsh'
37
+ input_value.template_input.name.must_equal 'package'
38
+
39
+ composer.targeting.search_query.must_equal "name = #{host.name}"
40
+ end
41
+ end
42
+ end
@@ -16,7 +16,7 @@ describe Targeting do
16
16
  end
17
17
 
18
18
  context 'resolved_at is set' do
19
- before { targeting.resolved_at = Time.now }
19
+ before { targeting.resolved_at = Time.now.getlocal }
20
20
  it { assert targeting.resolved? }
21
21
  end
22
22
 
@@ -86,7 +86,7 @@ describe Targeting do
86
86
  end
87
87
 
88
88
  context 'for two hosts' do
89
- let(:query) { targeting.build_query_from_hosts([ host.id, second_host.id ]) }
89
+ let(:query) { Targeting.build_query_from_hosts([ host.id, second_host.id ]) }
90
90
 
91
91
  it 'builds query using host names joining with or' do
92
92
  query.must_include "name = #{host.name}"
@@ -99,7 +99,7 @@ describe Targeting do
99
99
  end
100
100
 
101
101
  context 'for one host' do
102
- let(:query) { targeting.build_query_from_hosts([ host.id ]) }
102
+ let(:query) { Targeting.build_query_from_hosts([ host.id ]) }
103
103
 
104
104
  it 'builds query using host name' do
105
105
  query.must_equal "name = #{host.name}"
@@ -109,7 +109,7 @@ describe Targeting do
109
109
  end
110
110
 
111
111
  context 'for no id' do
112
- let(:query) { targeting.build_query_from_hosts([]) }
112
+ let(:query) { Targeting.build_query_from_hosts([]) }
113
113
 
114
114
  it 'builds query to find all hosts' do
115
115
  Host.search_for(query).must_include host
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-11 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.8
33
+ version: 0.8.10
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.8
40
+ version: 0.8.10
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: foreman-tasks
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -143,9 +143,11 @@ files:
143
143
  - app/controllers/api/v2/foreign_input_sets_controller.rb
144
144
  - app/controllers/api/v2/job_invocations_controller.rb
145
145
  - app/controllers/api/v2/job_templates_controller.rb
146
+ - app/controllers/api/v2/remote_execution_features_controller.rb
146
147
  - app/controllers/api/v2/template_inputs_controller.rb
147
148
  - app/controllers/job_invocations_controller.rb
148
149
  - app/controllers/job_templates_controller.rb
150
+ - app/controllers/remote_execution_features_controller.rb
149
151
  - app/controllers/template_invocations_controller.rb
150
152
  - app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
151
153
  - app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb
@@ -176,6 +178,7 @@ files:
176
178
  - app/models/job_invocation_task_group.rb
177
179
  - app/models/job_template.rb
178
180
  - app/models/job_template_effective_user.rb
181
+ - app/models/remote_execution_feature.rb
179
182
  - app/models/remote_execution_provider.rb
180
183
  - app/models/setting/remote_execution.rb
181
184
  - app/models/ssh_execution_provider.rb
@@ -204,13 +207,16 @@ files:
204
207
  - app/views/api/v2/job_templates/main.json.rabl
205
208
  - app/views/api/v2/job_templates/show.json.rabl
206
209
  - app/views/api/v2/job_templates/update.json.rabl
210
+ - app/views/api/v2/remote_execution_features/base.json.rabl
211
+ - app/views/api/v2/remote_execution_features/index.json.rabl
212
+ - app/views/api/v2/remote_execution_features/main.json.rabl
213
+ - app/views/api/v2/remote_execution_features/show.json.rabl
207
214
  - app/views/api/v2/template_inputs/base.json.rabl
208
215
  - app/views/api/v2/template_inputs/create.json.rabl
209
216
  - app/views/api/v2/template_inputs/index.json.rabl
210
217
  - app/views/api/v2/template_inputs/main.json.rabl
211
218
  - app/views/api/v2/template_inputs/show.json.rabl
212
219
  - app/views/dashboard/.gitkeep
213
- - app/views/job_invocation_task_groups/_job_invocation_task_group.html.erb
214
220
  - app/views/job_invocation_task_groups/_job_invocation_task_groups.html.erb
215
221
  - app/views/job_invocations/_description_fields.html.erb
216
222
  - app/views/job_invocations/_form.html.erb
@@ -234,17 +240,21 @@ files:
234
240
  - app/views/overrides/nics/_execution_interface.html.erb
235
241
  - app/views/overrides/subnets/_rex_tab.html.erb
236
242
  - app/views/overrides/subnets/_rex_tab_pane.html.erb
243
+ - app/views/remote_execution_features/_form.html.erb
244
+ - app/views/remote_execution_features/index.html.erb
245
+ - app/views/remote_execution_features/show.html.erb
237
246
  - app/views/template_inputs/_foreign_input_set_form.html.erb
238
247
  - app/views/template_inputs/_form.html.erb
248
+ - app/views/template_inputs/_invocation_form.html.erb
239
249
  - app/views/template_invocations/_output_line_set.html.erb
240
250
  - app/views/template_invocations/_refresh.js.erb
241
251
  - app/views/template_invocations/show.html.erb
242
252
  - app/views/template_invocations/show.js.erb
243
253
  - app/views/templates/package_action.erb
254
+ - app/views/templates/power_action.erb
244
255
  - app/views/templates/puppet_run_once.erb
245
256
  - app/views/templates/run_command.erb
246
257
  - app/views/templates/service_action.erb
247
- - app/views/unattended/snippets/_remote_execution_ssh_keys.erb
248
258
  - config/routes.rb
249
259
  - db/migrate/20150612121541_add_job_template_to_template.rb
250
260
  - db/migrate/20150616080015_create_template_input.rb
@@ -273,9 +283,13 @@ files:
273
283
  - db/migrate/20160113162007_expand_all_template_invocations.rb
274
284
  - db/migrate/20160114120200_rename_job_categories.rb
275
285
  - db/migrate/20160114125628_rename_job_name_to_job_category.rb
286
+ - db/migrate/20160118124600_create_remote_execution_features.rb
287
+ - db/migrate/20160125155108_make_job_template_name_unique.rb
288
+ - db/migrate/20160127134031_add_advanced_to_template_input.rb
289
+ - db/migrate/20160127162711_reword_puppet_template_description.rb
290
+ - db/migrate/20160203104056_add_concurrency_options_to_job_invocation.rb
276
291
  - db/seeds.d/60-ssh_proxy_feature.rb
277
292
  - db/seeds.d/70-job_templates.rb
278
- - db/seeds.d/80-provision_templates.rb
279
293
  - db/seeds.d/90-bookmarks.rb
280
294
  - doc/.bin/.gitkeep
281
295
  - doc/.gitignore
@@ -320,6 +334,7 @@ files:
320
334
  - lib/foreman_remote_execution/version.rb
321
335
  - lib/tasks/foreman_remote_execution_tasks.rake
322
336
  - locale/Makefile
337
+ - locale/action_names.rb
323
338
  - locale/en/foreman_remote_execution.po
324
339
  - locale/foreman_remote_execution.pot
325
340
  - locale/gemspec.rb
@@ -327,6 +342,7 @@ files:
327
342
  - test/functional/api/v2/foreign_input_sets_controller_test.rb
328
343
  - test/functional/api/v2/job_invocations_controller_test.rb
329
344
  - test/functional/api/v2/job_templates_controller_test.rb
345
+ - test/functional/api/v2/remote_execution_features_controller_test.rb
330
346
  - test/functional/api/v2/template_inputs_controller_test.rb
331
347
  - test/test_plugin_helper.rb
332
348
  - test/unit/actions/run_hosts_job_test.rb
@@ -340,6 +356,7 @@ files:
340
356
  - test/unit/job_template_effective_user_test.rb
341
357
  - test/unit/job_template_test.rb
342
358
  - test/unit/proxy_load_balancer_test.rb
359
+ - test/unit/remote_execution_feature_test.rb
343
360
  - test/unit/remote_execution_provider_test.rb
344
361
  - test/unit/targeting_test.rb
345
362
  - test/unit/template_input_test.rb
@@ -373,6 +390,7 @@ test_files:
373
390
  - test/functional/api/v2/foreign_input_sets_controller_test.rb
374
391
  - test/functional/api/v2/job_invocations_controller_test.rb
375
392
  - test/functional/api/v2/job_templates_controller_test.rb
393
+ - test/functional/api/v2/remote_execution_features_controller_test.rb
376
394
  - test/functional/api/v2/template_inputs_controller_test.rb
377
395
  - test/test_plugin_helper.rb
378
396
  - test/unit/actions/run_hosts_job_test.rb
@@ -386,6 +404,7 @@ test_files:
386
404
  - test/unit/job_template_effective_user_test.rb
387
405
  - test/unit/job_template_test.rb
388
406
  - test/unit/proxy_load_balancer_test.rb
407
+ - test/unit/remote_execution_feature_test.rb
389
408
  - test/unit/remote_execution_provider_test.rb
390
409
  - test/unit/targeting_test.rb
391
410
  - test/unit/template_input_test.rb
@@ -1,31 +0,0 @@
1
- <% job_invocation = task_group.job_invocation %>
2
- <table class='table table-condensed'>
3
- <tr>
4
- <th>ID</th>
5
- <td><%= link_to(job_invocation.id, job_invocation) %></td>
6
- </tr>
7
- <tr>
8
- <th>Job Name</th>
9
- <td><%= job_invocation.job_category %></td>
10
- </tr>
11
- <tr>
12
- <th>Status</th>
13
- <td><%= link_to_invocation_task_if_authorized(job_invocation) %></td>
14
- </tr>
15
- <tr>
16
- <th>Succeeded</th>
17
- <td><%= invocation_count(job_invocation, :output_key => :success_count) %></td>
18
- </tr>
19
- <tr>
20
- <th>Failed</th>
21
- <td><%= invocation_count(job_invocation, :output_key => :failed_count) %></td>
22
- </tr>
23
- <tr>
24
- <th>Pending</th>
25
- <td><%= invocation_count(job_invocation, :output_key => :pending_count) %></td>
26
- </tr>
27
- <tr>
28
- <th>Total hosts</th>
29
- <td><%= invocation_count(job_invocation, :output_key => :total_count) %></td>
30
- </tr>
31
- </table>
@@ -1,18 +0,0 @@
1
- <%#
2
- kind: snippet
3
- name: remote_execution_ssh_keys
4
- %>
5
-
6
- <% if !@host.params['remote_execution_ssh_keys'].blank? %>
7
- <% ssh_user = @host.params['remote_execution_ssh_user'] || 'root' %>
8
- <% ssh_path = "~#{ssh_user}/.ssh" %>
9
-
10
- mkdir -p <%= ssh_path %>
11
-
12
- cat << EOF >> <%= ssh_path %>/authorized_keys
13
- <%= @host.params['remote_execution_ssh_keys'].join("\n") %>
14
- EOF
15
-
16
- chmod 700 <%= ssh_path %>
17
- chmod 600 <%= ssh_path %>/authorized_keys
18
- <% end %>
@@ -1,21 +0,0 @@
1
- ProvisioningTemplate.without_auditing do
2
- templates = [{:name => 'remote_execution_ssh_keys', :source => 'snippets/_remote_execution_ssh_keys.erb', :snippet => true}]
3
-
4
- defaults = {:vendor => 'Remote Execution', :default => true, :locked => true}
5
-
6
- templates.each do |template|
7
- next if ProvisioningTemplate.find_by_name(template[:name])
8
-
9
- template.merge!(defaults)
10
-
11
- t= ProvisioningTemplate.create({
12
- :snippet => false,
13
- :template => File.read(File.join("#{ForemanRemoteExecution::Engine.root}/app/views/unattended", template.delete(:source)))
14
- }.merge(template))
15
-
16
- t.organizations << (Organization.all - t.organizations)
17
- t.locations << (Location.all - t.locations)
18
-
19
- raise "Unable to create template #{t.name}: #{format_errors t}" if t.nil? || t.errors.any?
20
- end
21
- end