foreman_salt 8.0.4 → 9.0.0

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
- SHA256:
3
- metadata.gz: f6b102a6fc74aec003d945ca7d88f86963c673fc624e8867f84fd59ee061d778
4
- data.tar.gz: a1a9409a364838b09777da3477e1037def275fe913544de8766ebd9b2a1d99c5
2
+ SHA1:
3
+ metadata.gz: dcb0cd457b3e5c9000833aaa9df08803939fa100
4
+ data.tar.gz: e3d96bb062af2c2b6b2c67755812227e6c318567
5
5
  SHA512:
6
- metadata.gz: 8ad8328433e56b07411ee20fa88f7df325ab40bbd7ba4d2fca557bd8148260929e3027e71319d8f79bbc0795da33f122621a9fb9e13395020af100978e5331c7
7
- data.tar.gz: 423f85d580b378fa4bb488bee0d917ed6aa7501dc84e3237a5111dc79f321f9ef15958e00243bfe93f3d0ef6f4b90eadc63e20cdcf621f9a27824dc38562cafa
6
+ metadata.gz: adc4191bdf884bce9b3bb4c19a89ae8b479219fda7b680ce0e3fa2443f3b59f1ae13f1ec3e96ce977bb44e9b6c2b9f621862c239a60d4d25c3d8e6ebac09a7dd
7
+ data.tar.gz: 7326754f45cd2725fdf075d1c4477bbc5bdc8c629b85a145e5e83bf1805ed0acfe990bc33a07b50b9772b41600a59f2613448c07608f3d481bab023922221cb0
@@ -21,7 +21,7 @@ module ForemanSalt
21
21
  param :smart_proxy_id, :identifier_dottable, :required => true
22
22
  param :state, String, :required => true, :desc => N_('State can be "accepted" or "rejected"')
23
23
  def update
24
- case params[:salt_key][:state]
24
+ case params[:key][:state]
25
25
  when 'accepted'
26
26
  @key.accept
27
27
  when 'rejected'
@@ -29,7 +29,7 @@ module ForemanSalt
29
29
  param_group :minion
30
30
  def update
31
31
  params[:minion][:salt_module_ids] = params[:minion].delete(:salt_state_ids) if params[:minion]
32
- process_response @salt_minion.update_attributes(params.require(:minion).permit(:salt_proxy_id, :salt_environment_id, :salt_module_ids => []))
32
+ process_response @salt_minion.update_attributes(params[:minion])
33
33
  end
34
34
 
35
35
  def controller_permission
@@ -66,7 +66,7 @@ module ForemanSalt
66
66
  end
67
67
  clean_orphans
68
68
  end
69
- render :plain => states.to_json
69
+ render :text => states.to_json
70
70
  end
71
71
 
72
72
  def controller_permission
@@ -16,12 +16,12 @@ module ForemanSalt
16
16
 
17
17
  enc['environment'] = env
18
18
  respond_to do |format|
19
- format.html { render :plain => "<pre>#{ERB::Util.html_escape(enc.to_yaml)}</pre>" }
20
- format.yml { render :plain => enc.to_yaml }
19
+ format.html { render :text => "<pre>#{ERB::Util.html_escape(enc.to_yaml)}</pre>" }
20
+ format.yml { render :text => enc.to_yaml }
21
21
  end
22
22
  rescue
23
23
  logger.warn "Failed to generate external nodes for #{@minion} with #{$ERROR_INFO}"
24
- render(:plain => _('Unable to generate output, Check log files\n'), :status => 412) && return
24
+ render(:text => _('Unable to generate output, Check log files\n'), :status => 412) && return
25
25
  end
26
26
 
27
27
  def run
@@ -3,7 +3,7 @@ module ForemanSalt
3
3
  def index
4
4
  setup
5
5
  autosign = @api.autosign_list
6
- @autosign = autosign.paginate :page => params[:page], :per_page => Setting::General.entries_per_page
6
+ @autosign = autosign.paginate :page => params[:page], :per_page => Setting[:entries_per_page]
7
7
  end
8
8
 
9
9
  def new
@@ -9,7 +9,7 @@ module ForemanSalt
9
9
  else
10
10
  SmartProxies::SaltKeys.find_by_state @proxy, params[:state].downcase
11
11
  end
12
- @keys = keys.sort.paginate :page => params[:page], :per_page => Setting::General.entries_per_page
12
+ @keys = keys.sort.paginate :page => params[:page], :per_page => Setting[:entries_per_page]
13
13
  end
