foreman_discovery 9.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/discovered_hosts_controller.rb +6 -4
  3. data/app/controllers/api/v2/fact_values_controller_extensions.rb +2 -2
  4. data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +6 -1
  5. data/app/controllers/discovered_hosts_controller.rb +2 -2
  6. data/app/helpers/discovered_hosts_helper.rb +5 -0
  7. data/app/models/discovery_attribute_set.rb +1 -1
  8. data/app/models/discovery_rule.rb +1 -1
  9. data/app/models/host/discovered.rb +3 -2
  10. data/app/models/host/managed_extensions.rb +10 -5
  11. data/app/services/foreman_discovery/host_converter.rb +0 -2
  12. data/app/views/api/v2/discovery_rules/main.json.rabl +12 -0
  13. data/app/views/discovered_hosts/_discovered_host_modal.html.erb +2 -2
  14. data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +5 -5
  15. data/app/views/discovered_hosts/edit.html.erb +3 -0
  16. data/app/views/discovery_rules/_form.html.erb +1 -1
  17. data/app/views/discovery_rules/index.html.erb +2 -2
  18. data/app/views/foreman_discovery/debian_kexec.erb +1 -0
  19. data/app/views/foreman_discovery/redhat_kexec.erb +1 -0
  20. data/config/routes.rb +3 -3
  21. data/db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb +1 -1
  22. data/db/migrate/20160818091421_add_permissions_from_default_roles.rb +1 -7
  23. data/db/seeds.d/50_discovery_templates.rb +2 -2
  24. data/db/seeds.d/60_discovery_proxy_feature.rb +2 -2
  25. data/db/seeds.d/70_discovery_mail_notification.rb +1 -1
  26. data/db/seeds.d/90_add_permissions_from_default_roles.rb +12 -0
  27. data/lib/foreman_discovery/engine.rb +3 -2
  28. data/lib/foreman_discovery/version.rb +1 -1
  29. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  30. data/locale/ca/foreman_discovery.edit.po +37 -28
  31. data/locale/ca/foreman_discovery.po +14 -8
  32. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  33. data/locale/de/foreman_discovery.edit.po +38 -29
  34. data/locale/de/foreman_discovery.po +15 -9
  35. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  36. data/locale/en/foreman_discovery.edit.po +62 -38
  37. data/locale/en/foreman_discovery.po +27 -9
  38. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  39. data/locale/en_GB/foreman_discovery.edit.po +37 -28
  40. data/locale/en_GB/foreman_discovery.po +14 -8
  41. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  42. data/locale/es/foreman_discovery.edit.po +37 -28
  43. data/locale/es/foreman_discovery.po +14 -8
  44. data/locale/foreman_discovery.pot +63 -41
  45. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  46. data/locale/fr/foreman_discovery.edit.po +38 -29
  47. data/locale/fr/foreman_discovery.po +15 -9
  48. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  49. data/locale/gl/foreman_discovery.edit.po +36 -27
  50. data/locale/gl/foreman_discovery.po +14 -8
  51. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  52. data/locale/it/foreman_discovery.edit.po +37 -28
  53. data/locale/it/foreman_discovery.po +14 -8
  54. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  55. data/locale/ja/foreman_discovery.edit.po +37 -28
  56. data/locale/ja/foreman_discovery.po +14 -8
  57. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  58. data/locale/ko/foreman_discovery.edit.po +37 -28
  59. data/locale/ko/foreman_discovery.po +14 -8
  60. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  61. data/locale/pt_BR/foreman_discovery.edit.po +37 -28
  62. data/locale/pt_BR/foreman_discovery.po +14 -8
  63. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  64. data/locale/ru/foreman_discovery.edit.po +37 -28
  65. data/locale/ru/foreman_discovery.po +14 -8
  66. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  67. data/locale/sv_SE/foreman_discovery.edit.po +36 -27
  68. data/locale/sv_SE/foreman_discovery.po +14 -8
  69. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  70. data/locale/zh_CN/foreman_discovery.edit.po +37 -28
  71. data/locale/zh_CN/foreman_discovery.po +14 -8
  72. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  73. data/locale/zh_TW/foreman_discovery.edit.po +37 -28
  74. data/locale/zh_TW/foreman_discovery.po +14 -8
  75. data/test/factories/discovery_host_related.rb +26 -0
  76. data/test/factories/discovery_rule_related.rb +0 -27
  77. data/test/functional/api/v2/discovered_hosts_controller_test.rb +8 -6
  78. data/test/functional/api/v2/discovery_rules_controller_test.rb +5 -2
  79. data/test/functional/api/v2/fact_value_extensions_test.rb +2 -2
  80. data/test/functional/discovered_hosts_controller_test.rb +114 -78
  81. data/test/functional/discovery_rules_controller_test.rb +1 -1
  82. data/test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb +0 -1
  83. data/test/test_helper_discovery.rb +42 -6
  84. data/test/test_plugin_helper.rb +2 -0
  85. data/test/unit/discovered_extensions_test.rb +55 -10
  86. data/test/unit/discovery_attribute_set_test.rb +1 -1
  87. data/test/unit/discovery_rule_test.rb +1 -1
  88. data/test/unit/discovery_taxonomy_extensions_test.rb +1 -1
  89. data/test/unit/fact_parser_test.rb +1 -1
  90. data/test/unit/host_discovered_test.rb +48 -3
  91. data/test/unit/managed_extensions_test.rb +76 -0
  92. data/test/unit/setting_discovered_test.rb +1 -1
  93. data/test/unit/ui_notifications/destroy_host_test.rb +0 -1
  94. metadata +25 -23
  95. data/app/models/concerns/fact_value_extensions.rb +0 -13
  96. data/test/test_helper.rb +0 -25
  97. data/test/unit/fact_value_extensions_test.rb +0 -11
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class DiscoveryRulesControllerTest < ActionController::TestCase
4
4
  setup :initialize_host
