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.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +11 -9
  3. data/.rubocop_todo.yml +146 -116
  4. data/app/controllers/api/v2/job_invocations_controller.rb +6 -1
  5. data/app/controllers/api/v2/job_templates_controller.rb +0 -1
  6. data/app/controllers/job_invocations_controller.rb +6 -1
  7. data/app/lib/actions/remote_execution/run_host_job.rb +1 -1
  8. data/app/models/concerns/foreman_remote_execution/errors_flattener.rb +3 -0
  9. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +1 -1
  10. data/app/models/concerns/foreman_remote_execution/subnet_extensions.rb +1 -1
  11. data/app/models/foreign_input_set.rb +1 -1
  12. data/app/models/job_invocation.rb +1 -1
  13. data/app/models/job_invocation_composer.rb +2 -2
  14. data/app/models/job_invocation_task_group.rb +1 -1
  15. data/app/models/job_template.rb +3 -3
  16. data/app/models/job_template_effective_user.rb +1 -1
  17. data/app/models/remote_execution_feature.rb +1 -1
  18. data/app/models/target_remote_execution_proxy.rb +1 -1
  19. data/app/models/targeting.rb +2 -2
  20. data/app/models/targeting_host.rb +1 -1
  21. data/app/models/template_input.rb +1 -1
  22. data/app/models/template_invocation.rb +1 -1
  23. data/app/models/template_invocation_input_value.rb +1 -1
  24. data/db/migrate/20150612121541_add_job_template_to_template.rb +1 -1
  25. data/db/migrate/20150616080015_create_template_input.rb +1 -1
  26. data/db/migrate/20150708133241_add_targeting.rb +1 -1
  27. data/db/migrate/20150708133242_add_invocation.rb +1 -1
  28. data/db/migrate/20150708133305_add_template_invocation.rb +1 -1
  29. data/db/migrate/20150812110800_add_resolved_at_to_targeting.rb +1 -1
  30. data/db/migrate/20150812145900_add_last_task_id_to_job_invocation.rb +1 -1
  31. data/db/migrate/20150826191632_create_target_remote_execution_proxies.rb +1 -1
  32. data/db/migrate/20150827144500_change_targeting_search_query_type.rb +1 -1
  33. data/db/migrate/20150827152730_add_options_to_template_input.rb +1 -1
  34. data/db/migrate/20150903192731_add_execution_to_interface.rb +2 -2
  35. data/db/migrate/20150923125825_add_job_invocation_task_group.rb +1 -1
  36. data/db/migrate/20151013135415_add_pub_key_to_smart_proxy.rb +1 -1
  37. data/db/migrate/20151022105508_rename_last_task_id_column.rb +1 -1
  38. data/db/migrate/20151116105412_add_triggering_to_job_invocation.rb +1 -1
  39. data/db/migrate/20151120171100_add_effective_user_to_template_invocation.rb +1 -1
  40. data/db/migrate/20151124162300_create_job_template_effective_users.rb +1 -1
  41. data/db/migrate/20151203100824_add_description_to_job_invocation.rb +1 -1
  42. data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +2 -2
  43. data/db/migrate/20151217092555_migrate_to_task_groups.rb +2 -2
  44. data/db/migrate/20160108134600_create_template_input_sets.rb +1 -1
  45. data/db/migrate/20160108141144_make_job_name_default_to_something.rb +1 -1
  46. data/db/migrate/20160111113032_upcase_ssh_feature.rb +2 -2
  47. data/db/migrate/20160113161916_add_run_host_job_task_id_to_template_invocation.rb +1 -1
  48. data/db/migrate/20160113162007_expand_all_template_invocations.rb +3 -3
  49. data/db/migrate/20160114120200_rename_job_categories.rb +1 -1
  50. data/db/migrate/20160114125628_rename_job_name_to_job_category.rb +1 -1
  51. data/db/migrate/20160118124600_create_remote_execution_features.rb +1 -1
  52. data/db/migrate/20160125155108_make_job_template_name_unique.rb +1 -1
  53. data/db/migrate/20160127134031_add_advanced_to_template_input.rb +1 -1
  54. data/db/migrate/20160127162711_reword_puppet_template_description.rb +1 -1
  55. data/db/migrate/20160203104056_add_concurrency_options_to_job_invocation.rb +1 -1
  56. data/db/migrate/20160926225841_update_template_input_value.rb +1 -1
  57. data/db/migrate/20170110145641_add_host_action_button_to_remote_execution_feature.rb +1 -1
  58. data/db/migrate/20170613101039_add_timeout_to_job_templates_and_job_invocations.rb +1 -1
  59. data/db/migrate/20180110104432_rename_template_invocation_permission.rb +25 -0
  60. data/db/migrate/20180112125015_fix_taxable_taxonomies_job_template.rb +14 -0
  61. data/db/seeds.d/90-bookmarks.rb +1 -1
  62. data/foreman_remote_execution.gemspec +2 -1
  63. data/lib/foreman_remote_execution/engine.rb +3 -3
  64. data/lib/foreman_remote_execution/version.rb +1 -1
  65. data/test/benchmark/run_hosts_job_benchmark.rb +10 -10
  66. data/test/benchmark/targeting_benchmark.rb +6 -6
  67. data/test/factories/foreman_remote_execution_factories.rb +14 -14
  68. data/test/functional/api/v2/foreign_input_sets_controller_test.rb +10 -15
  69. data/test/functional/api/v2/job_invocations_controller_test.rb +19 -8
  70. data/test/functional/api/v2/job_templates_controller_test.rb +12 -16
  71. data/test/functional/api/v2/remote_execution_features_controller_test.rb +3 -4
  72. data/test/functional/api/v2/template_inputs_controller_test.rb +8 -13
  73. data/test/test_plugin_helper.rb +4 -4
  74. data/test/unit/actions/run_hosts_job_test.rb +3 -3
  75. data/test/unit/concerns/exportable_test.rb +1 -1
  76. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +2 -2
  77. data/test/unit/concerns/host_extensions_test.rb +20 -20
  78. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  79. data/test/unit/input_template_renderer_test.rb +86 -86
  80. data/test/unit/job_invocation_composer_test.rb +17 -16
  81. data/test/unit/job_invocation_test.rb +10 -10
  82. data/test/unit/job_template_effective_user_test.rb +2 -2
  83. data/test/unit/job_template_importer_test.rb +3 -3
  84. data/test/unit/job_template_test.rb +15 -15
  85. data/test/unit/remote_execution_feature_test.rb +3 -3
  86. data/test/unit/remote_execution_provider_test.rb +15 -15
  87. data/test/unit/targeting_test.rb +3 -3
  88. data/test/unit/template_input_test.rb +1 -1
  89. data/test/unit/template_invocation_input_value_test.rb +17 -17
  90. metadata +19 -77
  91. data/doc/.gitignore +0 -7
  92. data/doc/Gemfile +0 -7
  93. data/doc/Rakefile +0 -41
  94. data/doc/_config.yml +0 -33
  95. data/doc/plugins/alert_block.rb +0 -27
  96. data/doc/plugins/div_tag.rb +0 -24
  97. data/doc/plugins/graphviz.rb +0 -121
  98. data/doc/plugins/plantuml.rb +0 -84
  99. data/doc/plugins/play.rb +0 -13
  100. data/doc/plugins/tags.rb +0 -137
  101. data/doc/plugins/toc.rb +0 -19
  102. data/doc/source/.nojekyll +0 -0
  103. data/doc/source/404.md +0 -6
  104. data/doc/source/_includes/footer.html +0 -21
  105. data/doc/source/_includes/header.html +0 -59
  106. data/doc/source/_includes/tocify.html +0 -6
  107. data/doc/source/_layouts/default.html +0 -9
  108. data/doc/source/_layouts/page.html +0 -25
  109. data/doc/source/atom.xml +0 -32
  110. data/doc/source/design/index.md +0 -1322
  111. data/doc/source/design/wireframes.pdf +0 -0
  112. data/doc/source/index.md +0 -18
  113. data/doc/source/static/css/bootstrap-responsive.min.css +0 -9
  114. data/doc/source/static/css/bootstrap.min.css +0 -866
  115. data/doc/source/static/css/jquery.tocify.css +0 -128
  116. data/doc/source/static/css/style.css +0 -285
  117. data/doc/source/static/css/syntax.css +0 -60
  118. data/doc/source/static/images/foreman.png +0 -0
  119. data/doc/source/static/images/glyphicons-halflings-white.png +0 -0
  120. data/doc/source/static/images/glyphicons-halflings.png +0 -0
  121. data/doc/source/static/js/bootstrap.min.js +0 -7
  122. data/doc/source/static/js/jquery-ui-1.9.2.custom.min.js +0 -6
  123. data/doc/source/static/js/jquery.js +0 -2
  124. data/doc/source/static/js/jquery.tocify.min.js +0 -3
  125. 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?(:execute_template_invocation, template_invocation)
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
@@ -1,4 +1,4 @@
1
- class ForeignInputSet < ActiveRecord::Base
1
+ class ForeignInputSet < ApplicationRecord
2
2
  include ForemanRemoteExecution::Exportable
