foreman_discovery 15.0.1 → 16.1.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/api/v2/discovery_rules_controller.rb +1 -1
- data/app/controllers/concerns/foreman/controller/discovered_extensions.rb +4 -0
- data/app/controllers/discovered_hosts_controller.rb +1 -0
- data/app/controllers/discovery_rules_controller.rb +1 -1
- data/app/models/discovery_rule.rb +1 -1
- data/app/models/host/discovered.rb +37 -15
- data/app/models/host/managed_extensions.rb +1 -1
- data/app/models/setting/discovered.rb +26 -33
- data/app/services/foreman_discovery/fact_parser.rb +1 -1
- data/app/services/foreman_discovery/host_converter.rb +30 -2
- data/app/services/foreman_discovery/import_hooks/subnet_and_taxonomy.rb +6 -14
- data/app/services/foreman_discovery/subnet_suggestion.rb +26 -0
- data/app/views/discovered_hosts/_discovered_host_modal.html.erb +19 -17
- data/app/views/foreman_discovery/debian_kexec.erb +1 -1
- data/config/routes.rb +2 -0
- data/db/migrate/20150512150432_remove_old_discovery_reader_permissions.rb +1 -1
- data/db/migrate/20151023144501_regenerate_red_hat_kexec.rb +1 -1
- data/db/migrate/20180412124505_add_priority_score_to_discovery_rules.rb +1 -1
- data/extra/discover-host +21 -7
- data/lib/foreman_discovery/engine.rb +4 -4
- 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 +238 -139
- data/locale/ca/foreman_discovery.po +28 -8
- data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/de/foreman_discovery.edit.po +240 -140
- data/locale/de/foreman_discovery.po +31 -11
- data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en/foreman_discovery.edit.po +109 -83
- data/locale/en/foreman_discovery.po +24 -4
- data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en_GB/foreman_discovery.edit.po +241 -142
- data/locale/en_GB/foreman_discovery.po +31 -11
- data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/es/foreman_discovery.edit.po +240 -141
- data/locale/es/foreman_discovery.po +30 -10
- data/locale/foreman_discovery.pot +110 -84
- data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/fr/foreman_discovery.edit.po +237 -137
- data/locale/fr/foreman_discovery.po +28 -8
- data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/gl/foreman_discovery.edit.po +236 -137
- data/locale/gl/foreman_discovery.po +26 -6
- data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/it/foreman_discovery.edit.po +236 -137
- data/locale/it/foreman_discovery.po +26 -6
- data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ja/foreman_discovery.edit.po +238 -142
- data/locale/ja/foreman_discovery.po +29 -9
- data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ko/foreman_discovery.edit.po +236 -139
- data/locale/ko/foreman_discovery.po +28 -8
- data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/pt_BR/foreman_discovery.edit.po +239 -140
- data/locale/pt_BR/foreman_discovery.po +29 -9
- data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ru/foreman_discovery.edit.po +242 -143
- data/locale/ru/foreman_discovery.po +29 -9
- data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/sv_SE/foreman_discovery.edit.po +237 -138
- data/locale/sv_SE/foreman_discovery.po +27 -7
- data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_CN/foreman_discovery.edit.po +237 -141
- data/locale/zh_CN/foreman_discovery.po +28 -8
- data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_TW/foreman_discovery.edit.po +235 -139
- data/locale/zh_TW/foreman_discovery.po +26 -6
- data/test/facts/bond0-eth0-eth1-active-passive.json +128 -0
- data/test/facts/facts_with_lldp_bond_candidate.json +2 -9
- data/test/functional/api/v2/discovered_hosts_controller_test.rb +1 -0
- data/test/functional/discovered_hosts_controller_test.rb +4 -4
- data/test/integration/discovered_hosts_test.rb +6 -11
- data/test/test_helper_discovery.rb +12 -0
- data/test/unit/discovered_extensions_test.rb +53 -0
- data/test/unit/discovery_attribute_set_test.rb +13 -10
- data/test/unit/discovery_rule_test.rb +1 -0
- data/test/unit/host_discovered_test.rb +32 -13
- data/test/unit/managed_extensions_test.rb +1 -0
- metadata +8 -2
@@ -14,6 +14,7 @@ class DiscoveryAttributeSetTest < ActiveSupport::TestCase
|
|
14
14
|
:name => 'discovery_prefix',
|
15
15
|
:value => 'mac',
|
16
16
|
:category => 'Setting::Discovered')
|
17
|
+
::ForemanDiscovery::HostConverter.stubs(:unused_ip_for_host)
|
17
18
|
end
|
18
19
|
|
19
20
|
test "can search discovered hosts by cpu" do
|
@@ -41,15 +42,17 @@ class DiscoveryAttributeSetTest < ActiveSupport::TestCase
|
|
41
42
|
end
|
42
43
|
|
43
44
|
test "can search discovered hosts by disks_size" do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
begin
|
46
|
+
excluded = Setting[:excluded_facts]
|
47
|
+
Setting[:excluded_facts] = ["test"]
|
48
|
+
host = discover_host_from_facts(@facts)
|
49
|
+
disks_size = (host.facts_hash['blockdevice_sda_size'].to_f / 1024 / 1024).ceil
|
50
|
+
results = Host::Discovered.unscoped.search_for("disks_size = #{disks_size}")
|
51
|
+
assert_equal 1, results.count
|
52
|
+
results = Host::Discovered.unscoped.search_for("disks_size > #{disks_size}")
|
53
|
+
assert_equal 0, results.count
|
54
|
+
ensure
|
55
|
+
Setting[:excluded_facts] = excluded
|
56
|
+
end
|
54
57
|
end
|
55
58
|
end
|
@@ -3,6 +3,7 @@ require_relative '../test_plugin_helper'
|
|
3
3
|
class DiscoveryRuleTest < ActiveSupport::TestCase
|
4
4
|
setup do
|
5
5
|
@hostgroup = FactoryBot.create(:hostgroup)
|
6
|
+
::ForemanDiscovery::HostConverter.stubs(:unused_ip_for_host)
|
6
7
|
end
|
7
8
|
|
8
9
|
should allow_values(*valid_name_list).for(:name)
|
@@ -7,6 +7,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
7
7
|
setup do
|
8
8
|
@facts = parse_json_fixture('regular_host', true)
|
9
9
|
set_default_settings
|
10
|
+
::ForemanDiscovery::HostConverter.stubs(:unused_ip_for_host)
|
10
11
|
end
|
11
12
|
|
12
13
|
test "should be able to create Host::Discovered objects" do
|
@@ -38,9 +39,20 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
38
39
|
assert_equal discovered_host.id, fact_value.host.id
|
39
40
|
end
|
40
41
|
|
42
|
+
test "should detect bridge as the primary" do
|
43
|
+
# Detected primary should be the bridge (.2)
|
44
|
+
# "ipaddress_br180": "10.35.27.2"
|
45
|
+
# "ipaddress_eth0": "10.35.27.3"
|
46
|
+
# "ipaddress": "10.35.27.2"
|
47
|
+
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [organization_one], :locations => [location_one])
|
48
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
49
|
+
host = discover_host_from_facts(@facts)
|
50
|
+
assert_equal '10.35.27.2', host.primary_interface.ip
|
51
|
+
end
|
52
|
+
|
41
53
|
test "should setup subnet" do
|
42
54
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [organization_one], :locations => [location_one])
|
43
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
55
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
44
56
|
host = discover_host_from_facts(@facts)
|
45
57
|
assert_equal subnet, host.primary_interface.subnet
|
46
58
|
end
|
@@ -48,7 +60,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
48
60
|
test "should setup subnet when update_subnets_from_facts is true" do
|
49
61
|
Setting[:update_subnets_from_facts] = true
|
50
62
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [organization_one], :locations => [location_one])
|
51
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
63
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
52
64
|
host = discover_host_from_facts(@facts)
|
53
65
|
assert_equal subnet, host.primary_interface.subnet
|
54
66
|
end
|
@@ -59,7 +71,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
59
71
|
Setting['discovery_organization'] = org.name
|
60
72
|
Setting['discovery_location'] = loc.name
|
61
73
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [org], :locations => [loc])
|
62
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
74
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
63
75
|
host = discover_host_from_facts(@facts)
|
64
76
|
assert_equal subnet, host.primary_interface.subnet
|
65
77
|
assert_equal org, host.organization
|
@@ -74,7 +86,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
74
86
|
Setting['discovery_organization'] = nil
|
75
87
|
Setting['discovery_location'] = nil
|
76
88
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [org, org2], :locations => [loc, loc2])
|
77
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
89
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
78
90
|
host = discover_host_from_facts(@facts)
|
79
91
|
assert_equal subnet, host.primary_interface.subnet
|
80
92
|
assert host.organization
|
@@ -92,7 +104,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
92
104
|
Setting['discovery_organization'] = org.name
|
93
105
|
Setting['discovery_location'] = loc.name
|
94
106
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [org], :locations => [loc])
|
95
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
107
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
96
108
|
host = discover_host_from_facts(@facts.merge("test_org" => bad_org.title, "test_loc" => bad_loc.title))
|
97
109
|
assert_equal subnet, host.primary_interface.subnet
|
98
110
|
assert_equal org, host.organization
|
@@ -111,7 +123,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
111
123
|
Setting['discovery_organization'] = org.name
|
112
124
|
Setting['discovery_location'] = loc.name
|
113
125
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [org, bad_org], :locations => [loc, bad_loc])
|
114
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
126
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
115
127
|
host = discover_host_from_facts(@facts.merge("foreman_organization" => bad_org.title, "foreman_location" => bad_loc.title))
|
116
128
|
assert_equal subnet, host.primary_interface.subnet
|
117
129
|
assert_equal org, host.organization
|
@@ -129,7 +141,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
129
141
|
Setting['discovery_organization'] = org.name
|
130
142
|
Setting['discovery_location'] = loc.name
|
131
143
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [org, bad_org], :locations => [loc, bad_loc])
|
132
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
144
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
133
145
|
host = discover_host_from_facts(@facts)
|
134
146
|
assert_equal subnet, host.primary_interface.subnet
|
135
147
|
assert_equal org, host.organization
|
@@ -148,7 +160,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
148
160
|
Setting['discovery_organization'] = org.name
|
149
161
|
Setting['discovery_location'] = loc.name
|
150
162
|
subnet = FactoryBot.create(:subnet_ipv4, :name => 'Subnet99', :network => '10.35.27.0', :organizations => [org], :locations => [loc])
|
151
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
163
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
152
164
|
host = discover_host_from_facts(@facts)
|
153
165
|
assert_equal org, host.organization
|
154
166
|
assert_equal loc, host.location
|
@@ -188,7 +200,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
188
200
|
:organizations => [organization_one],
|
189
201
|
:locations => [location_one]
|
190
202
|
)
|
191
|
-
Subnet.expects(:subnet_for).with('10.35.27.
|
203
|
+
Subnet.expects(:subnet_for).with('10.35.27.2').returns(subnet)
|
192
204
|
ProxyAPI::TFTP.any_instance.expects(:set).with(anything, 'e4:1f:13:cc:36:58', anything).returns(true).times(3)
|
193
205
|
TemplateKind::PXE.each do |kind|
|
194
206
|
ProvisioningTemplate.where(:name => "#{kind.downcase}_discovery").first_or_create(
|
@@ -259,14 +271,14 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
259
271
|
assert_equal 'mace41f13cc3658', host1.name
|
260
272
|
assert_equal 'IBM System x -[7870K4G]-', host1.facts["productname"]
|
261
273
|
assert_equal 1, Host::Discovered.where(:name => 'mace41f13cc3658').count
|
262
|
-
assert_equal '10.35.27.
|
274
|
+
assert_equal '10.35.27.2', host1.ip
|
263
275
|
|
264
276
|
@facts["ipaddress_eth0"] = "1.2.3.4"
|
265
277
|
@facts["productname"] = "Dishwasher DW400"
|
266
278
|
host2 = discover_host_from_facts(@facts)
|
267
279
|
assert_equal 'mace41f13cc3658', host2.name
|
268
280
|
assert_equal 'Dishwasher DW400', host2.facts["productname"]
|
269
|
-
assert_equal '
|
281
|
+
assert_equal '10.35.27.2', host2.ip
|
270
282
|
assert_equal 1, Host::Discovered.where(:name => 'mace41f13cc3658').count
|
271
283
|
end
|
272
284
|
|
@@ -438,12 +450,19 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
438
450
|
end
|
439
451
|
end
|
440
452
|
|
453
|
+
test "primary interface via tagged VLAN is discovered with an IP" do
|
454
|
+
raw = parse_json_fixture('rhel7-vlan')
|
455
|
+
host = discover_host_from_facts(raw)
|
456
|
+
assert_equal "192.168.1.16", host.ip
|
457
|
+
assert_equal "eno49.444", host.primary_interface.identifier
|
458
|
+
end
|
459
|
+
|
441
460
|
test "primary interface isn't touched with no LLDP facts" do
|
442
461
|
Setting[:discovery_auto_bond] = true
|
443
462
|
raw = parse_json_fixture('regular_host', true)
|
444
463
|
host = discover_host_from_facts(raw)
|
445
464
|
refute_nil host.primary_interface
|
446
|
-
assert_equal "
|
465
|
+
assert_equal "br180", host.primary_interface.identifier
|
447
466
|
end
|
448
467
|
|
449
468
|
test "provision_interface isn't touched with no peer on the same VLAN" do
|
@@ -451,7 +470,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
451
470
|
raw = parse_json_fixture('facts_with_lldp', true)
|
452
471
|
host = discover_host_from_facts(raw)
|
453
472
|
refute_nil host.primary_interface
|
454
|
-
assert_equal "
|
473
|
+
assert_equal "br180", host.primary_interface.identifier
|
455
474
|
end
|
456
475
|
|
457
476
|
test "provision_interface is switched to bond0 with more than one interface on the same VLAN" do
|
@@ -30,6 +30,7 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
|
|
30
30
|
@host.stubs(:medium).returns('http://a_medium')
|
31
31
|
@host.stubs(:architecture).returns(FactoryBot.create(:architecture))
|
32
32
|
::MediumProviders::Default.any_instance.stubs(:validate).returns([])
|
33
|
+
::ForemanDiscovery::HostConverter.stubs(:unused_ip_for_host)
|
33
34
|
end
|
34
35
|
|
35
36
|
test "queue_reboot enques reboot command when there is no kexec fact" 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:
|
4
|
+
version: 16.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditi Puntambekar
|
@@ -9,6 +9,7 @@ authors:
|
|
9
9
|
- Alon Goldboim
|
10
10
|
- amirfefer
|
11
11
|
- Amit Karsale
|
12
|
+
- Amit Upadhye
|
12
13
|
- Amos Benari
|
13
14
|
- Avi Sharvit
|
14
15
|
- Bryan Kearney
|
@@ -34,6 +35,7 @@ authors:
|
|
34
35
|
- kgaikwad
|
35
36
|
- Lars Berntzon
|
36
37
|
- ldjebran
|
38
|
+
- Leos Stejskal
|
37
39
|
- Lukas Zapletal
|
38
40
|
- Lukáš Zapletal
|
39
41
|
- Marek Hulan
|
@@ -45,6 +47,7 @@ authors:
|
|
45
47
|
- odovzhenko
|
46
48
|
- Ohad Levy
|
47
49
|
- Ondrej Prazak
|
50
|
+
- Ondřej Ezr
|
48
51
|
- Ori Rabin
|
49
52
|
- orrabin
|
50
53
|
- Partha Aji
|
@@ -68,7 +71,7 @@ authors:
|
|
68
71
|
autorequire:
|
69
72
|
bindir: bin
|
70
73
|
cert_chain: []
|
71
|
-
date:
|
74
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
72
75
|
dependencies: []
|
73
76
|
description: MaaS Discovery Plugin engine for Foreman
|
74
77
|
email: gsutclif@redhat.com
|
@@ -114,6 +117,7 @@ files:
|
|
114
117
|
- app/services/foreman_discovery/node_api/node_resource.rb
|
115
118
|
- app/services/foreman_discovery/node_api/power.rb
|
116
119
|
- app/services/foreman_discovery/node_api/power_service.rb
|
120
|
+
- app/services/foreman_discovery/subnet_suggestion.rb
|
117
121
|
- app/services/foreman_discovery/ui_notifications/destroy_host.rb
|
118
122
|
- app/services/foreman_discovery/ui_notifications/new_host.rb
|
119
123
|
- app/views/api/v2/discovered_hosts/base.json.rabl
|
@@ -234,6 +238,7 @@ files:
|
|
234
238
|
- locale/zh_TW/foreman_discovery.po
|
235
239
|
- test/factories/discovery_host_related.rb
|
236
240
|
- test/factories/discovery_rule_related.rb
|
241
|
+
- test/facts/bond0-eth0-eth1-active-passive.json
|
237
242
|
- test/facts/default.json
|
238
243
|
- test/facts/dell_npars.json
|
239
244
|
- test/facts/dell_vlan.json
|
@@ -305,6 +310,7 @@ test_files:
|
|
305
310
|
- test/test_plugin_helper.rb
|
306
311
|
- test/facts/facts_with_lldp.json
|
307
312
|
- test/facts/dell_vlan.json
|
313
|
+
- test/facts/bond0-eth0-eth1-active-passive.json
|
308
314
|
- test/facts/simple-bond.json
|
309
315
|
- test/facts/rhel-r730.json
|
310
316
|
- test/facts/dell_npars.json
|