14
14
 
15
15
  def accept
@@ -4,8 +4,8 @@ module ForemanSalt
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- has_many :host_salt_modules, :foreign_key => :host_id, :class_name => '::ForemanSalt::HostSaltModule'
8
7
  has_many :salt_modules, :through => :host_salt_modules, :class_name => '::ForemanSalt::SaltModule'
8
+ has_many :host_salt_modules, :foreign_key => :host_id, :class_name => '::ForemanSalt::HostSaltModule'
9
9
 
10
10
  belongs_to :salt_proxy, :class_name => 'SmartProxy'
11
11
  belongs_to :salt_environment, :class_name => 'ForemanSalt::SaltEnvironment'
@@ -15,9 +15,9 @@ module ForemanSalt
15
15
  alias_method_chain :inherited_attributes, :salt
16
16
  alias_method_chain :configuration?, :salt
17
17
 
18
- scoped_search :in => :salt_modules, :on => :name, :complete_value => true, :rename => :salt_state
19
- scoped_search :in => :salt_environment, :on => :name, :complete_value => true, :rename => :salt_environment
20
- scoped_search :in => :salt_proxy, :on => :name, :complete_value => true, :rename => :saltmaster
18
+ scoped_search :relation => :salt_modules, :on => :name, :complete_value => true, :rename => :salt_state
19
+ scoped_search :relation => :salt_environment, :on => :name, :complete_value => true, :rename => :salt_environment
20
+ scoped_search :relation => :salt_proxy, :on => :name, :complete_value => true, :rename => :saltmaster
21
21
 
22
22
  validate :salt_modules_in_host_environment
23
23
 
@@ -4,15 +4,15 @@ module ForemanSalt
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- has_many :hostgroup_salt_modules, :class_name => '::ForemanSalt::HostgroupSaltModule'
8
7
  has_many :salt_modules, :through => :hostgroup_salt_modules, :class_name => '::ForemanSalt::SaltModule'
8
+ has_many :hostgroup_salt_modules, :class_name => '::ForemanSalt::HostgroupSaltModule'
9
9
 
10
10
  belongs_to :salt_proxy, :class_name => 'SmartProxy'
11
11
  belongs_to :salt_environment, :class_name => 'ForemanSalt::SaltEnvironment'
12
12
 
13
- scoped_search :in => :salt_modules, :on => :name, :complete_value => true, :rename => :salt_state
14
- scoped_search :in => :salt_environment, :on => :name, :complete_value => true, :rename => :salt_environment
15
- scoped_search :in => :salt_proxy, :on => :name, :complete_value => true, :rename => :saltmaster
13
+ scoped_search :relation => :salt_modules, :on => :name, :complete_value => true, :rename => :salt_state
14
+ scoped_search :relation => :salt_environment, :on => :name, :complete_value => true, :rename => :salt_environment
15
+ scoped_search :relation => :salt_proxy, :on => :name, :complete_value => true, :rename => :saltmaster
16
16
  end
17
17
 
18
18
  def all_salt_modules
@@ -1,5 +1,5 @@
1
1
  module ForemanSalt
2
- class HostSaltModule < ActiveRecord::Base
2
+ class HostSaltModule < ApplicationRecord
3
3
  belongs_to :host, :class_name => 'Host::Managed', :foreign_key => :host_id
4
4
  belongs_to :salt_module
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ForemanSalt
2
- class HostgroupSaltModule < ActiveRecord::Base
2
+ class HostgroupSaltModule < ApplicationRecord
3
3
  belongs_to :hostgroup
4
4
  belongs_to :salt_module
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ForemanSalt
2
- class SaltEnvironment < ActiveRecord::Base
2
+ class SaltEnvironment < ApplicationRecord
3
3
  include Authorizable
4
4
  extend FriendlyId
5
5
  friendly_id :name
@@ -7,14 +7,14 @@ module ForemanSalt
7
7
  has_many :hosts, :class_name => '::Host::Managed'
8
8
  has_many :hostgroups, :class_name => '::Hostgroup'
9
9
 
10
- has_many :salt_module_environments
11
10
  has_many :salt_modules, :through => :salt_module_environments, :before_remove => :remove_from_hosts
11
+ has_many :salt_module_environments
12
12
 
13
13
  validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d\.]+\z/, :message => N_('is alphanumeric and cannot contain spaces') }