@@ -1,5 +1,4 @@
1
1
  require 'test_plugin_helper'
2
- require 'test_helper_discovery'
3
2
 
4
3
  module ForemanDiscovery
5
4
  module Concerns
@@ -1,4 +1,8 @@
1
- def set_session_user_with_perms perms
1
+ def set_session_user(user)
2
+ SETTINGS[:login] ? {:user => user.id, :expires_at => 5.minutes.from_now} : {}
3
+ end
4
+
5
+ def user_with_perms(perms)
2
6
  perms = perms.collect{|p| Permission.find_by_name(p) || Permission.create(:name => p) }
3
7
  perms.each do |p|
4
8
  p.resource_type = 'Host' if p.name =~ /discovered_hosts$/
@@ -11,16 +15,36 @@ def set_session_user_with_perms perms
11
15
  end
12
16
  user = FactoryGirl.create :user, :with_mail, :admin => false
13
17
  user.roles << role
14
- user.save!
15
- SETTINGS[:login] ? {:user => user.id, :expires_at => 5.minutes.from_now} : {}
18
+ user.save
19
+ user
20
+ end
21
+
22
+ def as_default_manager
23
+ as_user(default_manager) do
24
+ yield
25
+ end
26
+ end
27
+
28
+ def as_default_reader
29
+ as_user(default_reader) do
30
+ yield
31
+ end
32
+ end
33
+
34
+ def default_manager
35
+ @default_manager ||= user_with_perms(Foreman::Plugin.find('foreman_discovery').default_roles['Discovery Manager'])
36
+ end
37
+
38
+ def default_reader
39
+ @default_reader ||= user_with_perms(Foreman::Plugin.find('foreman_discovery').default_roles['Discovery Reader'])
16
40
  end
17
41
 
18
42
  def set_session_user_default_reader
19
- set_session_user_with_perms Foreman::Plugin.find('foreman_discovery').default_roles['Discovery Reader']
43
+ set_session_user(default_reader)
20
44
  end
21
45
 
22
46
  def set_session_user_default_manager
23
- set_session_user_with_perms Foreman::Plugin.find('foreman_discovery').default_roles['Discovery Manager']
47
+ set_session_user(default_manager)
24
48
  end
25
49
 
26
50
  def extract_form_errors(response)
@@ -47,7 +71,19 @@ end
47
71
  def setup_hostgroup(host)
48
72
  domain = FactoryGirl.create(:domain)
49
73
  subnet = FactoryGirl.create(:subnet_ipv4, :network => "192.168.100.0")
