foreman_remote_execution 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +11 -9
- data/.rubocop_todo.yml +146 -116
- data/app/controllers/api/v2/job_invocations_controller.rb +6 -1
- data/app/controllers/api/v2/job_templates_controller.rb +0 -1
- data/app/controllers/job_invocations_controller.rb +6 -1
- data/app/lib/actions/remote_execution/run_host_job.rb +1 -1
- data/app/models/concerns/foreman_remote_execution/errors_flattener.rb +3 -0
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +1 -1
- data/app/models/concerns/foreman_remote_execution/subnet_extensions.rb +1 -1
- data/app/models/foreign_input_set.rb +1 -1
- data/app/models/job_invocation.rb +1 -1
- data/app/models/job_invocation_composer.rb +2 -2
- data/app/models/job_invocation_task_group.rb +1 -1
- data/app/models/job_template.rb +3 -3
- data/app/models/job_template_effective_user.rb +1 -1
- data/app/models/remote_execution_feature.rb +1 -1
- data/app/models/target_remote_execution_proxy.rb +1 -1
- data/app/models/targeting.rb +2 -2
- data/app/models/targeting_host.rb +1 -1
- data/app/models/template_input.rb +1 -1
- data/app/models/template_invocation.rb +1 -1
- data/app/models/template_invocation_input_value.rb +1 -1
- data/db/migrate/20150612121541_add_job_template_to_template.rb +1 -1
- data/db/migrate/20150616080015_create_template_input.rb +1 -1
- data/db/migrate/20150708133241_add_targeting.rb +1 -1
- data/db/migrate/20150708133242_add_invocation.rb +1 -1
- data/db/migrate/20150708133305_add_template_invocation.rb +1 -1
- data/db/migrate/20150812110800_add_resolved_at_to_targeting.rb +1 -1
- data/db/migrate/20150812145900_add_last_task_id_to_job_invocation.rb +1 -1
- data/db/migrate/20150826191632_create_target_remote_execution_proxies.rb +1 -1
- data/db/migrate/20150827144500_change_targeting_search_query_type.rb +1 -1
- data/db/migrate/20150827152730_add_options_to_template_input.rb +1 -1
- data/db/migrate/20150903192731_add_execution_to_interface.rb +2 -2
- data/db/migrate/20150923125825_add_job_invocation_task_group.rb +1 -1
- data/db/migrate/20151013135415_add_pub_key_to_smart_proxy.rb +1 -1
- data/db/migrate/20151022105508_rename_last_task_id_column.rb +1 -1
- data/db/migrate/20151116105412_add_triggering_to_job_invocation.rb +1 -1
- data/db/migrate/20151120171100_add_effective_user_to_template_invocation.rb +1 -1
- data/db/migrate/20151124162300_create_job_template_effective_users.rb +1 -1
- data/db/migrate/20151203100824_add_description_to_job_invocation.rb +1 -1
- data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +2 -2
- data/db/migrate/20151217092555_migrate_to_task_groups.rb +2 -2
- data/db/migrate/20160108134600_create_template_input_sets.rb +1 -1
- data/db/migrate/20160108141144_make_job_name_default_to_something.rb +1 -1
- data/db/migrate/20160111113032_upcase_ssh_feature.rb +2 -2
- data/db/migrate/20160113161916_add_run_host_job_task_id_to_template_invocation.rb +1 -1
- data/db/migrate/20160113162007_expand_all_template_invocations.rb +3 -3
- data/db/migrate/20160114120200_rename_job_categories.rb +1 -1
- data/db/migrate/20160114125628_rename_job_name_to_job_category.rb +1 -1
- data/db/migrate/20160118124600_create_remote_execution_features.rb +1 -1
- data/db/migrate/20160125155108_make_job_template_name_unique.rb +1 -1
- data/db/migrate/20160127134031_add_advanced_to_template_input.rb +1 -1
- data/db/migrate/20160127162711_reword_puppet_template_description.rb +1 -1
- data/db/migrate/20160203104056_add_concurrency_options_to_job_invocation.rb +1 -1
- data/db/migrate/20160926225841_update_template_input_value.rb +1 -1
- data/db/migrate/20170110145641_add_host_action_button_to_remote_execution_feature.rb +1 -1
- data/db/migrate/20170613101039_add_timeout_to_job_templates_and_job_invocations.rb +1 -1
- data/db/migrate/20180110104432_rename_template_invocation_permission.rb +25 -0
- data/db/migrate/20180112125015_fix_taxable_taxonomies_job_template.rb +14 -0
- data/db/seeds.d/90-bookmarks.rb +1 -1
- data/foreman_remote_execution.gemspec +2 -1
- data/lib/foreman_remote_execution/engine.rb +3 -3
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/test/benchmark/run_hosts_job_benchmark.rb +10 -10
- data/test/benchmark/targeting_benchmark.rb +6 -6
- data/test/factories/foreman_remote_execution_factories.rb +14 -14
- data/test/functional/api/v2/foreign_input_sets_controller_test.rb +10 -15
- data/test/functional/api/v2/job_invocations_controller_test.rb +19 -8
- data/test/functional/api/v2/job_templates_controller_test.rb +12 -16
- data/test/functional/api/v2/remote_execution_features_controller_test.rb +3 -4
- data/test/functional/api/v2/template_inputs_controller_test.rb +8 -13
- data/test/test_plugin_helper.rb +4 -4
- data/test/unit/actions/run_hosts_job_test.rb +3 -3
- data/test/unit/concerns/exportable_test.rb +1 -1
- data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +2 -2
- data/test/unit/concerns/host_extensions_test.rb +20 -20
- data/test/unit/concerns/nic_extensions_test.rb +1 -1
- data/test/unit/input_template_renderer_test.rb +86 -86
- data/test/unit/job_invocation_composer_test.rb +17 -16
- data/test/unit/job_invocation_test.rb +10 -10
- data/test/unit/job_template_effective_user_test.rb +2 -2
- data/test/unit/job_template_importer_test.rb +3 -3
- data/test/unit/job_template_test.rb +15 -15
- data/test/unit/remote_execution_feature_test.rb +3 -3
- data/test/unit/remote_execution_provider_test.rb +15 -15
- data/test/unit/targeting_test.rb +3 -3
- data/test/unit/template_input_test.rb +1 -1
- data/test/unit/template_invocation_input_value_test.rb +17 -17
- metadata +19 -77
- data/doc/.gitignore +0 -7
- data/doc/Gemfile +0 -7
- data/doc/Rakefile +0 -41
- data/doc/_config.yml +0 -33
- data/doc/plugins/alert_block.rb +0 -27
- data/doc/plugins/div_tag.rb +0 -24
- data/doc/plugins/graphviz.rb +0 -121
- data/doc/plugins/plantuml.rb +0 -84
- data/doc/plugins/play.rb +0 -13
- data/doc/plugins/tags.rb +0 -137
- data/doc/plugins/toc.rb +0 -19
- data/doc/source/.nojekyll +0 -0
- data/doc/source/404.md +0 -6
- data/doc/source/_includes/footer.html +0 -21
- data/doc/source/_includes/header.html +0 -59
- data/doc/source/_includes/tocify.html +0 -6
- data/doc/source/_layouts/default.html +0 -9
- data/doc/source/_layouts/page.html +0 -25
- data/doc/source/atom.xml +0 -32
- data/doc/source/design/index.md +0 -1322
- data/doc/source/design/wireframes.pdf +0 -0
- data/doc/source/index.md +0 -18
- data/doc/source/static/css/bootstrap-responsive.min.css +0 -9
- data/doc/source/static/css/bootstrap.min.css +0 -866
- data/doc/source/static/css/jquery.tocify.css +0 -128
- data/doc/source/static/css/style.css +0 -285
- data/doc/source/static/css/syntax.css +0 -60
- data/doc/source/static/images/foreman.png +0 -0
- data/doc/source/static/images/glyphicons-halflings-white.png +0 -0
- data/doc/source/static/images/glyphicons-halflings.png +0 -0
- data/doc/source/static/js/bootstrap.min.js +0 -7
- data/doc/source/static/js/jquery-ui-1.9.2.custom.min.js +0 -6
- data/doc/source/static/js/jquery.js +0 -2
- data/doc/source/static/js/jquery.tocify.min.js +0 -3
- data/doc/source/static/js/scroll.js +0 -24
@@ -140,7 +140,7 @@ module Actions
|
|
140
140
|
# we don't want to load all template_invocations to verify so we construct Authorizer object manually and set
|
141
141
|
# the base collection to current template
|
142
142
|
authorizer = Authorizer.new(User.current, :collection => [ template_invocation.id ])
|
143
|
-
raise _('User can not execute this job template on %s') % host.name unless authorizer.can?(:
|
143
|
+
raise _('User can not execute this job template on %s') % host.name unless authorizer.can?(:create_template_invocations, template_invocation)
|
144
144
|
|
145
145
|
true
|
146
146
|
end
|
@@ -6,6 +6,8 @@ module ForemanRemoteExecution
|
|
6
6
|
|
7
7
|
def flattened_errors
|
8
8
|
errors = Hash.new { |h, k| h[k] = [] }
|
9
|
+
# self.errors is ActiveModel::Errors, not Hash and doesn't have the #each_key method
|
10
|
+
# rubocop:disable Performance/HashEachMethods
|
9
11
|
self.errors.keys.each do |key|
|
10
12
|
messages = self.errors[key]
|
11
13
|
invalid_objects = invalid_objects_for_attribute(key)
|
@@ -17,6 +19,7 @@ module ForemanRemoteExecution
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
22
|
+
# rubocop:enable Performance/HashEachMethods
|
20
23
|
errors.map { |key, messages| self.errors.full_message(key, messages.join(', ')) }
|
21
24
|
end
|
22
25
|
|
@@ -5,7 +5,7 @@ module ForemanRemoteExecution
|
|
5
5
|
base.instance_eval do
|
6
6
|
has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
|
7
7
|
has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
|
8
|
-
has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id'
|
8
|
+
has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id', :dependent => :destroy
|
9
9
|
has_many :run_host_job_tasks, :through => :template_invocations
|
10
10
|
|
11
11
|
scoped_search :relation => :run_host_job_tasks, :on => :result, :rename => 'job_invocation.result',
|
@@ -3,7 +3,7 @@ module ForemanRemoteExecution
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
has_many :target_remote_execution_proxies, :as => :target
|
6
|
+
has_many :target_remote_execution_proxies, :as => :target, :dependent => :destroy
|
7
7
|
has_many :remote_execution_proxies, :dependent => :destroy, :through => :target_remote_execution_proxies
|
8
8
|
end
|
9
9
|
end
|
@@ -130,7 +130,7 @@ class JobInvocationComposer
|
|
130
130
|
|
131
131
|
def template_invocations_params
|
132
132
|
template_invocation_params = { :template_id => template.id, :effective_user => api_params[:effective_user] }
|
133
|
-
template_invocation_params[:input_values] = api_params.fetch(:inputs, {}).map do |name, value|
|
133
|
+
template_invocation_params[:input_values] = api_params.fetch(:inputs, {}).to_h.map do |name, value|
|
134
134
|
input = template.template_inputs_with_foreign.find { |i| i.name == name }
|
135
135
|
unless input
|
136
136
|
raise ::Foreman::Exception, _('Unknown input %{input_name} for template %{template_name}') %
|
@@ -149,7 +149,7 @@ class JobInvocationComposer
|
|
149
149
|
|
150
150
|
def format_datetime(datetime)
|
151
151
|
return datetime if datetime.blank?
|
152
|
-
|
152
|
+
Time.parse(datetime).strftime('%Y-%m-%d %H:%M')
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
data/app/models/job_template.rb
CHANGED
@@ -13,7 +13,7 @@ class JobTemplate < ::Template
|
|
13
13
|
include Parameterizable::ByIdName
|
14
14
|
|
15
15
|
audited :allow_mass_assignment => true
|
16
|
-
has_many :audits, :as => :auditable, :class_name => Audited.audit_class.name
|
16
|
+
has_many :audits, :as => :auditable, :class_name => Audited.audit_class.name, :dependent => :nullify
|
17
17
|
has_many :all_template_invocations, :dependent => :destroy, :foreign_key => 'template_id', :class_name => 'TemplateInvocation'
|
18
18
|
has_many :template_invocations, -> { where('host_id IS NOT NULL') }, :foreign_key => 'template_id'
|
19
19
|
has_many :pattern_template_invocations, -> { where('host_id IS NULL') }, :foreign_key => 'template_id', :class_name => 'TemplateInvocation'
|
@@ -184,7 +184,7 @@ class JobTemplate < ::Template
|
|
184
184
|
end
|
185
185
|
|
186
186
|
# Create new inputs
|
187
|
-
inputs.
|
187
|
+
inputs.each_value { |new_input| template_inputs.build(new_input) }
|
188
188
|
end
|
189
189
|
|
190
190
|
def sync_foreign_input_sets(input_sets)
|
@@ -206,7 +206,7 @@ class JobTemplate < ::Template
|
|
206
206
|
end
|
207
207
|
|
208
208
|
# Create new input_sets
|
209
|
-
input_sets.
|
209
|
+
input_sets.each_value { |input_set| self.foreign_input_sets.build(input_set) }
|
210
210
|
end
|
211
211
|
|
212
212
|
def sync_feature(feature_name)
|
data/app/models/targeting.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Targeting <
|
1
|
+
class Targeting < ApplicationRecord
|
2
2
|
|
3
3
|
STATIC_TYPE = 'static_query'.freeze
|
4
4
|
DYNAMIC_TYPE = 'dynamic_query'.freeze
|
@@ -10,7 +10,7 @@ class Targeting < ActiveRecord::Base
|
|
10
10
|
|
11
11
|
has_many :targeting_hosts, :dependent => :destroy
|
12
12
|
has_many :hosts, :through => :targeting_hosts
|
13
|
-
has_one :job_invocation
|
13
|
+
has_one :job_invocation, :dependent => :delete
|
14
14
|
has_many :template_invocations, :through => :job_invocation
|
15
15
|
|
16
16
|
validates :targeting_type, :presence => true, :inclusion => Targeting::TYPES.keys
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddLastTaskIdToJobInvocation < ActiveRecord::Migration
|
1
|
+
class AddLastTaskIdToJobInvocation < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column :job_invocations, :last_task_id, :string, :limit => 255
|
4
4
|
add_index :job_invocations, [:last_task_id], :name => 'job_invocations_last_task_id'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddJobInvocationTaskGroup < ActiveRecord::Migration
|
1
|
+
class AddJobInvocationTaskGroup < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
3
|
add_column :job_invocations, :task_group_id, :integer, :index => true
|
4
4
|
add_foreign_key :job_invocations, :foreman_tasks_task_groups, :column => :task_group_id
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class RenameLastTaskIdColumn < ActiveRecord::Migration
|
1
|
+
class RenameLastTaskIdColumn < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
rename_column :job_invocations, :last_task_id, :task_id
|
4
4
|
rename_index :job_invocations, 'job_invocations_last_task_id', 'job_invocations_task_id'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddTriggeringToJobInvocation < ActiveRecord::Migration
|
1
|
+
class AddTriggeringToJobInvocation < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
3
|
add_column :job_invocations, :triggering_id, :integer, :index => true
|
4
4
|
add_foreign_key :job_invocations, :foreman_tasks_triggerings, :column => :triggering_id
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddDescriptionToJobInvocation < ActiveRecord::Migration
|
1
|
+
class AddDescriptionToJobInvocation < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
3
|
add_column :job_invocations, :description, :string, :limit => 255
|
4
4
|
add_column :templates, :description_format, :string, :limit => 255
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class AddHostIdToTemplateInvocation < ActiveRecord::Migration
|
2
|
-
class FakeTemplateInvocation <
|
1
|
+
class AddHostIdToTemplateInvocation < ActiveRecord::Migration[4.2]
|
2
|
+
class FakeTemplateInvocation < ApplicationRecord
|
3
3
|
self.table_name = 'template_invocations'
|
4
4
|
end
|
5
5
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddRunHostJobTaskIdToTemplateInvocation < ActiveRecord::Migration
|
1
|
+
class AddRunHostJobTaskIdToTemplateInvocation < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column :template_invocations, :run_host_job_task_id, :string, :limit => 255
|
4
4
|
add_index :template_invocations, [:run_host_job_task_id], :name => 'template_invocations_run_host_job_task_id'
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class ExpandAllTemplateInvocations < ActiveRecord::Migration
|
2
|
-
class FakeTemplateInvocation <
|
1
|
+
class ExpandAllTemplateInvocations < ActiveRecord::Migration[4.2]
|
2
|
+
class FakeTemplateInvocation < ApplicationRecord
|
3
3
|
self.table_name = 'template_invocations'
|
4
4
|
|
5
5
|
has_many :input_values, :class_name => 'FakeInputValue', :foreign_key => 'template_invocation_id'
|
6
6
|
end
|
7
7
|
|
8
|
-
class FakeInputValue <
|
8
|
+
class FakeInputValue < ApplicationRecord
|
9
9
|
self.table_name = 'template_invocation_input_values'
|
10
10
|
end
|
11
11
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddAdvancedToTemplateInput < ActiveRecord::Migration
|
1
|
+
class AddAdvancedToTemplateInput < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
3
|
add_column :template_inputs, :advanced, :boolean, :default => false, :null => false
|
4
4
|
template = JobTemplate.find_by(name: 'Package Action - SSH Default')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class RewordPuppetTemplateDescription < ActiveRecord::Migration
|
1
|
+
class RewordPuppetTemplateDescription < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
3
|
JobTemplate.where(:name => 'Puppet Run Once - SSH Default').update_all(:description_format => 'Run Puppet once with "%{puppet_options}"')
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddConcurrencyOptionsToJobInvocation < ActiveRecord::Migration
|
1
|
+
class AddConcurrencyOptionsToJobInvocation < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column :job_invocations, :concurrency_level, :integer, :null => true
|
4
4
|
add_column :job_invocations, :time_span, :integer, :null => true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddHostActionButtonToRemoteExecutionFeature < ActiveRecord::Migration
|
1
|
+
class AddHostActionButtonToRemoteExecutionFeature < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column :remote_execution_features, :host_action_button, :boolean, :null => false, :default => false
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddTimeoutToJobTemplatesAndJobInvocations < ActiveRecord::Migration
|
1
|
+
class AddTimeoutToJobTemplatesAndJobInvocations < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column :templates, :execution_timeout_interval, :integer
|
4
4
|
add_column :job_invocations, :execution_timeout_interval, :integer
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class RenameTemplateInvocationPermission < ActiveRecord::Migration[4.2]
|
2
|
+
PERMISSION_NAMES = %w(execute_template_invocation create_template_invocations).freeze
|
3
|
+
|
4
|
+
def up
|
5
|
+
switch_filtering_permission!(*PERMISSION_NAMES)
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
switch_filtering_permission!(*PERMISSION_NAMES.reverse)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def switch_filtering_permission!(old, new)
|
15
|
+
old_permission = Permission.find_by(:name => old)
|
16
|
+
return if old_permission.nil?
|
17
|
+
new_permission = Permission.find_or_create_by(:name => new,
|
18
|
+
:resource_type => 'TemplateInvocation')
|
19
|
+
old_permission.filterings.each do |filtering|
|
20
|
+
filtering.permission_id = new_permission.id
|
21
|
+
filtering.save!
|
22
|
+
end
|
23
|
+
old_permission.destroy!
|
24
|
+
end
|
25
|
+
end
|