foreman_salt 3.0.0 → 3.0.1

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
2
  SHA1:
3
- metadata.gz: a9a26aba67e387ba355bf4b358969f155e0e7550
4
- data.tar.gz: c77ad3cab0e6f604f8e60964894d3345b01384ed
3
+ metadata.gz: bea1caeb04b5f73dc724c2d4bdd45e46055dbf80
4
+ data.tar.gz: 21b7646d6d05aea5c7a393e1505910bc08efde11
5
5
  SHA512:
6
- metadata.gz: 9db5120fde1dff0fffad5b1cf5dbec81cf780669887447f379ba6109d2fd886f45b120a79d219b7b2f327cdd9d35d424e4cb09e1ba427b4441e8ed5124809e03
7
- data.tar.gz: b36d148373832511ea50bbf3379f0f096f9a2fdcad94b62422cf7cb06526ddecafba58aeb83e1faa4c7c9c362b7a089b0514b5ec9454656401d9bc4a399ee41c
6
+ metadata.gz: 7ae9d028461860b4fac00233e19a8de3b74614c92278539d4848649c20fc632987f1cd1f33aa53c3d63c8de9e7831532e0f753f49317fe0147f1c9de2c8e1e3c
7
+ data.tar.gz: 495c4414f5718ecc4d75ba82bada937b1cf799327f9adebe434a65ead4880eb45c4f79fc2717e5e66357691617e25809e6566409ba67375c9320d704aed0fea2
@@ -4,7 +4,7 @@ $(document).on( "ContentLoad", function() {
4
4
 
5
5
  function update_salt_states(element) {
6
6
  var host_id = $("form").data('id')
7
- var env_id = $('*[id*=salt_environment_id]').val();
7
+ var env_id = $('select[name*=salt_environment_id]').val();
8
8
  var url = $(element).attr('data-url');
9
9
  var data = $("form").serialize().replace('method=put', 'method=post');
10
10
 
@@ -69,7 +69,7 @@ module ForemanSalt
69
69
  @minion = Host::Base.authorized(:view_hosts, Host).find_by_id(params[:host_id])
70
70
  if @minion
71
71
  unless @minion.is_a?(Host::Managed)
72
- @minion = @host.becomes(Host::Managed)
72
+ @minion = @minion.becomes(Host::Managed)
73
73
  @minion.type = 'Host::Managed'
74
74
  end
75
75
  @minion.attributes = params[:host]
@@ -33,10 +33,9 @@ module ForemanSalt
33
33
  end
34
34
 
35
35
  def salt_modules_for_enc
36
- return [] unless self.salt_environment
37
-
38
- hostgroup_modules = self.hostgroup ? self.hostgroup.all_salt_modules : []
39
- self.salt_environment.salt_modules.where(:id => self.salt_modules + hostgroup_modules).pluck(:name)
36
+ return [] unless salt_environment
37
+ modules = salt_modules + (hostgroup ? hostgroup.all_salt_modules : [])
38
+ ForemanSalt::SaltModule.in_environment(salt_environment).where(:id => modules).pluck(:name).uniq
40
39
  end
41
40
 
42
41
  def salt_master
@@ -16,11 +16,7 @@ module ForemanSalt
16
16
  end
17
17
 
18
18
  def all_salt_modules
19
- if ancestry.present?
20
- (self.salt_modules + self.inherited_salt_modules).uniq
21
- else
22
- self.salt_modules
23
- end
19
+ ForemanSalt::SaltModule.in_environment(salt_environment).where(:id => salt_module_ids + inherited_salt_module_ids)
24
20
  end
25
21
 
26
22
  def inherited_salt_modules
@@ -28,11 +24,7 @@ module ForemanSalt
28
24
  end
29
25
 
30
26
  def inherited_salt_module_ids
31
- if ancestry.present?
32
- self.class.sort_by_ancestry(ancestors.reject { |ancestor| ancestor.salt_module_ids.empty? }).map(&:salt_module_ids).inject(&:+).uniq
33
- else
34
- []
35
- end
27
+ ancestors.map(&:salt_module_ids).flatten.uniq
36
28
  end
37
29
 
38
30
  def salt_proxy
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
@@ -4,24 +4,25 @@ FactoryGirl.define do
4
4
  end
5
5
 
6
6
  factory :salt_environment, :class => 'ForemanSalt::SaltEnvironment' do
7
- sequence(:name) { |n| "module#{n}" }
7
+ sequence(:name) { |n| "environment#{n}" }
8
8
  end
9
9
  end
10
10
 
11
11
  FactoryGirl.modify do
12
12
  factory :host do
13
13
  trait :with_salt_proxy do
14
- salt_proxy { FactoryGirl.create :smart_proxy, :with_salt_feature }
14
+ salt_proxy { FactoryGirl.build :smart_proxy, :with_salt_feature }
15
15
  end
16
16
  end
17
17
 
18
18
  factory :hostgroup do
19
19
  trait :with_salt_proxy do
20
- salt_proxy { FactoryGirl.create :smart_proxy, :with_salt_feature }
20
+ salt_proxy { FactoryGirl.build :smart_proxy, :with_salt_feature }
21
21
  end
22
22
 
23
23
  trait :with_salt_modules do
24
- salt_modules { FactoryGirl.create_list :salt_module, 10 }
24
+ salt_environment { FactoryGirl.build :salt_environment }
25
+ salt_modules { FactoryGirl.create_list :salt_module, 10, :salt_environments => [self.salt_environment] }
25
26
  end
26
27
  end
27
28
 
@@ -25,16 +25,32 @@ module ForemanSalt
25
25
  end
26
26
 
27
27
  test 'child and parent salt modules are combined' do
28
+ environment = FactoryGirl.create :salt_environment
29
+ parent = FactoryGirl.create :hostgroup, :with_salt_modules, :salt_environment => environment
30
+ child = FactoryGirl.create :hostgroup, :with_salt_modules, :salt_environment => environment, :parent => parent
31
+
32
+ total = parent.salt_modules.count + child.salt_modules.count
33
+ assert_equal total, child.all_salt_modules.count
34
+ end
35
+
36
+ test 'child doesnt get modules from outside its environment' do
28
37
  parent = FactoryGirl.create :hostgroup, :with_salt_modules
29
38
  child = FactoryGirl.create :hostgroup, :with_salt_modules, :parent => parent
30
- assert_equal 10, (child.salt_modules - parent.salt_modules).length
39
+ assert_equal child.salt_modules.count, child.all_salt_modules.count
31
40
  end
32
41
 
33
- test 'second child inherits from parent' do
42
+ test 'inheritance when only parent has modules' do
34
43
  parent = FactoryGirl.create :hostgroup, :with_salt_modules
35
44
  child_one = FactoryGirl.create :hostgroup, :parent => parent
36
45
  child_two = FactoryGirl.create :hostgroup, :parent => child_one
37
- assert_equal [], parent.all_salt_modules - child_two.all_salt_modules
46
+ assert_blank parent.all_salt_modules - child_two.all_salt_modules
47
+ end
48
+
49
+ test 'inheritance when no parents have modules' do
50
+ parent = FactoryGirl.create :hostgroup
51
+ child_one = FactoryGirl.create :hostgroup, :parent => parent
52
+ child_two = FactoryGirl.create :hostgroup, :with_salt_modules, :parent => child_one
53
+ assert child_two.all_salt_modules.any?
38
54
  end
39
55
  end
40
56
  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: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Benjamin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: foreman-tasks
29
29
  requirement: !ruby/object:Gem::Requirement