50
- hostgroup = FactoryGirl.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :subnet => subnet, :domain => domain, :organizations => [host.organization], :locations => [host.location])
74
+ environment = FactoryGirl.create(:environment, :organizations => [host.organization], :locations => [host.location])
75
+ medium = FactoryGirl.create(:medium, :organizations => [host.organization], :locations => [host.location])
76
+ os = FactoryGirl.create(:operatingsystem, :with_ptables, :with_archs, :media => [medium])
77
+ hostgroup = FactoryGirl.create(
78
+ :hostgroup, :with_rootpass, :with_puppet_orchestration,
79
+ :operatingsystem => os,
80
+ :architecture => os.architectures.first,
81
+ :ptable => os.ptables.first,
82
+ :medium => os.media.first,
83
+ :environment => environment,
84
+ :subnet => subnet,
85
+ :domain => domain,
86
+ :organizations => [host.organization], :locations => [host.location])
51
87
  domain.subnets << hostgroup.subnet
52
88
  hostgroup.medium.organizations |= [host.organization]
53
89
  hostgroup.medium.locations |= [host.location]
@@ -1,6 +1,8 @@
1
1
  # This calls the main test_helper in Foreman-core
2
2
  require 'test_helper'
3
3
 
4
+ require 'test_helper_discovery'
5
+
4
6
  # Add plugin to FactoryGirl's paths
5
7
  FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
8
  FactoryGirl.reload
@@ -1,14 +1,16 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
- class FindDiscoveryRulesTest < ActiveSupport::TestCase
3
+ class DiscoveredExtensionsTest < ActiveSupport::TestCase
4
4
  include Foreman::Controller::DiscoveredExtensions
5
5
 
6
6
  setup do
7
7
  @facts = {
8
- "interfaces" => "lo,eth0",
8
+ "interfaces" => "lo,eth0,eth1",
9
9
  "ipaddress" => "192.168.100.42",
10
10
  "ipaddress_eth0" => "192.168.100.42",
11
+ "ipaddress_eth1" => "192.168.100.15",
11
12
  "macaddress_eth0" => "AA:BB:CC:DD:EE:FF",
13
+ "macaddress_eth1" => "AA:BB:CC:DD:EE:F1",
12
14
  "discovery_bootif" => "AA:BB:CC:DD:EE:FF",
13
15
  }
14
16
  set_default_settings
@@ -162,18 +164,63 @@ class FindDiscoveryRulesTest < ActiveSupport::TestCase
162
164
  assert_equal host.name, "macaabbccddeeff"
163
165
  end
164
166
 
165
- test "attributes from hostgroup are copied after auto provisioning" do
167
+ test "attributes from hostgroup are copied after auto provisioning for host with subnet detected" do
166
168
  facts = @facts.merge({"somefact" => "abc"})
169
+ domain = FactoryGirl.create(:domain)
170
+ subnet = FactoryGirl.create(:subnet_ipv4, :tftp, :dhcp, :name => 'subnet_100', :network => '192.168.100.0', :organizations => [Organization.find_by_name("Organization 1")], :locations => [Location.find_by_name("Location 1")])
167
171
  host = Host::Discovered.import_host(facts)
172
+ assert_equal subnet, host.subnet
173
+ hostgroup = FactoryGirl.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :pxe_loader => "PXELinux BIOS", :subnet => subnet, :domain => domain)
174
+ r1 = FactoryGirl.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
175
+ host.primary_interface.expects(:queue_tftp).at_least(1)
176
+ host.primary_interface.expects(:queue_dhcp).at_least(1)
177
+ assert managed_host = perform_auto_provision(host, r1)
178
+ assert_empty managed_host.errors
179
+ refute_nil hostgroup.pxe_loader, managed_host.pxe_loader
180
+ assert_equal hostgroup.pxe_loader, managed_host.pxe_loader
181
+ refute_nil hostgroup.subnet, managed_host.subnet
182
+ assert_equal hostgroup.subnet, managed_host.subnet
183
+ refute_nil hostgroup.subnet, managed_host.primary_interface.subnet
184
+ assert_equal hostgroup.subnet, managed_host.primary_interface.subnet
185
+ refute_nil hostgroup.subnet, managed_host.provision_interface.subnet
186
+ assert_equal hostgroup.subnet, managed_host.provision_interface.subnet
187
+ refute_nil hostgroup.domain, managed_host.domain
188
+ assert_equal hostgroup.domain, managed_host.domain
189
+ refute_nil hostgroup.environment, managed_host.environment
190
+ assert_equal hostgroup.environment, managed_host.environment
191
+ refute_nil hostgroup.puppet_proxy, managed_host.puppet_proxy
192
+ assert_equal hostgroup.puppet_proxy, managed_host.puppet_proxy
193
+ refute_nil hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
194
+ assert_equal hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
195
+ end
196
+
197
+ test "attributes from hostgroup are copied after auto provisioning for host without subnet detected" do
198
+ facts = @facts.merge({"somefact" => "abc"})
199
+ host = Host::Discovered.import_host(facts)
200
+ refute host.subnet
168
201
  domain = FactoryGirl.create(:domain)
