foreman_salt 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -8
  3. data/Rakefile +1 -1
  4. data/app/controllers/foreman_salt/api/v2/jobs_controller.rb +4 -4
  5. data/app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb +4 -4
  6. data/app/controllers/foreman_salt/concerns/smart_proxy_auth_extensions.rb +2 -2
  7. data/app/controllers/foreman_salt/concerns/unattended_controller_extensions.rb +1 -1
  8. data/app/controllers/foreman_salt/salt_environments_controller.rb +1 -1
  9. data/app/controllers/foreman_salt/salt_keys_controller.rb +4 -4
  10. data/app/controllers/foreman_salt/salt_modules_controller.rb +1 -1
  11. data/app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb +4 -4
  12. data/app/helpers/concerns/foreman_salt/smart_proxies_helper_extensions.rb +2 -2
  13. data/app/helpers/foreman_salt/salt_keys_helper.rb +1 -1
  14. data/app/lib/proxy_api/salt.rb +21 -21
  15. data/app/models/foreman_salt/concerns/host_managed_extensions.rb +7 -7
  16. data/app/models/foreman_salt/concerns/hostgroup_extensions.rb +5 -5
  17. data/app/models/foreman_salt/concerns/orchestration/salt.rb +12 -12
  18. data/app/models/foreman_salt/salt_environment.rb +4 -4
  19. data/app/models/foreman_salt/salt_module.rb +4 -4
  20. data/app/overrides/foreman/salt_modules/_host_tab_pane.html.erb +2 -2
  21. data/app/overrides/salt_environment_selector.rb +4 -4
  22. data/app/overrides/salt_modules_selector.rb +9 -9
  23. data/app/overrides/salt_proxy_selector.rb +4 -4
  24. data/app/services/foreman_salt/fact_importer.rb +5 -5
  25. data/app/services/foreman_salt/report_importer.rb +14 -14
  26. data/app/services/foreman_salt/smart_proxies/salt_keys.rb +6 -6
  27. data/app/views/foreman_salt/salt_autosign/_form.html.erb +1 -1
  28. data/app/views/foreman_salt/salt_autosign/index.html.erb +3 -3
  29. data/app/views/foreman_salt/salt_autosign/new.html.erb +1 -1
  30. data/app/views/foreman_salt/salt_environments/edit.html.erb +1 -1
  31. data/app/views/foreman_salt/salt_environments/index.html.erb +4 -4
  32. data/app/views/foreman_salt/salt_environments/new.html.erb +1 -1
  33. data/app/views/foreman_salt/salt_keys/index.erb +9 -9
  34. data/app/views/foreman_salt/salt_modules/edit.html.erb +1 -1
  35. data/app/views/foreman_salt/salt_modules/index.html.erb +4 -4
  36. data/app/views/foreman_salt/salt_modules/new.html.erb +1 -1
  37. data/config/routes.rb +1 -1
  38. data/db/migrate/20140817210214_create_salt_modules.rb +1 -1
  39. data/db/migrate/20140920232200_create_salt_environments.rb +1 -1
  40. data/db/seeds.d/75-salt-seeds.rb +1 -1
  41. data/lib/foreman_salt/engine.rb +20 -20
  42. data/lib/foreman_salt/version.rb +1 -1
  43. data/lib/foreman_salt.rb +1 -1
  44. data/lib/tasks/foreman_salt_tasks.rake +16 -9
  45. data/test/factories/foreman_salt_factories.rb +2 -2
  46. data/test/functional/hosts_controller_test.rb +1 -1
  47. data/test/integration/salt_autosign_test.rb +8 -8
  48. data/test/integration/salt_environment_test.rb +7 -7
  49. data/test/integration/salt_keys_test.rb +17 -17
  50. data/test/integration/salt_module_test.rb +8 -8
  51. data/test/test_plugin_helper.rb +1 -1
  52. data/test/unit/grains_importer_test.rb +9 -9
  53. data/test/unit/host_extensions_test.rb +7 -7
  54. data/test/unit/hostgroup_extensions_test.rb +7 -7
  55. data/test/unit/report_importer_test.rb +1 -1
  56. data/test/unit/salt_keys_test.rb +13 -13
  57. data/test/unit/salt_modules_test.rb +5 -5
  58. metadata +58 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763554c758fd70adb3a4feef13ceb720c6711caa