3
3
 
4
4
  class CircularDependencyError < Foreman::Exception
@@ -1,4 +1,4 @@
1
- class JobInvocation < ActiveRecord::Base
1
+ class JobInvocation < ApplicationRecord
2
2
  include Authorizable
3
3
  audited :except => [ :task_id, :targeting_id, :task_group_id, :triggering_id ]
4
4
 
@@ -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
- DateTime.parse(datetime).strftime('%Y-%m-%d %H:%M')
152
+ Time.parse(datetime).strftime('%Y-%m-%d %H:%M')
153
153
  end
154
154
  end
155
155
 
@@ -1,6 +1,6 @@
1
1
  class JobInvocationTaskGroup < ::ForemanTasks::TaskGroup
2
2
 
3
- has_one :job_invocation, :foreign_key => :task_group_id
3
+ has_one :job_invocation, :foreign_key => :task_group_id, :dependent => :nullify
4
4
 
5
5
  alias resource job_invocation
6
6
 
@@ -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.values.each { |new_input| template_inputs.build(new_input) }
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.values.each { |input_set| self.foreign_input_sets.build(input_set) }
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)
@@ -1,4 +1,4 @@
1
- class JobTemplateEffectiveUser < ActiveRecord::Base
1
+ class JobTemplateEffectiveUser < ApplicationRecord
2
2
 