169
- subnet = FactoryGirl.create(:subnet_ipv4, :name => 'subnet_100', :network => '192.168.100.0', :organizations => [host.organization], :locations => [host.location])
170
- hostgroup = FactoryGirl.create(:hostgroup, :with_environment, :with_rootpass, :with_os, :subnet => subnet, :domain => domain)
171
- r1 = FactoryGirl.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc",
172
- :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
202
+ subnet = FactoryGirl.create(:subnet_ipv4, :tftp, :dhcp, :name => 'subnet_100', :network => '192.168.100.0', :organizations => [Organization.find_by_name("Organization 1")], :locations => [Location.find_by_name("Location 1")])
203
+ hostgroup = FactoryGirl.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :pxe_loader => "PXELinux BIOS", :subnet => subnet, :domain => domain)
204
+ r1 = FactoryGirl.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
205
+ host.primary_interface.expects(:queue_tftp).at_least(1)
206
+ host.primary_interface.expects(:queue_dhcp).at_least(1)
173
207
  assert managed_host = perform_auto_provision(host, r1)
174
208
  assert_empty managed_host.errors
209
+ refute_nil hostgroup.pxe_loader, managed_host.pxe_loader
210
+ assert_equal hostgroup.pxe_loader, managed_host.pxe_loader
211
+ refute_nil hostgroup.subnet, managed_host.subnet
212
+ assert_equal hostgroup.subnet, managed_host.subnet
213
+ refute_nil hostgroup.subnet, managed_host.primary_interface.subnet
214
+ assert_equal hostgroup.subnet, managed_host.primary_interface.subnet
215
+ refute_nil hostgroup.subnet, managed_host.provision_interface.subnet
216
+ assert_equal hostgroup.subnet, managed_host.provision_interface.subnet
217
+ refute_nil hostgroup.domain, managed_host.domain
218
+ assert_equal hostgroup.domain, managed_host.domain
219
+ refute_nil hostgroup.environment, managed_host.environment
175
220
  assert_equal hostgroup.environment, managed_host.environment
221
+ refute_nil hostgroup.puppet_proxy, managed_host.puppet_proxy
176
222
  assert_equal hostgroup.puppet_proxy, managed_host.puppet_proxy
223
+ refute_nil hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
177
224
  assert_equal hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
178
225
  end
179
226
 
@@ -263,7 +310,5 @@ class FindDiscoveryRulesTest < ActiveSupport::TestCase
263
310
  refute perform_auto_provision host, r1
264
311
  assert_equal "xabc", host.name
265
312
  end
266
-
267
313
  end
268
-
269
314
  end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class DiscoveryAttributeSetTest < ActiveSupport::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class DiscoveryRuleTest < ActiveSupport::TestCase
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class DiscoveryTaxonomyExtensionsTest < ActiveSupport::TestCase
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class FactParserTest < ActiveSupport::TestCase
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class HostDiscoveredTest < ActiveSupport::TestCase
4
4
  setup do
@@ -16,6 +16,12 @@ class HostDiscoveredTest < ActiveSupport::TestCase
16
16
  assert Host::Discovered.find_by_name('mace41f13cc3658')
17
17
  end
18
18
 
19
+ test 'fact value association is set accordingly' do
20
+ discovered_host = FactoryGirl.create(:discovered_host, :with_facts, :fact_count => 1)
21
+ fact_value = discovered_host.fact_values.first
22
+ assert_equal discovered_host.id, fact_value.host.id
23
+ end
24
+
19
25
  test "should setup subnet" do