4
- data.tar.gz: 0b86628a2277d95a26cc75bf6ef45070361c35d0
3
+ metadata.gz: ce1b4cb399d2e977121144ef5e214df9cfb96c14
4
+ data.tar.gz: 7ae9a7bfe423ed887ae6b6a4b553bebc2a493197
5
5
  SHA512:
6
- metadata.gz: 8d874dcf278f82b3b5bce1da5373bc37ccd758a5ee3ab9cccca65bc7cd8e0518a74a4cb9580d47e9d3187b4b2191e9b5d4b69b102cb420b4815719344eae35de
7
- data.tar.gz: 5fd385f82b6dd1a8f9fef3d8061e221e127123176afeda78ea07b1075092b62ac7cab162d8b143a60f4bb6f88c991657fcf3c5511602977b825fa1aa9127d37e
6
+ metadata.gz: 642dccb0a0683cee2885bcf2a9446c13687fb8af7685537d1b2db45532c81c59476fb326e91c1e1144ccb0882f236ee18497b3fd64d580aaf68de4891e1070e0
7
+ data.tar.gz: 3cc3ab238b85f88d1c60f8bf6e8c29985de38a28ebfdadb58e010ddf25c6458c8d69b9f8c354b6aeebe8ba6690f33482f5cf04c02d264f7e913363fd5e9de40f
data/README.md CHANGED
@@ -2,16 +2,9 @@
2
2
 
3
3
  This plug-in adds support for Salt to Foreman.
4
4
 
5
- ## Compatibility
6
-
7
- | Foreman Version | Plugin Version |
8
- | --------------- | --------------:|
9
- | >= 1.6 | ~> 0.0 |
10
- | >= 1.7 | ~> 1.0 |
11
-
12
5
  ## Documentation
13
6
 
14
- More info is available in the Wiki https://github.com/theforeman/foreman_salt/wiki
7
+ Available in the Wiki https://github.com/theforeman/foreman_salt/wiki
15
8
 
16
9
  ## Contributing
17
10
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
23
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
24
24
  load 'rails/tasks/engine.rake'
25
25
 
26
26
 
@@ -11,14 +11,14 @@ module ForemanSalt
11
11
  add_puppetmaster_filters :upload
12
12
 
13
13
  resource_description do
14
- api_base_url "/salt/api"
14
+ api_base_url '/salt/api'
15
15
  end
16
16
 
17
17
  def_param_group :job do
18
18
  param :job, Hash, :required => true, :action_aware => true do
19
- param :job_id, Integer, :required => true, :desc => N_("JID")
20
- param :function, String, :required => true, :desc => N_("Function")
21
- param :result, Hash, :required => true, :desc => N_("Result")
19
+ param :job_id, Integer, :required => true, :desc => N_('JID')
20
+ param :function, String, :required => true, :desc => N_('Function')
21
+ param :result, Hash, :required => true, :desc => N_('Result')
22
22
  end
23
23
  end
24
24
 
@@ -13,7 +13,7 @@ module ForemanSalt
13
13
 
14
14
  def saltrun
15
15
  if @host.saltrun!
16
- notice _("Successfully executed, check log files for more details")
16
+ notice _('Successfully executed, check log files for more details')
17
17
  else
18
18
  error @host.errors[:base].to_sentence
19
19
  end
@@ -25,9 +25,9 @@ module ForemanSalt
25
25
  @host = resource_base.find(params[:name])
26
26
  enc = {}
27
27
  env = @host.salt_environment.blank? ? 'base' : @host.salt_environment.name
28
- enc["classes"] = @host.salt_modules.any? ? @host.salt_modules.map(&:name) : []
29
- enc["parameters"] = @host.info["parameters"]
30
- enc["environment"] = env
28
+ enc['classes'] = @host.salt_modules.any? ? @host.salt_modules.map(&:name) : []
29
+ enc['parameters'] = @host.info['parameters']
30
+ enc['environment'] = env
31
31
  respond_to do |format|
32
32
  format.html { render :text => "<pre>#{ERB::Util.html_escape(enc.to_yaml)}</pre>" }
33
33
  format.yml { render :text => enc.to_yaml }
@@ -12,9 +12,9 @@ module ForemanSalt
12
12
  end
13
13
 
14
14
  def require_puppetmaster_or_login_with_salt
15
- if auth_smart_proxy(::SmartProxy.with_features("Salt"), ::Setting[:require_ssl_puppetmasters])
15
+ if auth_smart_proxy(::SmartProxy.with_features('Salt'), ::Setting[:require_ssl_puppetmasters])
16
16
  set_admin_user