3
3
  belongs_to :job_template
4
4
 
@@ -1,4 +1,4 @@
1
- class RemoteExecutionFeature < ActiveRecord::Base
1
+ class RemoteExecutionFeature < ApplicationRecord
2
2
  VALID_OPTIONS = [:provided_inputs, :description, :host_action_button].freeze
3
3
  validates :label, :name, :presence => true, :uniqueness => true
4
4
 
@@ -1,4 +1,4 @@
1
- class TargetRemoteExecutionProxy < ActiveRecord::Base
1
+ class TargetRemoteExecutionProxy < ApplicationRecord
2
2
  belongs_to :remote_execution_proxy, :class_name => 'SmartProxy'
3
3
  belongs_to :target, :polymorphic => true
4
4
  end
@@ -1,4 +1,4 @@
1
- class Targeting < ActiveRecord::Base
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 TargetingHost < ActiveRecord::Base
1
+ class TargetingHost < ApplicationRecord
2
2
 
3
3
  belongs_to :targeting
4
4
  belongs_to_host
@@ -1,4 +1,4 @@
1
- class TemplateInput < ActiveRecord::Base
1
+ class TemplateInput < ApplicationRecord
2
2
  include ForemanRemoteExecution::Exportable
3
3
 
4
4
  class ValueNotReady < ::Foreman::Exception
@@ -1,4 +1,4 @@
1
- class TemplateInvocation < ActiveRecord::Base
1
+ class TemplateInvocation < ApplicationRecord
2
2
  include Authorizable
3
3
  include ForemanTasks::Concerns::ActionSubject
4
4
 
@@ -1,4 +1,4 @@
1
- class TemplateInvocationInputValue < ActiveRecord::Base
1
+ class TemplateInvocationInputValue < ApplicationRecord
2
2
 
3
3
  belongs_to :template_invocation
4
4
  belongs_to :template_input
@@ -1,4 +1,4 @@
1
- class AddJobTemplateToTemplate < ActiveRecord::Migration
1
+ class AddJobTemplateToTemplate < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :templates, :job_name, :string, :limit => 255
4
4
  add_column :templates, :provider_type, :string, :limit => 255
@@ -1,4 +1,4 @@
1
- class CreateTemplateInput < ActiveRecord::Migration
1
+ class CreateTemplateInput < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :template_inputs do |t|
4
4
  t.string :name, :null => false, :limit => 255
@@ -1,4 +1,4 @@
1
- class AddTargeting < ActiveRecord::Migration
1
+ class AddTargeting < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :targetings do |t|
4
4
  t.string :search_query, :limit => 255
@@ -1,4 +1,4 @@
1
- class AddInvocation< ActiveRecord::Migration
1
+ class AddInvocation< ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :job_invocations do |t|
4
4
  t.references :targeting, :null => false
@@ -1,4 +1,4 @@
1
- class AddTemplateInvocation < ActiveRecord::Migration
1
+ class AddTemplateInvocation < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :template_invocations do |t|
4
4
  t.references :template, :null => false
@@ -1,4 +1,4 @@
1
- class AddResolvedAtToTargeting < ActiveRecord::Migration
1
+ class AddResolvedAtToTargeting < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :targetings, :resolved_at, :datetime
4
4
  end
@@ -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 CreateTargetRemoteExecutionProxies < ActiveRecord::Migration
1
+ class CreateTargetRemoteExecutionProxies < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :target_remote_execution_proxies do |t|
4
4
  t.integer :remote_execution_proxy_id