14
14
 
15
15
  scoped_search :on => :name, :complete_value => true
16
- scoped_search :in => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
17
- scoped_search :in => :hosts, :on => :name, :complete_value => true, :rename => :host
16
+ scoped_search :relation => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
17
+ scoped_search :relation => :hosts, :on => :name, :complete_value => true, :rename => :host
18
18
 
19
19
  def self.humanize_class_name(_name = nil)
20
20
  _('Salt environment')
@@ -1,17 +1,17 @@
1
1
  module ForemanSalt
2
- class SaltModule < ActiveRecord::Base
2
+ class SaltModule < ApplicationRecord
3
3
  include Authorizable
4
4
  extend FriendlyId
5
5
  friendly_id :name
6
6
 
7
- has_many :host_salt_modules, :foreign_key => :salt_module_id
8
7
  has_many :hosts, :through => :host_salt_modules, :class_name => '::Host::Managed'
8
+ has_many :host_salt_modules, :foreign_key => :salt_module_id
9
9
 
10
- has_many :hostgroup_salt_modules, :foreign_key => :salt_module_id
11
10
  has_many :hostgroups, :through => :hostgroup_salt_modules
11
+ has_many :hostgroup_salt_modules, :foreign_key => :salt_module_id
12
12
 
13
- has_many :salt_module_environments
14
13
  has_many :salt_environments, :through => :salt_module_environments
14
+ has_many :salt_module_environments
15
15
 
16
16
  validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A(?:[\w\d\-]+\.{0,1})+[^\.]\z/, :message => N_('must be alphanumeric, can contain periods, dashes, underscores and must not contain spaces') }
17
17
 
@@ -22,9 +22,9 @@ module ForemanSalt
22
22
  scope :in_environment, ->(environment) { joins(:salt_environments).where('salt_module_environments.salt_environment_id' => environment) }
23
23
 
24
24
  scoped_search :on => :name, :complete_value => true
25
- scoped_search :in => :salt_environments, :on => :name, :complete_value => true, :rename => :environment
26
- scoped_search :in => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
27
- scoped_search :in => :hosts, :on => :name, :complete_value => true, :rename => :host
25
+ scoped_search :relation => :salt_environments, :on => :name, :complete_value => true, :rename => :environment
26
+ scoped_search :relation => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
27
+ scoped_search :relation => :hosts, :on => :name, :complete_value => true, :rename => :host
28
28
 
29
29
  def self.to_hash
30
30
  states = {}
@@ -1,5 +1,5 @@
1
1
  module ForemanSalt
2
- class SaltModuleEnvironment < ActiveRecord::Base
2
+ class SaltModuleEnvironment < ApplicationRecord
3
3
  belongs_to :salt_environment
4
4
  belongs_to :salt_module
5
5
 
@@ -31,12 +31,14 @@ module ForemanSalt
31
31
  end
32
32
 
33
33
  def accept
34
+ fail ::Foreman::Exception.new(N_('unable to re-accept an accepted key')) unless state == 'unaccepted'
34
35
  proxy = SmartProxy.find(smart_proxy_id)
35
36
  Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
36
37
  ProxyAPI::Salt.new(:url => proxy.url).key_accept name
37
38
  end
38
39
 
39
40
  def reject
41
+ fail ::Foreman::Exception.new(N_('unable to reject an accepted key')) unless state == 'unaccepted'
40
42
  proxy = SmartProxy.find(smart_proxy_id)
41
43
  Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
42
44
  ProxyAPI::Salt.new(:url => proxy.url).key_reject name
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '8.0.4'
2
+ VERSION = '9.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.4
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Benjamin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-06 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -183,14 +183,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  requirements: []
185
185
  rubyforge_project:
186
- rubygems_version: 2.7.6
186
+ rubygems_version: 2.5.2.1
187
187
  signing_key:
188
188
  specification_version: 4
189
189
  summary: Foreman Plug-in for Salt
190
190
  test_files:
191
191
  - test/factories/foreman_salt_factories.rb
192
- - test/functional/api/v2/salt_autosign_controller_test.rb
193
192
  - test/functional/api/v2/salt_environments_controller_test.rb
193
+ - test/functional/api/v2/salt_autosign_controller_test.rb
194
194
  - test/functional/api/v2/salt_keys_controller_test.rb
195
195
  - test/functional/api/v2/salt_states_controller_test.rb
196
196
  - test/functional/minions_controller_test.rb