17
- return true
17
+ true
18
18
  else
19
19
  require_puppetmaster_or_login_without_salt
20
20
  end
@@ -11,7 +11,7 @@ module ForemanSalt
11
11
 
12
12
  def handle_salt
13
13
  return true if @spoof
14
- render(:text => _("Failed to set autosign for host. Terminating the build!"), :status => 500) unless @host.respond_to?(:handle_salt) && @host.handle_salt
14
+ render(:text => _('Failed to set autosign for host. Terminating the build!'), :status => 500) unless @host.respond_to?(:handle_salt) && @host.handle_salt
15
15
  end
16
16
  end
17
17
  end
@@ -27,7 +27,7 @@ module ForemanSalt
27
27
 
28
28
  def update
29
29
  if @salt_environment.update_attributes(params[:foreman_salt_salt_environment])
30
- notice _("Successfully updated %s." % @salt_environment.to_s)
30
+ notice _('Successfully updated %s.' % @salt_environment.to_s)
31
31
  redirect_to salt_environments_path
32
32
  else
33
33
  process_error
@@ -4,7 +4,7 @@ module ForemanSalt
4
4
  def index
5
5
  @proxy = find_proxy
6
6
 
7
- Rails.cache.delete("saltkeys_#{@proxy.id}") if params[:expire_cache] == "true"
7
+ Rails.cache.delete("saltkeys_#{@proxy.id}") if params[:expire_cache] == 'true'
8
8
  keys = if params[:state].blank?
9
9
  SmartProxies::SaltKeys.all @proxy
10
10
  else
@@ -14,7 +14,7 @@ module ForemanSalt
14
14
  end
15
15
 
16
16
  def accept
17
- @proxy = find_proxy(permission = :edit_smart_proxies_salt_keys)
17
+ @proxy = find_proxy(:edit_smart_proxies_salt_keys)
18
18
  key = SmartProxies::SaltKeys.find(@proxy, params[:salt_key_id])
19
19
  if key.accept
