foreman_discovery 13.0.1 → 14.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +3 -1
- data/app/models/host/discovered.rb +8 -78
- data/app/models/host/managed_extensions.rb +3 -3
- data/app/models/nic/managed_extensions.rb +1 -1
- data/app/services/foreman_discovery/import_hook.rb +12 -0
- data/app/services/foreman_discovery/import_hook_service.rb +24 -0
- data/app/services/foreman_discovery/import_hooks/discovery_attribute.rb +33 -0
- data/app/services/foreman_discovery/import_hooks/lldp_neighbor.rb +11 -0
- data/app/services/foreman_discovery/import_hooks/lock_templates.rb +27 -0
- data/app/services/foreman_discovery/import_hooks/subnet_and_taxonomy.rb +63 -0
- data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +1 -1
- data/app/views/foreman_discovery/debian_kexec.erb +4 -3
- data/app/views/foreman_discovery/redhat_kexec.erb +4 -2
- data/db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb +1 -2
- data/db/seeds.d/50_discovery_templates.rb +9 -2
- data/extra/discover-host +1 -1
- data/lib/foreman_discovery/engine.rb +1 -1
- data/lib/foreman_discovery/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ca/foreman_discovery.edit.po +100 -61
- data/locale/ca/foreman_discovery.po +31 -4
- data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/de/foreman_discovery.edit.po +111 -71
- data/locale/de/foreman_discovery.po +41 -13
- data/locale/en/foreman_discovery.edit.po +21 -17
- data/locale/en/foreman_discovery.po +3 -0
- data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en_GB/foreman_discovery.edit.po +101 -62
- data/locale/en_GB/foreman_discovery.po +31 -4
- data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/es/foreman_discovery.edit.po +102 -63
- data/locale/es/foreman_discovery.po +32 -5
- data/locale/foreman_discovery.pot +24 -19
- data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/fr/foreman_discovery.edit.po +102 -63
- data/locale/fr/foreman_discovery.po +32 -5
- data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/gl/foreman_discovery.edit.po +100 -61
- data/locale/gl/foreman_discovery.po +31 -4
- data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/it/foreman_discovery.edit.po +102 -63
- data/locale/it/foreman_discovery.po +32 -5
- data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ja/foreman_discovery.edit.po +102 -63
- data/locale/ja/foreman_discovery.po +32 -5
- data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ko/foreman_discovery.edit.po +101 -62
- data/locale/ko/foreman_discovery.po +31 -4
- data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/pt_BR/foreman_discovery.edit.po +102 -63
- data/locale/pt_BR/foreman_discovery.po +32 -5
- data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ru/foreman_discovery.edit.po +102 -63
- data/locale/ru/foreman_discovery.po +32 -5
- data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/sv_SE/foreman_discovery.edit.po +101 -62
- data/locale/sv_SE/foreman_discovery.po +32 -5
- data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_CN/foreman_discovery.edit.po +101 -62
- data/locale/zh_CN/foreman_discovery.po +31 -4
- data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_TW/foreman_discovery.edit.po +102 -63
- data/locale/zh_TW/foreman_discovery.po +32 -5
- data/test/factories/discovery_host_related.rb +1 -1
- data/test/factories/discovery_rule_related.rb +4 -4
- data/{extra/discovery → test/facts}/default.json +0 -0
- data/{extra/discovery/many_ems.json → test/facts/dell_npars.json} +5 -7
- data/test/facts/dell_vlan.json +328 -0
- data/test/{unit → facts}/facts_with_lldp.json +0 -0
- data/test/{unit → facts}/facts_with_lldp_bond_candidate.json +0 -0
- data/test/facts/puppet3-virtual.json +109 -0
- data/{extra/discovery → test/facts}/pxeless-vlan.json +0 -0
- data/test/{unit/facts.json → facts/regular_host.json} +0 -0
- data/{extra/discovery → test/facts}/rhel-dl380-1kdisks.json +0 -0
- data/{extra/discovery → test/facts}/rhel-r730.json +0 -0
- data/{extra/discovery → test/facts}/rhel7-vlan.json +0 -0
- data/{extra/discovery → test/facts}/simple-bond.json +0 -0
- data/{extra/discovery → test/facts}/suse-vmware.json +0 -0
- data/test/facts/vmware_local.json +226 -0
- data/test/functional/api/v2/discovered_hosts_controller_test.rb +1 -1
- data/test/functional/api/v2/discovery_rules_controller_test.rb +1 -1
- data/test/functional/api/v2/fact_value_extensions_test.rb +1 -1
- data/test/functional/api/v2/settings_controller_test.rb +1 -1
- data/test/functional/discovered_hosts_controller_test.rb +3 -2
- data/test/functional/discovery_rules_controller_test.rb +3 -2
- data/test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb +1 -1
- data/test/integration/discovered_hosts_test.rb +1 -1
- data/test/models/setting_test.rb +1 -1
- data/test/test_helper_discovery.rb +6 -2
- data/test/test_plugin_helper.rb +2 -3
- data/test/unit/discovered_extensions_test.rb +7 -3
- data/test/unit/discovered_mailer_test.rb +1 -1
- data/test/unit/discovery_attribute_set_test.rb +2 -6
- data/test/unit/discovery_rule_test.rb +1 -1
- data/test/unit/discovery_taxonomy_extensions_test.rb +5 -6
- data/test/unit/fact_parser_test.rb +1 -1
- data/test/unit/host_discovered_test.rb +36 -36
- data/test/unit/lldp_neighbors_test.rb +3 -7
- data/test/unit/managed_extensions_test.rb +4 -7
- data/test/unit/setting_discovered_test.rb +1 -1
- data/test/unit/ui_notifications/destroy_host_test.rb +1 -5
- data/test/unit/ui_notifications/new_host_test.rb +2 -6
- metadata +38 -16
data/test/test_plugin_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# requires the main test_helper from Foreman-core
|
2
2
|
require 'test_helper'
|
3
|
-
|
4
|
-
require 'test_helper_discovery'
|
3
|
+
require_relative './test_helper_discovery'
|
5
4
|
|
6
5
|
# Add plugin to FactoryBot's paths
|
7
6
|
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_plugin_helper'
|
2
2
|
|
3
3
|
class DiscoveredExtensionsTest < ActiveSupport::TestCase
|
4
4
|
include Foreman::Controller::DiscoveredExtensions
|
@@ -157,7 +157,9 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
|
|
157
157
|
r1 = FactoryBot.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
|
158
158
|
host.primary_interface.expects(:queue_tftp).at_least(1)
|
159
159
|
host.primary_interface.expects(:queue_dhcp).at_least(1)
|
160
|
-
|
160
|
+
managed_host = perform_auto_provision(host, r1)
|
161
|
+
assert_empty host.errors
|
162
|
+
assert managed_host
|
161
163
|
assert_empty managed_host.errors
|
162
164
|
refute_nil hostgroup.pxe_loader, managed_host.pxe_loader
|
163
165
|
assert_equal hostgroup.pxe_loader, managed_host.pxe_loader
|
@@ -187,7 +189,9 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
|
|
187
189
|
r1 = FactoryBot.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
|
188
190
|
host.primary_interface.expects(:queue_tftp).at_least(1)
|
189
191
|
host.primary_interface.expects(:queue_dhcp).at_least(1)
|
190
|
-
|
192
|
+
managed_host = perform_auto_provision(host, r1)
|
193
|
+
assert_empty host.errors
|
194
|
+
assert managed_host
|
191
195
|
assert_empty managed_host.errors
|
192
196
|
refute_nil hostgroup.pxe_loader, managed_host.pxe_loader
|
193
197
|
assert_equal hostgroup.pxe_loader, managed_host.pxe_loader
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_plugin_helper'
|
2
2
|
|
3
3
|
class DiscoveryAttributeSetTest < ActiveSupport::TestCase
|
4
4
|
include FactImporterIsolation
|
5
5
|
allow_transactions_for_any_importer
|
6
6
|
|
7
7
|
setup do
|
8
|
-
@facts = parse_json_fixture('
|
8
|
+
@facts = parse_json_fixture('regular_host', true)
|
9
9
|
FactoryBot.create(:setting,
|
10
10
|
:name => 'discovery_hostname',
|
11
11
|
:value => 'discovery_bootif',
|
@@ -48,8 +48,4 @@ class DiscoveryAttributeSetTest < ActiveSupport::TestCase
|
|
48
48
|
results = Host::Discovered.search_for("disks_size > #{disks_size}")
|
49
49
|
assert_equal 0, results.count
|
50
50
|
end
|
51
|
-
|
52
|
-
def parse_json_fixture(relative_path)
|
53
|
-
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
54
|
-
end
|
55
51
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_plugin_helper'
|
2
2
|
|
3
3
|
class DiscoveryTaxonomyExtensionsTest < ActiveSupport::TestCase
|
4
|
+
include FactImporterIsolation
|
5
|
+
allow_transactions_for_any_importer
|
6
|
+
|
4
7
|
setup do
|
5
|
-
@facts = parse_json_fixture('
|
8
|
+
@facts = parse_json_fixture('regular_host', true)
|
6
9
|
set_default_settings
|
7
10
|
end
|
8
11
|
|
@@ -17,8 +20,4 @@ class DiscoveryTaxonomyExtensionsTest < ActiveSupport::TestCase
|
|
17
20
|
refute location.destroy, 'Location was destroyed but it should not be allowed'
|
18
21
|
end
|
19
22
|
end
|
20
|
-
|
21
|
-
def parse_json_fixture(relative_path)
|
22
|
-
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
23
|
-
end
|
24
23
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_plugin_helper'
|
2
2
|
|
3
3
|
class HostDiscoveredTest < ActiveSupport::TestCase
|
4
4
|
include FactImporterIsolation
|
5
5
|
allow_transactions_for_any_importer
|
6
6
|
|
7
7
|
setup do
|
8
|
-
@facts = parse_json_fixture('
|
8
|
+
@facts = parse_json_fixture('regular_host', true)
|
9
9
|
set_default_settings
|
10
10
|
end
|
11
11
|
|
@@ -112,28 +112,32 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
112
112
|
end
|
113
113
|
|
114
114
|
test "should lock host into discovery via PXE configuration" do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
Subnet.expects(:subnet_for).with('10.35.27.3').returns(subnet)
|
126
|
-
ProxyAPI::TFTP.any_instance.expects(:set).with(anything, 'e4:1f:13:cc:36:58', anything).returns(true).times(3)
|
127
|
-
TemplateKind::PXE.each do |kind|
|
128
|
-
ProvisioningTemplate.where(:name => "#{kind.downcase}_discovery").first_or_create(
|
129
|
-
:template_kind_id => template_kinds(kind.downcase.to_sym),
|
130
|
-
:snippet => true,
|
131
|
-
:template => "test"
|
115
|
+
begin
|
116
|
+
Host::Discovered.delete('mace41f13cc3658')
|
117
|
+
Setting[:discovery_lock] = true
|
118
|
+
subnet = FactoryBot.create(:subnet,
|
119
|
+
:tftp,
|
120
|
+
:network => '10.35.27.0',
|
121
|
+
:cidr => '24',
|
122
|
+
:mask => '255.255.255.0',
|
123
|
+
:organizations => [organization_one],
|
124
|
+
:locations => [location_one]
|
132
125
|
)
|
126
|
+
Subnet.expects(:subnet_for).with('10.35.27.3').returns(subnet)
|
127
|
+
ProxyAPI::TFTP.any_instance.expects(:set).with(anything, 'e4:1f:13:cc:36:58', anything).returns(true).times(3)
|
128
|
+
TemplateKind::PXE.each do |kind|
|
129
|
+
ProvisioningTemplate.where(:name => "#{kind.downcase}_discovery").first_or_create(
|
130
|
+
:template_kind_id => template_kinds(kind.downcase.to_sym),
|
131
|
+
:snippet => true,
|
132
|
+
:template => "test"
|
133
|
+
)
|
134
|
+
end
|
135
|
+
assert discover_host_from_facts(@facts)
|
136
|
+
assert Host::Discovered.find_by_name('mace41f13cc3658')
|
137
|
+
refute Host::Managed.find_by_name('mace41f13cc3658')
|
138
|
+
ensure
|
139
|
+
Setting[:discovery_lock] = false
|
133
140
|
end
|
134
|
-
assert discover_host_from_facts(@facts)
|
135
|
-
assert Host::Discovered.find_by_name('mace41f13cc3658')
|
136
|
-
refute Host::Managed.find_by_name('mace41f13cc3658')
|
137
141
|
end
|
138
142
|
|
139
143
|
test "should create discovered host with fact_name as a name if it is a valid mac" do
|
@@ -258,7 +262,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
258
262
|
|
259
263
|
test "all non-discovery facts are deleted after managed conversion" do
|
260
264
|
Setting[:discovery_clean_facts] = true
|
261
|
-
raw = parse_json_fixture('
|
265
|
+
raw = parse_json_fixture('regular_host', true)
|
262
266
|
raw.merge!({
|
263
267
|
'delete_me' => "content",
|
264
268
|
'discovery_keep_me' => "content",
|
@@ -272,7 +276,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
272
276
|
end
|
273
277
|
|
274
278
|
test "primary interface is preserved after managed conversion" do
|
275
|
-
raw = parse_json_fixture('
|
279
|
+
raw = parse_json_fixture('regular_host', true)
|
276
280
|
raw.merge!({
|
277
281
|
'keep_me' => "content",
|
278
282
|
'discovery_keep_me' => "content",
|
@@ -285,7 +289,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
285
289
|
end
|
286
290
|
|
287
291
|
test "provision interface is preserved after managed conversion" do
|
288
|
-
raw = parse_json_fixture('
|
292
|
+
raw = parse_json_fixture('regular_host', true)
|
289
293
|
raw.merge!({
|
290
294
|
'keep_me' => "content",
|
291
295
|
'discovery_keep_me' => "content",
|
@@ -298,7 +302,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
298
302
|
end
|
299
303
|
|
300
304
|
test "provision interface host association is preserved after managed conversion" do
|
301
|
-
raw = parse_json_fixture('
|
305
|
+
raw = parse_json_fixture('regular_host', true)
|
302
306
|
raw.merge!({
|
303
307
|
'keep_me' => "content",
|
304
308
|
'discovery_keep_me' => "content",
|
@@ -311,7 +315,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
311
315
|
end
|
312
316
|
|
313
317
|
test "all facts are preserved after managed conversion" do
|
314
|
-
raw = parse_json_fixture('
|
318
|
+
raw = parse_json_fixture('regular_host', true)
|
315
319
|
raw.merge!({
|
316
320
|
'keep_me' => "content",
|
317
321
|
'discovery_keep_me' => "content",
|
@@ -380,7 +384,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
380
384
|
|
381
385
|
test "primary interface isn't touched with no LLDP facts" do
|
382
386
|
Setting[:discovery_auto_bond] = true
|
383
|
-
raw = parse_json_fixture('
|
387
|
+
raw = parse_json_fixture('regular_host', true)
|
384
388
|
host = discover_host_from_facts(raw)
|
385
389
|
refute_nil host.primary_interface
|
386
390
|
assert_equal "eth0", host.primary_interface.identifier
|
@@ -388,7 +392,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
388
392
|
|
389
393
|
test "provision_interface isn't touched with no peer on the same VLAN" do
|
390
394
|
Setting[:discovery_auto_bond] = true
|
391
|
-
raw = parse_json_fixture('
|
395
|
+
raw = parse_json_fixture('facts_with_lldp', true)
|
392
396
|
host = discover_host_from_facts(raw)
|
393
397
|
refute_nil host.primary_interface
|
394
398
|
assert_equal "eth0", host.primary_interface.identifier
|
@@ -396,7 +400,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
396
400
|
|
397
401
|
test "provision_interface is switched to bond0 with more than one interface on the same VLAN" do
|
398
402
|
Setting[:discovery_auto_bond] = true
|
399
|
-
raw = parse_json_fixture('
|
403
|
+
raw = parse_json_fixture('facts_with_lldp_bond_candidate', true)
|
400
404
|
host = discover_host_from_facts(raw)
|
401
405
|
refute_nil host.primary_interface
|
402
406
|
assert_equal "bond0", host.primary_interface.identifier
|
@@ -404,7 +408,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
404
408
|
|
405
409
|
test "provision_interface is not switched to bond0 if disabled" do
|
406
410
|
Setting[:discovery_auto_bond] = false
|
407
|
-
raw = parse_json_fixture('
|
411
|
+
raw = parse_json_fixture('facts_with_lldp_bond_candidate', true)
|
408
412
|
host = discover_host_from_facts(raw)
|
409
413
|
refute_nil host.primary_interface
|
410
414
|
assert_equal "eth0", host.primary_interface.identifier
|
@@ -412,7 +416,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
412
416
|
|
413
417
|
test "former provision_interface is cleanup up after switching to bond0" do
|
414
418
|
Setting[:discovery_auto_bond] = true
|
415
|
-
raw = parse_json_fixture('
|
419
|
+
raw = parse_json_fixture('facts_with_lldp_bond_candidate', true)
|
416
420
|
host = discover_host_from_facts(raw)
|
417
421
|
refute_nil host.primary_interface
|
418
422
|
|
@@ -427,8 +431,4 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
427
431
|
assert_nil former_interface.name
|
428
432
|
assert_equal false, former_interface.primary
|
429
433
|
end
|
430
|
-
|
431
|
-
def parse_json_fixture(relative_path)
|
432
|
-
JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
433
|
-
end
|
434
434
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_plugin_helper'
|
2
2
|
|
3
3
|
class LldpNeighborsTest < ActiveSupport::TestCase
|
4
4
|
test "#get_neighbors_by_interface gives nothing with no LLDP facts" do
|
@@ -35,7 +35,7 @@ class LldpNeighborsTest < ActiveSupport::TestCase
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def simple_facts
|
38
|
-
neighbors '
|
38
|
+
neighbors 'regular_host'
|
39
39
|
end
|
40
40
|
|
41
41
|
def lldp_facts
|
@@ -47,10 +47,6 @@ class LldpNeighborsTest < ActiveSupport::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def neighbors(name)
|
50
|
-
ForemanDiscovery::LldpNeighbors.from_facts(
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_facts(name)
|
54
|
-
JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + "/#{name}.json")))['facts']
|
50
|
+
ForemanDiscovery::LldpNeighbors.from_facts(parse_json_fixture(name, true))
|
55
51
|
end
|
56
52
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_plugin_helper'
|
2
2
|
|
3
3
|
class ManagedExtensionsTest < ActiveSupport::TestCase
|
4
4
|
class StubHost < ApplicationRecord
|
@@ -33,19 +33,17 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
test "queue_reboot enques reboot command when there is no kexec fact" do
|
36
|
-
@host.stubs(:
|
36
|
+
@host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
|
37
37
|
@host.stubs(:new_record?).returns(false)
|
38
38
|
@host.id = 130513
|
39
|
-
::Host::Base.stubs(:find).with(@host.id).returns(@host)
|
40
39
|
@post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
|
41
40
|
@host.queue_reboot
|
42
41
|
end
|
43
42
|
|
44
43
|
test "queue_reboot enques reboot command when there is no kexec template" do
|
45
|
-
@host.stubs(:
|
44
|
+
@host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
|
46
45
|
@host.stubs(:new_record?).returns(false)
|
47
46
|
@host.id = 130513
|
48
|
-
::Host::Base.stubs(:find).with(@host.id).returns(@host)
|
49
47
|
@facts['discovery_kexec'] = "Kexec version X.Y.Z"
|
50
48
|
@host.stubs(:provisioning_template).returns(nil)
|
51
49
|
@post_queue.expects(:create).with(has_entry(:action, [@host, :setReboot])).once
|
@@ -53,10 +51,9 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
|
|
53
51
|
end
|
54
52
|
|
55
53
|
test "queue_reboot enques kexec command" do
|
56
|
-
@host.stubs(:
|
54
|
+
@host.stubs(:will_save_change_to_attribute?).with(:type, from: 'Host::Discovered').returns(true)
|
57
55
|
@host.stubs(:new_record?).returns(false)
|
58
56
|
@host.id = 130513
|
59
|
-
::Host::Base.stubs(:find).with(@host.id).returns(@host)
|
60
57
|
@facts['discovery_kexec'] = "Kexec version X.Y.Z"
|
61
58
|
@post_queue.expects(:create).with(has_entry(:action, [@host, :setKexec])).once
|
62
59
|
@host.queue_reboot
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../test_plugin_helper'
|
2
2
|
|
3
3
|
class DestroyHostNotificationTest < ActiveSupport::TestCase
|
4
4
|
alias_method :blueprint, :discovered_notification_blueprint
|
@@ -51,8 +51,4 @@ class DestroyHostNotificationTest < ActiveSupport::TestCase
|
|
51
51
|
assert new_host.save!
|
52
52
|
assert_equal 1, blueprint.notifications.count
|
53
53
|
end
|
54
|
-
|
55
|
-
def parse_json_fixture(relative_path)
|
56
|
-
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
57
|
-
end
|
58
54
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../test_plugin_helper'
|
2
2
|
|
3
3
|
class NewHostNotificationTest < ActiveSupport::TestCase
|
4
4
|
include FactImporterIsolation
|
@@ -12,7 +12,7 @@ class NewHostNotificationTest < ActiveSupport::TestCase
|
|
12
12
|
test 'new discovered host should generate a notification' do
|
13
13
|
set_default_settings
|
14
14
|
assert_difference('blueprint.notifications.count') do
|
15
|
-
discover_host_from_facts(parse_json_fixture('
|
15
|
+
discover_host_from_facts(parse_json_fixture('regular_host', true))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -26,8 +26,4 @@ class NewHostNotificationTest < ActiveSupport::TestCase
|
|
26
26
|
assert_equal 1, blueprint.notifications.count
|
27
27
|
assert_not_equal expired_at, blueprint.notifications.first.expired_at
|
28
28
|
end
|
29
|
-
|
30
|
-
def parse_json_fixture(relative_path)
|
31
|
-
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
|
32
|
-
end
|
33
29
|
end
|
metadata
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_discovery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 14.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Aditi Puntambekar
|
7
8
|
- alongoldboim
|
8
9
|
- Alon Goldboim
|
9
10
|
- amirfefer
|
@@ -17,6 +18,7 @@ authors:
|
|
17
18
|
- Daniel Lobato García
|
18
19
|
- Danny Smit
|
19
20
|
- David Davis
|
21
|
+
- Djebran Lezzoum
|
20
22
|
- Dominic Cleal
|
21
23
|
- Eric D. Helms
|
22
24
|
- Ewoud Kohl van Wijngaarden
|
@@ -65,7 +67,7 @@ authors:
|
|
65
67
|
autorequire:
|
66
68
|
bindir: bin
|
67
69
|
cert_chain: []
|
68
|
-
date: 2018-
|
70
|
+
date: 2018-11-05 00:00:00.000000000 Z
|
69
71
|
dependencies: []
|
70
72
|
description: MaaS Discovery Plugin engine for Foreman
|
71
73
|
email: gsutclif@redhat.com
|
@@ -100,6 +102,12 @@ files:
|
|
100
102
|
- app/models/setting/discovered.rb
|
101
103
|
- app/services/foreman_discovery/fact_parser.rb
|
102
104
|
- app/services/foreman_discovery/host_converter.rb
|
105
|
+
- app/services/foreman_discovery/import_hook.rb
|
106
|
+
- app/services/foreman_discovery/import_hook_service.rb
|
107
|
+
- app/services/foreman_discovery/import_hooks/discovery_attribute.rb
|
108
|
+
- app/services/foreman_discovery/import_hooks/lldp_neighbor.rb
|
109
|
+
- app/services/foreman_discovery/import_hooks/lock_templates.rb
|
110
|
+
- app/services/foreman_discovery/import_hooks/subnet_and_taxonomy.rb
|
103
111
|
- app/services/foreman_discovery/lldp_neighbors.rb
|
104
112
|
- app/services/foreman_discovery/node_api/inventory.rb
|
105
113
|
- app/services/foreman_discovery/node_api/node_resource.rb
|
@@ -171,14 +179,6 @@ files:
|
|
171
179
|
- db/seeds.d/80_discovery_ui_notification.rb
|
172
180
|
- db/seeds.d/90_add_permissions_from_default_roles.rb
|
173
181
|
- extra/discover-host
|
174
|
-
- extra/discovery/default.json
|
175
|
-
- extra/discovery/many_ems.json
|
176
|
-
- extra/discovery/pxeless-vlan.json
|
177
|
-
- extra/discovery/rhel-dl380-1kdisks.json
|
178
|
-
- extra/discovery/rhel-r730.json
|
179
|
-
- extra/discovery/rhel7-vlan.json
|
180
|
-
- extra/discovery/simple-bond.json
|
181
|
-
- extra/discovery/suse-vmware.json
|
182
182
|
- extra/generate-authors-file
|
183
183
|
- lib/discovery.rake
|
184
184
|
- lib/foreman_discovery.rb
|
@@ -233,6 +233,20 @@ files:
|
|
233
233
|
- locale/zh_TW/foreman_discovery.po
|
234
234
|
- test/factories/discovery_host_related.rb
|
235
235
|
- test/factories/discovery_rule_related.rb
|
236
|
+
- test/facts/default.json
|
237
|
+
- test/facts/dell_npars.json
|
238
|
+
- test/facts/dell_vlan.json
|
239
|
+
- test/facts/facts_with_lldp.json
|
240
|
+
- test/facts/facts_with_lldp_bond_candidate.json
|
241
|
+
- test/facts/puppet3-virtual.json
|
242
|
+
- test/facts/pxeless-vlan.json
|
243
|
+
- test/facts/regular_host.json
|
244
|
+
- test/facts/rhel-dl380-1kdisks.json
|
245
|
+
- test/facts/rhel-r730.json
|
246
|
+
- test/facts/rhel7-vlan.json
|
247
|
+
- test/facts/simple-bond.json
|
248
|
+
- test/facts/suse-vmware.json
|
249
|
+
- test/facts/vmware_local.json
|
236
250
|
- test/functional/api/v2/discovered_hosts_controller_test.rb
|
237
251
|
- test/functional/api/v2/discovery_rules_controller_test.rb
|
238
252
|
- test/functional/api/v2/fact_value_extensions_test.rb
|
@@ -250,9 +264,6 @@ files:
|
|
250
264
|
- test/unit/discovery_rule_test.rb
|
251
265
|
- test/unit/discovery_taxonomy_extensions_test.rb
|
252
266
|
- test/unit/fact_parser_test.rb
|
253
|
-
- test/unit/facts.json
|
254
|
-
- test/unit/facts_with_lldp.json
|
255
|
-
- test/unit/facts_with_lldp_bond_candidate.json
|
256
267
|
- test/unit/host_discovered_test.rb
|
257
268
|
- test/unit/lldp_neighbors_test.rb
|
258
269
|
- test/unit/managed_extensions_test.rb
|
@@ -288,10 +299,22 @@ test_files:
|
|
288
299
|
- test/test_plugin_helper.rb
|
289
300
|
- test/test_helper_discovery.rb
|
290
301
|
- test/integration/discovered_hosts_test.rb
|
291
|
-
- test/
|
302
|
+
- test/facts/facts_with_lldp.json
|
303
|
+
- test/facts/dell_vlan.json
|
304
|
+
- test/facts/rhel-r730.json
|
305
|
+
- test/facts/regular_host.json
|
306
|
+
- test/facts/vmware_local.json
|
307
|
+
- test/facts/pxeless-vlan.json
|
308
|
+
- test/facts/dell_npars.json
|
309
|
+
- test/facts/simple-bond.json
|
310
|
+
- test/facts/puppet3-virtual.json
|
311
|
+
- test/facts/rhel-dl380-1kdisks.json
|
312
|
+
- test/facts/suse-vmware.json
|
313
|
+
- test/facts/default.json
|
314
|
+
- test/facts/rhel7-vlan.json
|
315
|
+
- test/facts/facts_with_lldp_bond_candidate.json
|
292
316
|
- test/unit/lldp_neighbors_test.rb
|
293
317
|
- test/unit/discovery_attribute_set_test.rb
|
294
|
-
- test/unit/facts.json
|
295
318
|
- test/unit/discovered_mailer_test.rb
|
296
319
|
- test/unit/managed_extensions_test.rb
|
297
320
|
- test/unit/discovery_rule_test.rb
|
@@ -302,7 +325,6 @@ test_files:
|
|
302
325
|
- test/unit/setting_discovered_test.rb
|
303
326
|
- test/unit/host_discovered_test.rb
|
304
327
|
- test/unit/fact_parser_test.rb
|
305
|
-
- test/unit/facts_with_lldp_bond_candidate.json
|
306
328
|
- test/factories/discovery_host_related.rb
|
307
329
|
- test/factories/discovery_rule_related.rb
|
308
330
|
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|