20
26
  raw = parse_json_fixture('/facts.json')
21
27
  subnet = FactoryGirl.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [organization_one], :locations => [location_one])
@@ -211,7 +217,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
211
217
  assert Token.where(:host_id => h.id).empty?
212
218
  end
213
219
 
214
- test "all non-discovery facts are deleted after provisioning" do
220
+ test "all non-discovery facts are deleted after managed conversion" do
215
221
  Setting[:discovery_clean_facts] = true
216
222
  raw = parse_json_fixture('/facts.json')['facts']
217
223
  raw.merge!({
@@ -226,7 +232,46 @@ class HostDiscoveredTest < ActiveSupport::TestCase
226
232
  assert_equal "content", managed.facts_hash['discovery_keep_me']
227
233
  end
228
234
 
229
- test "all facts are preserved after provisioning" do
235
+ test "primary interface is preserved after managed conversion" do
236
+ raw = parse_json_fixture('/facts.json')['facts']
237
+ raw.merge!({
238
+ 'keep_me' => "content",
239
+ 'discovery_keep_me' => "content",
240
+ })
241
+ host = Host::Discovered.import_host(raw)
242
+ host.save
243
+ managed = ::ForemanDiscovery::HostConverter.to_managed(host)
244
+ refute_nil managed.primary_interface
245
+ assert_equal "e4:1f:13:cc:36:58", managed.primary_interface.mac
246
+ end
247
+
248
+ test "provision interface is preserved after managed conversion" do
249
+ raw = parse_json_fixture('/facts.json')['facts']
250
+ raw.merge!({
251
+ 'keep_me' => "content",
252
+ 'discovery_keep_me' => "content",
253
+ })
254
+ host = Host::Discovered.import_host(raw)
255
+ host.save
256
+ managed = ::ForemanDiscovery::HostConverter.to_managed(host)
257
+ refute_nil managed.provision_interface
258
+ assert_equal "e4:1f:13:cc:36:58", managed.provision_interface.mac
259
+ end
260
+
261
+ test "provision interface host association is preserved after managed conversion" do
262
+ raw = parse_json_fixture('/facts.json')['facts']
263
+ raw.merge!({
264
+ 'keep_me' => "content",
265
+ 'discovery_keep_me' => "content",
266
+ })
267
+ host = Host::Discovered.import_host(raw)
268
+ host.save
269
+ managed = ::ForemanDiscovery::HostConverter.to_managed(host)
270
+ refute_nil managed.provision_interface
271
+ assert_equal host, managed.provision_interface.host
272
+ end
273
+
274
+ test "all facts are preserved after managed conversion" do
230
275
  raw = parse_json_fixture('/facts.json')['facts']
231
276
  raw.merge!({
232
277
  'keep_me' => "content",
@@ -0,0 +1,76 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class ManagedExtensionsTest < ActiveSupport::TestCase
4
+ class StubHost < ApplicationRecord
5
+ include Host::ManagedExtensions
6
+
7
+ # prevent from Could not find table exception
8
+ def self.table_name
9
+ 'hosts'
10
+ end
11
+ end
12
+
13
+ setup do
14
+ set_default_settings
15
+
16
+ @host = StubHost.new
17
+ @host.legacy_api = false
18
+ @host.type = "Host::Discovered"
19
+ @host.stubs(:old).returns(@host)
20
+ @facts = {}
21
+ @host.stubs(:facts).returns(@facts)
22
+ @post_queue = mock('Post Queue')
23
+ @host.stubs(:post_queue).returns(@post_queue)
24
+ @operatingsystem = mock('OS')
25
+ @host.stubs(:operatingsystem).returns(@operatingsystem)
26
+ @host.stubs(:provisioning_template).returns('A template')
27
+ @host.stubs(:medium).returns('http://a_medium')
28
+ @host.stubs(:architecture).returns(FactoryGirl.create(:architecture))
29
+ @kexec_json = {
30
+ :kernel => "http://a_host/vmlinuz",
31
+ :initrd => "http://a_host/someimage.img"
32
+ }
33
+ @host.stubs(:unattended_render).returns(@kexec_json.to_json)
34
+ end
35
+
36
+ test "queue_reboot enques reboot command when there is no kexec fact" do
37
+ @host.stubs(:type_changed?).returns(true)
38
+ @host.stubs(:new_record?).returns(false)
39
+ @host.id = 130513
40
+ ::Host::Base.stubs(:find).with(@host.id).returns(@host)
41
+ @post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
42
+ @host.queue_reboot
43
+ end
44
+
45
+ test "queue_reboot enques reboot command when there is no kexec template" do
46
+ @host.stubs(:type_changed?).returns(true)
47
+ @host.stubs(:new_record?).returns(false)
48
+ @host.id = 130513
49
+ ::Host::Base.stubs(:find).with(@host.id).returns(@host)
50
+ @facts['discovery_kexec'] = "Kexec version X.Y.Z"
51
+ @host.stubs(:provisioning_template).returns(nil)
52
+ @post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
53
+ @host.queue_reboot
54
+ end
55
+
56
+ test "queue_reboot enques kexec command" do
57
+ @host.stubs(:type_changed?).returns(true)
58
+ @host.stubs(:new_record?).returns(false)
59
+ @host.id = 130513
60
+ ::Host::Base.stubs(:find).with(@host.id).returns(@host)
61
+ @facts['discovery_kexec'] = "Kexec version X.Y.Z"
62
+ @post_queue.expects(:create).with(has_entry(:action, [@host, :setKexec])).once
63
+ @host.queue_reboot
64
+ end
65
+
66
+ test "setReboot calls reboot API" do
67
+ Host::Discovered.any_instance.expects(:reboot).once
68
+ @host.setReboot
69
+ end
70
+
71
+ test "setKexec calls boot_files_uri and kexec API" do
72
+ Host::Discovered.any_instance.expects(:kexec).once
73
+ @operatingsystem.expects(:boot_files_uri).with(@host.medium, @host.architecture, @host)
74
+ @host.setKexec
75
+ end
76
+ end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
 
3
3
  class SettingDiscoveredTest < ActiveSupport::TestCase
4
4
  test "can create setting of discovered type" do
@@ -1,5 +1,4 @@
1
1
  require 'test_plugin_helper'
2
- require 'test_helper_discovery'
3
2
 
4
3
  class DestroyHostNotificationTest < ActiveSupport::TestCase
5
4
  test 'destorying discovered host should remove notification' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_discovery
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alongoldboim
@@ -45,11 +45,12 @@ authors:
45
45
  - Swapnil Abnave
46
46
  - Timo Goebel
47
47
  - Tom Caspy
48
+ - Tomer Brisker
48
49
  - Yann Cézard
49
50
  autorequire:
50
51
  bindir: bin
51
52
  cert_chain: []
52
- date: 2017-04-07 00:00:00.000000000 Z
53
+ date: 2017-06-14 00:00:00.000000000 Z
53
54
  dependencies: []
54
55
  description: MaaS Discovery Plugin engine for Foreman
55
56
  email: gsutclif@redhat.com
@@ -75,7 +76,6 @@ files:
75
76
  - app/lib/facter_utils.rb
76
77
  - app/mailers/discovered_mailer.rb
77
78
  - app/models/concerns/discovery_taxonomy_extensions.rb
78
- - app/models/concerns/fact_value_extensions.rb
79
79
  - app/models/discovery_attribute_set.rb
80
80
  - app/models/discovery_rule.rb
81
81
  - app/models/host/discovered.rb
@@ -109,6 +109,7 @@ files:
109
109
  - app/views/discovered_hosts/_discovered_host_modal.html.erb
110
110
  - app/views/discovered_hosts/_discovered_hosts_list.html.erb
111
111
  - app/views/discovered_hosts/_selected_hosts.html.erb
112
+ - app/views/discovered_hosts/edit.html.erb
112
113
  - app/views/discovered_hosts/index.html.erb
113
114
  - app/views/discovered_hosts/multiple_destroy.html.erb
114
115
  - app/views/discovered_hosts/select_multiple_location.html.erb
@@ -149,6 +150,7 @@ files:
149
150
  - db/seeds.d/60_discovery_proxy_feature.rb
150
151
  - db/seeds.d/70_discovery_mail_notification.rb
151
152
  - db/seeds.d/80_discovery_ui_notification.rb
153
+ - db/seeds.d/90_add_permissions_from_default_roles.rb
152
154
  - extra/build_iso.sh
153
155
  - extra/discover_host
154
156
  - extra/discovery_init.sh.example
@@ -209,6 +211,7 @@ files:
209
211
  - locale/zh_TW/LC_MESSAGES/foreman_discovery.mo
210
212
  - locale/zh_TW/foreman_discovery.edit.po
211
213
  - locale/zh_TW/foreman_discovery.po
214
+ - test/factories/discovery_host_related.rb
212
215
  - test/factories/discovery_rule_related.rb
213
216
  - test/functional/api/v2/discovered_hosts_controller_test.rb
214
217
  - test/functional/api/v2/discovery_rules_controller_test.rb
@@ -216,7 +219,6 @@ files:
216
219
  - test/functional/discovered_hosts_controller_test.rb
217
220
  - test/functional/discovery_rules_controller_test.rb
218
221
  - test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
219
- - test/test_helper.rb
220
222
  - test/test_helper_discovery.rb
221
223
  - test/test_plugin_helper.rb
222
224
  - test/unit/discovered_extensions_test.rb
@@ -225,9 +227,9 @@ files:
225
227
  - test/unit/discovery_rule_test.rb
226
228
  - test/unit/discovery_taxonomy_extensions_test.rb
227
229
  - test/unit/fact_parser_test.rb
228
- - test/unit/fact_value_extensions_test.rb
229
230
  - test/unit/facts.json
230
231
  - test/unit/host_discovered_test.rb
232
+ - test/unit/managed_extensions_test.rb
231
233
  - test/unit/setting_discovered_test.rb
232
234
  - test/unit/ui_notifications/destroy_host_test.rb
233
235
  - test/unit/ui_notifications/new_host_test.rb
@@ -251,30 +253,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
253
  version: '0'
252
254
  requirements: []
253
255
  rubyforge_project:
254
- rubygems_version: 2.5.1
256
+ rubygems_version: 2.6.11
255
257
  signing_key:
256
258
  specification_version: 4
257
259
  summary: MaaS Discovery Plugin for Foreman
258
260
  test_files:
259
- - test/functional/discovery_rules_controller_test.rb
260
- - test/functional/api/v2/discovery_rules_controller_test.rb
261
- - test/functional/api/v2/fact_value_extensions_test.rb
262
- - test/functional/api/v2/discovered_hosts_controller_test.rb
263
- - test/functional/discovered_hosts_controller_test.rb
264
- - test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
265
- - test/factories/discovery_rule_related.rb
266
- - test/unit/discovered_extensions_test.rb
267
- - test/unit/fact_parser_test.rb
261
+ - test/test_plugin_helper.rb
262
+ - test/test_helper_discovery.rb
268
263
  - test/unit/discovery_attribute_set_test.rb
269
- - test/unit/setting_discovered_test.rb
270
264
  - test/unit/facts.json
271
- - test/unit/fact_value_extensions_test.rb
272
265
  - test/unit/discovered_mailer_test.rb
273
- - test/unit/discovery_taxonomy_extensions_test.rb
266
+ - test/unit/managed_extensions_test.rb
274
267
  - test/unit/discovery_rule_test.rb
275
- - test/unit/host_discovered_test.rb
276
- - test/unit/ui_notifications/destroy_host_test.rb
268
+ - test/unit/discovered_extensions_test.rb
269
+ - test/unit/discovery_taxonomy_extensions_test.rb
277
270
  - test/unit/ui_notifications/new_host_test.rb
278
- - test/test_helper_discovery.rb
279
- - test/test_plugin_helper.rb
280
- - test/test_helper.rb
271
+ - test/unit/ui_notifications/destroy_host_test.rb
272
+ - test/unit/setting_discovered_test.rb
273
+ - test/unit/host_discovered_test.rb
274
+ - test/unit/fact_parser_test.rb
275
+ - test/factories/discovery_host_related.rb
276
+ - test/factories/discovery_rule_related.rb
277
+ - test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
278
+ - test/functional/api/v2/fact_value_extensions_test.rb
279
+ - test/functional/api/v2/discovered_hosts_controller_test.rb
280
+ - test/functional/api/v2/discovery_rules_controller_test.rb
281
+ - test/functional/discovered_hosts_controller_test.rb
282
+ - test/functional/discovery_rules_controller_test.rb