20
20
  process_success({:success_redirect => hash_for_smart_proxy_salt_keys_path(:state => params[:state], :expire_cache => true),
@@ -25,7 +25,7 @@ module ForemanSalt
25
25
  end
26
26
 
27
27
  def reject
28
- @proxy = find_proxy(permission = :edit_smart_proxies_salt_keys)
28
+ @proxy = find_proxy(:edit_smart_proxies_salt_keys)
29
29
  key = SmartProxies::SaltKeys.find(@proxy, params[:salt_key_id])
30
30
  if key.reject
31
31
  process_success({:success_redirect => hash_for_smart_proxy_salt_keys_path(:state => params[:state], :expire_cache => true),
@@ -36,7 +36,7 @@ module ForemanSalt
36
36
  end
37
37
 
38
38
  def destroy
39
- @proxy = find_proxy(permission = :destroy_smart_proxies_salt_keys)
39
+ @proxy = find_proxy(:destroy_smart_proxies_salt_keys)
40
40
  key = SmartProxies::SaltKeys.find(@proxy, params[:id])
41
41
  if key.delete
42
42
  process_success({:success_redirect => hash_for_smart_proxy_salt_keys_path(:state => params[:state], :expire_cache => true),
@@ -27,7 +27,7 @@ module ForemanSalt
27
27
 
28
28
  def update
29
29
  if @salt_module.update_attributes(params[:foreman_salt_salt_module])
30
- notice _("Successfully updated %s." % @salt_module.to_s)
30
+ notice _('Successfully updated %s.' % @salt_module.to_s)
31
31
  redirect_to salt_modules_path
32
32
  else
33
33
  process_error
@@ -9,16 +9,16 @@ module ForemanSalt
9
9
 
10
10
  def show_appropriate_host_buttons_with_salt(host)
11
11
  (show_appropriate_host_buttons_without_salt(host) +
12
- [(link_to_if_authorized(_("Salt ENC"), {:controller => :hosts, :action => :salt_external_node, :name => host},
13
- :title => _("Salt external nodes YAML dump"), :class => 'btn btn-default') unless host.salt_master.blank?)]).flatten.compact
12
+ [(link_to_if_authorized(_('Salt ENC'), {:controller => :hosts, :action => :salt_external_node, :name => host},
13
+ :title => _('Salt external nodes YAML dump'), :class => 'btn btn-default') unless host.salt_master.blank?)]).flatten.compact
14
14
  end
15
15
 
16
16
  def host_title_actions_with_salt_run(host)
17
17
  title_actions(
18
18
  button_group(
19
19
  if host.try(:salt_proxy)
20
- link_to_if_authorized(_("Run Salt"), {:controller => :hosts, :action => :saltrun, :id => @host},
21
- :title => _("Trigger a state.highstate run on a node"))
20
+ link_to_if_authorized(_('Run Salt'), {:controller => :hosts, :action => :saltrun, :id => @host},
21
+ :title => _('Trigger a state.highstate run on a node'))
22
22
  end
23
23
  )
24
24
  )
@@ -10,11 +10,11 @@ module ForemanSalt
10
10
  salt = proxy.features.detect { |feature| feature.name == 'Salt' }
11
11
  [
12
12
  if salt
13
- display_link_if_authorized(_("Salt Keys"), {:controller => 'foreman_salt/salt_keys', :action => 'index', :smart_proxy_id => proxy})
13
+ display_link_if_authorized(_('Salt Keys'), {:controller => 'foreman_salt/salt_keys', :action => 'index', :smart_proxy_id => proxy})
14
14
  end,
15
15
 
16
16
  if salt
17
- display_link_if_authorized(_("Salt Autosign"), {:controller => 'foreman_salt/salt_autosign', :action => 'index', :smart_proxy_id => proxy})
17
+ display_link_if_authorized(_('Salt Autosign'), {:controller => 'foreman_salt/salt_autosign', :action => 'index', :smart_proxy_id => proxy})
18
18
  end
19
19
  ] + proxy_actions_without_salt_proxy(proxy, authorizer)
20
20
  end
@@ -1,7 +1,7 @@
1
1
  module ForemanSalt
2
2
  module SaltKeysHelper
3
3
  def salt_keys_state_filter
4
- select_tag "Filter", options_for_select(["", _("Accepted"),_("Rejected"), _("Unaccepted")], params[:state]),
4
+ select_tag 'Filter', options_for_select(['', _('Accepted'),_('Rejected'), _('Unaccepted')], params[:state]),
5
5
  :onchange => "window.location.href = location.protocol + '//' + location.host + location.pathname + (this.value == '' ? '' : ('?state=' + this.value))"
6
6
  end
7
7
  end
@@ -1,60 +1,60 @@
1
1
  module ::ProxyAPI
2
2
  class Salt < ::ProxyAPI::Resource
3
- def initialize args
4
- @url = args[:url] + "/salt/"
3
+ def initialize(args)
4
+ @url = args[:url] + '/salt/'
5
5
  super args
6
6
  end
7
7
 
8
8
  def autosign_list
9
- parse(get("autosign"))
9
+ parse(get('autosign'))
10
10
  rescue => e
11
- raise ProxyException.new(url, e, N_("Unable to fetch autosign list"))
11
+ raise ProxyException.new(url, e, N_('Unable to fetch autosign list'))
12
12
  end
13
13
 
14
- def autosign_create name
15
- parse(post("", "autosign/#{URI.escape(name)}"))
14
+ def autosign_create(name)
15
+ parse(post('', "autosign/#{URI.escape(name)}"))
16
16
  rescue => e
17
- raise ProxyException.new(url, e, N_("Unable to set Salt autosign for %s"), name)
17
+ raise ProxyException.new(url, e, N_('Unable to set Salt autosign for %s'), name)
18
18
  end
19
19
 
20
- def autosign_remove name
20
+ def autosign_remove(name)
21
21
  parse(delete("autosign/#{URI.escape(name)}"))
22
22
  rescue RestClient::ResourceNotFound
23
23
  true # entry doesn't exists anyway
24
24
  rescue => e
25
- raise ProxyException.new(url, e, N_("Unable to delete Salt autosign for %s"), name)
25
+ raise ProxyException.new(url, e, N_('Unable to delete Salt autosign for %s'), name)
26
26
  end
27
27
 
28
28
  def key_list
29
- parse(get("key"))
29
+ parse(get('key'))
30
30
  rescue => e
31
- raise ProxyException.new(url, e, N_("Unable to fetch Salt key list"))
31
+ raise ProxyException.new(url, e, N_('Unable to fetch Salt key list'))
32
32
  end
33
33
 
34
- def key_accept name
35
- parse(post("","key/#{name}"))
34
+ def key_accept(name)
35
+ parse(post('',"key/#{name}"))
36
36
  rescue => e
37
- raise ProxyException.new(url, e, N_("Unable to accept Salt key for %s"), name)
37
+ raise ProxyException.new(url, e, N_('Unable to accept Salt key for %s'), name)
38
38
  end
39
39
 
40
- def key_reject name
40
+ def key_reject(name)
41
41
  parse(delete("key/reject/#{name}"))
42
42
  rescue => e
43
- raise ProxyException.new(url, e, N_("Unable to reject Salt key for %s"), name)
43
+ raise ProxyException.new(url, e, N_('Unable to reject Salt key for %s'), name)
44
44
  end
45
45
 
46
- def key_delete name
46
+ def key_delete(name)
47
47
  parse(delete("key/#{name}"))
48
48
  rescue RestClient::ResourceNotFound
49
49
  true
50
50
  rescue => e
51
- raise ProxyException.new(url, e, N_("Unable to delete Salt key for %s"), name)
51
+ raise ProxyException.new(url, e, N_('Unable to delete Salt key for %s'), name)
52
52
  end
53
53
 
54
- def highstate name
55
- parse(post("", "highstate/#{name}"))
54
+ def highstate(name)
55
+ parse(post('', "highstate/#{name}"))
56
56
  rescue => e
57
- raise ProxyException.new(url, e, N_("Unable to run Salt state.highstate for %s"), name)
57
+ raise ProxyException.new(url, e, N_('Unable to run Salt state.highstate for %s'), name)
58
58
  end
59
59
  end
60
60
  end
@@ -4,9 +4,9 @@ module ForemanSalt
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- has_and_belongs_to_many :salt_modules, :class_name => "ForemanSalt::SaltModule", :join_table => "hosts_salt_modules", :foreign_key => "host_id"
8
- belongs_to :salt_proxy, :class_name => "SmartProxy"
9
- belongs_to :salt_environment, :class_name => "ForemanSalt::SaltEnvironment"
7
+ has_and_belongs_to_many :salt_modules, :class_name => 'ForemanSalt::SaltModule', :join_table => 'hosts_salt_modules', :foreign_key => 'host_id'
8
+ belongs_to :salt_proxy, :class_name => 'SmartProxy'
9
+ belongs_to :salt_environment, :class_name => 'ForemanSalt::SaltEnvironment'
10
10
  alias_method_chain :params, :salt_proxy
11
11
  alias_method_chain :set_hostgroup_defaults, :salt_proxy
12
12
  alias_method_chain :smart_proxy_ids, :salt_proxy
@@ -14,12 +14,12 @@ module ForemanSalt
14
14
 
15
15
  def handle_salt
16
16
  return true unless salt?
17
- salt_autosign_create
17
+ set_salt_autosign
18
18
  end
19
19
 
20
20
  def params_with_salt_proxy
21
21
  params = params_without_salt_proxy
22
- params["salt_master"] = salt_master unless salt_master.blank?
22
+ params['salt_master'] = salt_master unless salt_master.blank?
23
23
  params
24
24
  end
25
25
 
@@ -40,12 +40,12 @@ module ForemanSalt
40
40
  def saltrun!
41
41
  unless salt_proxy.present?
42
42
  errors.add(:base, _("No Salt master defined - can't continue"))
43
- logger.warn "Unable to execute salt run, no salt proxies defined"
43
+ logger.warn 'Unable to execute salt run, no salt proxies defined'
44
44
  return false
45
45
  end
46
46
  ProxyAPI::Salt.new({:url => salt_proxy.url}).highstate name
47
47
  rescue => e
48
- errors.add(:base, _("Failed to execute state.highstate: %s") % e)
48
+ errors.add(:base, _('Failed to execute state.highstate: %s') % e)
49
49
  false
50
50
  end
51
51
 
@@ -4,9 +4,9 @@ module ForemanSalt
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- has_and_belongs_to_many :salt_modules, :class_name => "ForemanSalt::SaltModule"
8
- belongs_to :salt_proxy, :class_name => "SmartProxy"
9
- belongs_to :salt_environment, :class_name => "ForemanSalt::SaltEnvironment"
7
+ has_and_belongs_to_many :salt_modules, :class_name => 'ForemanSalt::SaltModule'
8
+ belongs_to :salt_proxy, :class_name => 'SmartProxy'
9
+ belongs_to :salt_environment, :class_name => 'ForemanSalt::SaltEnvironment'
10
10
  end
11
11
 
12
12
  def salt_modules
@@ -38,7 +38,7 @@ module ForemanSalt
38
38
 
39
39
  def inherited_salt_proxy_id
40
40
  if ancestry.present?
41
- read_attribute(:salt_proxy_id) || self.class.sort_by_ancestry(ancestors.where("salt_proxy_id is not NULL")).last.try(:salt_proxy_id)
41
+ read_attribute(:salt_proxy_id) || self.class.sort_by_ancestry(ancestors.where('salt_proxy_id is not NULL')).last.try(:salt_proxy_id)
42
42
  else
43
43
  self.salt_proxy_id
44
44
  end
@@ -51,7 +51,7 @@ module ForemanSalt
51
51
 
52
52
  def inherited_salt_environment_id
53
53
  if ancestry.present?
54
- read_attribute(:salt_environment_id) || self.class.sort_by_ancestry(ancestors.where("salt_environment_id is not NULL")).last.try(:salt_environment_id)
54
+ read_attribute(:salt_environment_id) || self.class.sort_by_ancestry(ancestors.where('salt_environment_id is not NULL')).last.try(:salt_environment_id)
55
55
  else
56
56
  self.salt_environment_id
57
57
  end
@@ -20,41 +20,41 @@ module ForemanSalt
20
20
 
21
21
  def queue_salt_autosign
22
22
  return unless salt? && errors.empty?
23
- new_record? ? queue_salt_autosign_create : queue_salt_autosign_update
23
+ new_record? ? queue_set_salt_autosign : queue_update_salt_autosign
24
24
  end
25
25
 
26
- def queue_salt_autosign_create
26
+ def queue_set_salt_autosign
27
27
  # do nothing - we'll set autosign at the last second: when a host requests a provision URL
28
28
  end
29
29
 
30
- def queue_salt_autosign_update
30
+ def queue_update_salt_autosign
31
31
  # Host has been built --> remove auto sign
32
32
  if old.build? and !build?
33
- queue.create(:name => _("Remove autosign entry for %s") % self, :priority => 50, :action => [self, :salt_autosign_remove])
33
+ queue.create(:name => _('Remove autosign entry for %s') % self, :priority => 50, :action => [self, :del_salt_autosign])
34
34
  end
35
35
  end
36
36
 
37
37
  def queue_salt_destroy
38
38
  return unless salt? && errors.empty?
39
- queue.create(:name => _("Remove autosign entry for %s") % self, :priority => 50, :action => [self, :salt_autosign_remove])
40
- queue.create(:name => _("Delete existing salt key for %s") % self, :priority => 50, :action => [self, :salt_key_delete])
39
+ queue.create(:name => _('Remove autosign entry for %s') % self, :priority => 50, :action => [self, :del_salt_autosign])
40
+ queue.create(:name => _('Delete existing salt key for %s') % self, :priority => 50, :action => [self, :del_salt_key])
41
41
  end
42
42
 
43
- def queue_salt_autosign_remove
43
+ def queue_del_salt_autosign
44
44
  return unless salt? && errors.empty?
45
- queue.create(:name => _("Remove autosign entry for %s") % self, :priority => 50, :action => [self, :salt_autosign_remove])
45
+ queue.create(:name => _('Remove autosign entry for %s') % self, :priority => 50, :action => [self, :del_salt_autosign])
46
46
  end
47
47
 
48
- def salt_autosign_create
48
+ def set_salt_autosign
49
49
  logger.info "Create autosign entry for #{name}"
50
50
  initialize_salt
51
- salt_key_delete # if there's already an existing key
51
+ del_salt_key # if there's already an existing key
52
52
  @salt_api.autosign_create name
53
53
  rescue => e
54
54
  failure _("Failed to create %{name}'s Salt autosign entry: %{e}") % { :name => name, :e => e }
55
55
  end
56
56
 
57
- def salt_autosign_remove
57
+ def del_salt_autosign
58
58
  logger.info "Remove autosign entry for #{name}"
59
59
  initialize_salt
60
60
  @salt_api.autosign_remove name
@@ -62,7 +62,7 @@ module ForemanSalt
62
62
  failure _("Failed to remove %{name}'s Salt autosign entry: %{e}") % { :name => name, :e => e }
63
63
  end
64
64
 
65
- def salt_key_delete
65
+ def del_salt_key
66
66
  logger.info "Delete salt key for #{name}"
67
67
  initialize_salt
68
68
  @salt_api.key_delete name
@@ -5,13 +5,13 @@ module ForemanSalt
5
5
 
6
6
  before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups)
7
7
 
8
- has_many :hosts, :class_name => "::Host::Managed"
9
- has_many :hostgroups, :class_name => "::Hostgroup"
8
+ has_many :hosts, :class_name => '::Host::Managed'
9
+ has_many :hostgroups, :class_name => '::Hostgroup'
10
10
 
11
- validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d\.]+\z/, :message => N_("is alphanumeric and cannot contain spaces") }
11
+ validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d\.]+\z/, :message => N_('is alphanumeric and cannot contain spaces') }
12
12
 