@@ -1,4 +1,4 @@
1
- class ChangeTargetingSearchQueryType < ActiveRecord::Migration
1
+ class ChangeTargetingSearchQueryType < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  change_column :targetings, :search_query, :text
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddOptionsToTemplateInput < ActiveRecord::Migration
1
+ class AddOptionsToTemplateInput < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :template_inputs, :options, :text
4
4
  end
@@ -1,5 +1,5 @@
1
- class AddExecutionToInterface < ActiveRecord::Migration
2
- class FakeNic < ActiveRecord::Base
1
+ class AddExecutionToInterface < ActiveRecord::Migration[4.2]
2
+ class FakeNic < ApplicationRecord
3
3
  self.table_name = 'nics'
4
4
 
5
5
  def type
@@ -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 AddPubKeyToSmartProxy < ActiveRecord::Migration
1
+ class AddPubKeyToSmartProxy < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :smart_proxies, :pubkey, :text
4
4
  end
@@ -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 AddEffectiveUserToTemplateInvocation < ActiveRecord::Migration
1
+ class AddEffectiveUserToTemplateInvocation < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :template_invocations, :effective_user, :string, :limit => 255
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreateJobTemplateEffectiveUsers < ActiveRecord::Migration
1
+ class CreateJobTemplateEffectiveUsers < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :job_template_effective_users do |t|
4
4
  t.integer :job_template_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 < ActiveRecord::Base
1
+ class AddHostIdToTemplateInvocation < ActiveRecord::Migration[4.2]
2
+ class FakeTemplateInvocation < ApplicationRecord
3
3
  self.table_name = 'template_invocations'
4
4
  end
5
5
 
@@ -1,5 +1,5 @@
1
- class MigrateToTaskGroups < ActiveRecord::Migration
2
- class FakeJobInvocation < ActiveRecord::Base
1
+ class MigrateToTaskGroups < ActiveRecord::Migration[4.2]
2
+ class FakeJobInvocation < ApplicationRecord
3
3
  self.table_name = 'job_invocations'
4
4
  end
5
5
 
@@ -1,4 +1,4 @@
1
- class CreateTemplateInputSets < ActiveRecord::Migration
1
+ class CreateTemplateInputSets < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :foreign_input_sets do |t|
4
4
  t.integer :template_id, :null => false
@@ -1,4 +1,4 @@
1
- class MakeJobNameDefaultToSomething < ActiveRecord::Migration
1
+ class MakeJobNameDefaultToSomething < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  change_column :templates, :job_name, :string, :default => 'Miscellaneous', :limit => 255
4
4
  end
@@ -1,5 +1,5 @@
1
- class UpcaseSshFeature < ActiveRecord::Migration
2
- class FakeFeature < ActiveRecord::Base
1
+ class UpcaseSshFeature < ActiveRecord::Migration[4.2]
2
+ class FakeFeature < ApplicationRecord
3
3
  self.table_name = 'features'
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 < ActiveRecord::Base
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 < ActiveRecord::Base
8
+ class FakeInputValue < ApplicationRecord
9
9
  self.table_name = 'template_invocation_input_values'
10
10
  end
11
11
 
@@ -1,4 +1,4 @@
1
- class RenameJobCategories < ActiveRecord::Migration
1
+ class RenameJobCategories < ActiveRecord::Migration[4.2]
2
2
  MAP = {
3
3
  'Package Action - SSH Default' => ['Package Action', 'Packages'],
4
4
  'Puppet Run Once - SSH Default' => ['Puppet Run Once', 'Puppet'],
@@ -1,4 +1,4 @@
1
- class RenameJobNameToJobCategory < ActiveRecord::Migration
1
+ class RenameJobNameToJobCategory < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  rename_column :templates, :job_name, :job_category
4
4
  rename_column :job_invocations, :job_name, :job_category
@@ -1,4 +1,4 @@
1
- class CreateRemoteExecutionFeatures < ActiveRecord::Migration
1
+ class CreateRemoteExecutionFeatures < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :remote_execution_features do |t|
4
4
  t.string :label, :index => true, :null => false, :limit => 255
@@ -1,4 +1,4 @@
1
- class MakeJobTemplateNameUnique < ActiveRecord::Migration
1
+ class MakeJobTemplateNameUnique < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  duplicates = JobTemplate.unscoped.group(:name).count.delete_if { |_name, value| value == 1 }
4
4
  duplicates.each_key do |duplicated_name|
@@ -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 UpdateTemplateInputValue < ActiveRecord::Migration
1
+ class UpdateTemplateInputValue < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  change_column :template_invocation_input_values, :value, :text, :limit => 16.megabytes - 1
4
4
  end
@@ -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