13
13
  default_scope lambda {
14
- order("salt_environments.name")
14
+ order('salt_environments.name')
15
15
  }
16
16
 
17
17
  scoped_search :on => :name, :complete_value => true
@@ -4,15 +4,15 @@ module ForemanSalt
4
4
  include Authorizable
5
5
 
6
6
  before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups)
7
- has_and_belongs_to_many :hosts, :class_name => "::Host::Managed", :join_table => "hosts_salt_modules",
7
+ has_and_belongs_to_many :hosts, :class_name => '::Host::Managed', :join_table => 'hosts_salt_modules',
8
8
  :association_foreign_key => 'host_id'
9
9
 
10
- has_and_belongs_to_many :hostgroups, :class_name => "::Hostgroup", :join_table => "hostgroups_salt_modules"
10
+ has_and_belongs_to_many :hostgroups, :class_name => '::Hostgroup', :join_table => 'hostgroups_salt_modules'
11
11
 
12
- validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A(?:[\w\d]+\.{0,1})+[^\.]\z/, :message => N_("must be alphanumeric, can contain dots and must not contain spaces") }
12
+ validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A(?:[\w\d]+\.{0,1})+[^\.]\z/, :message => N_('must be alphanumeric, can contain dots and must not contain spaces') }
13
13
 
14
14
  default_scope lambda {
15
- order("salt_modules.name")
15
+ order('salt_modules.name')
16
16
  }
17
17
 
18
18
  scoped_search :on => :name, :complete_value => true
@@ -12,9 +12,9 @@
12
12
  <div class="col-md-8">
13
13
  <h3>Salt States</h3>
14
14
  <% if @inherited_salt_modules.blank? -%>
15
- <%= multiple_selects f, :salt_module, ::ForemanSalt::SaltModule, @salt_modules.try(:map, &:id), :label => "" %>
15
+ <%= multiple_selects f, :salt_module, ::ForemanSalt::SaltModule, @salt_modules.try(:map, &:id), :label => '' %>
16
16
  <% else -%>
17
- <%= multiple_selects f, :salt_module, ::ForemanSalt::SaltModule.where('id NOT IN (?)', @inherited_salt_modules.map(&:id)), @salt_modules.try(:map, &:id), :label => "" %>
17
+ <%= multiple_selects f, :salt_module, ::ForemanSalt::SaltModule.where('id NOT IN (?)', @inherited_salt_modules.map(&:id)), @salt_modules.try(:map, &:id), :label => '' %>
18
18
  <% end -%>
19
19
  </div>
20
20
  </div>
@@ -2,12 +2,12 @@ selector_text = "<%= select_f f, :salt_environment_id, ForemanSalt::SaltEnvironm
2
2
  { :include_blank => blank_or_inherit_f(f, :salt_environment) },
3
3
  { :label => _('Salt Environment') } %>"
4
4
 
5
- Deface::Override.new(:virtual_path => "hosts/_form",
6
- :name => "add_salt_environment_to_host",
5
+ Deface::Override.new(:virtual_path => 'hosts/_form',
6
+ :name => 'add_salt_environment_to_host',
7
7
  :insert_bottom => 'div#primary',
8
8
  :text => selector_text)
9
9
 
10
- Deface::Override.new(:virtual_path => "hostgroups/_form",
11
- :name => "add_salt_environment_to_hostgroup",
10
+ Deface::Override.new(:virtual_path => 'hostgroups/_form',
11
+ :name => 'add_salt_environment_to_hostgroup',
12
12
  :insert_bottom => 'div#primary',
13
13
  :text => selector_text)
@@ -1,19 +1,19 @@
1
- Deface::Override.new(:virtual_path => "hosts/_form",
2
- :name => "add_salt_modules_tab_to_host",
1
+ Deface::Override.new(:virtual_path => 'hosts/_form',
2
+ :name => 'add_salt_modules_tab_to_host',
3
3
  :insert_after => 'li.active',
4
4
  :partial => '../overrides/foreman/salt_modules/host_tab')
5
5
 
6
- Deface::Override.new(:virtual_path => "hosts/_form",
7
- :name => "add_salt_modules_tab_pane_to_host",
6
+ Deface::Override.new(:virtual_path => 'hosts/_form',
7
+ :name => 'add_salt_modules_tab_pane_to_host',
8
8
  :insert_before => 'div#puppet_klasses',
9
9
  :partial => '../overrides/foreman/salt_modules/host_tab_pane')
10
-
11
- Deface::Override.new(:virtual_path => "hostgroups/_form",
12
- :name => "add_salt_modules_tab_to_hg",
10
+
11
+ Deface::Override.new(:virtual_path => 'hostgroups/_form',
12
+ :name => 'add_salt_modules_tab_to_hg',
13
13
  :insert_after => 'li.active',
14
14
  :partial => '../overrides/foreman/salt_modules/host_tab')
15
15
 
16
- Deface::Override.new(:virtual_path => "hostgroups/_form",
17
- :name => "add_salt_modules_tab_pane_to_hg",
16
+ Deface::Override.new(:virtual_path => 'hostgroups/_form',
17
+ :name => 'add_salt_modules_tab_pane_to_hg',
18
18
  :insert_before => 'div#puppet_klasses',
19
19
  :partial => '../overrides/foreman/salt_modules/host_tab_pane')
@@ -2,12 +2,12 @@ selector_text = "<%= select_f f, :salt_proxy_id, SmartProxy.unscoped.with_featur
2
2
  { :include_blank => blank_or_inherit_f(f, :salt_proxy) },
3
3
  { :label => _('Salt Master') } %>"
4
4
 
5
- Deface::Override.new(:virtual_path => "hosts/_form",
6
- :name => "add_salt_proxy_to_host",
5
+ Deface::Override.new(:virtual_path => 'hosts/_form',
6
+ :name => 'add_salt_proxy_to_host',
7
7
  :insert_bottom => 'div#primary',
8
8
  :text => selector_text)
9
9
 
10
- Deface::Override.new(:virtual_path => "hostgroups/_form",
11
- :name => "add_salt_proxy_to_hostgroup",
10
+ Deface::Override.new(:virtual_path => 'hostgroups/_form',
11
+ :name => 'add_salt_proxy_to_hostgroup',
12
12
  :insert_bottom => 'div#primary',
13
13
  :text => selector_text)
@@ -72,8 +72,8 @@ module ForemanSalt
72
72
  name_parts = fact_name.split(FactName::SEPARATOR)
73
73
 
74
74
  name_parts.inject([]) do |memo, name|
75
- memo = memo + [name]
76
- key = memo.join(FactName::SEPARATOR)
75
+ memo += [name]
76
+ key = memo.join(FactName::SEPARATOR)
77
77
  new_facts[key] ||= name_parts == memo ? value : nil
78
78
  memo
79
79
  end
@@ -85,7 +85,7 @@ module ForemanSalt
85
85
  hash.sort_by { |k, v| k.to_s }
86
86
  end
87
87
 
88
- def sparse(hash, options={})
88
+ def sparse(hash, options = {})
89
89
  hash.map do |k, v|
90
90
  prefix = (options.fetch(:prefix, [])+[k])
91
91
  next Sparsify::sparse(v, options.merge(:prefix => prefix)) if v.is_a? Hash
@@ -93,7 +93,7 @@ module ForemanSalt
93
93
  end.reduce(:merge) || Hash.new
94
94
  end
95
95
 
96
- def unsparse(hash, options={})
96
+ def unsparse(hash, options = {})
97
97
  ret = Hash.new
98
98
  sparse(hash).each do |k, v|
99
99
  current = ret
@@ -101,7 +101,7 @@ module ForemanSalt
101
101
  current = (current[key.shift] ||= Hash.new) until (key.size<=1)
102
102
  current[key.first] = v
103
103
  end
104
- return ret
104
+ ret
105
105
  end
106
106
  end
107
107
  end