foreman_discovery 22.0.2 → 22.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/discovered_hosts_controller.rb +1 -1
- data/app/models/host/discovered.rb +3 -3
- data/app/services/foreman_discovery/import_hooks/lock_templates.rb +1 -1
- data/app/views/discovered_hosts/_discovered_host.html.erb +1 -1
- data/app/views/discovered_hosts/_discovered_hosts_list.html.erb +1 -1
- data/db/migrate/20221102065954_fix_discovery_settings_category_to_dsl.rb +1 -1
- data/db/migrate/20221102075151_migrate_discovery_hostname_and_fact_column_to_array.rb +13 -0
- data/lib/foreman_discovery/engine.rb +6 -12
- data/lib/foreman_discovery/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ca/foreman_discovery.po +8 -8
- data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/de/foreman_discovery.po +6 -6
- data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en/foreman_discovery.po +5 -5
- data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/en_GB/foreman_discovery.po +6 -6
- data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/es/foreman_discovery.po +65 -61
- data/locale/foreman_discovery.pot +212 -211
- data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/fr/foreman_discovery.po +19 -15
- data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/gl/foreman_discovery.po +5 -5
- data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/it/foreman_discovery.po +7 -6
- data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ja/foreman_discovery.po +18 -18
- data/locale/ka/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ka/foreman_discovery.po +834 -0
- data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ko/foreman_discovery.po +5 -5
- data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/pt_BR/foreman_discovery.po +45 -41
- data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/ru/foreman_discovery.po +5 -5
- data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/sv_SE/foreman_discovery.po +5 -5
- data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_CN/foreman_discovery.po +15 -15
- data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
- data/locale/zh_TW/foreman_discovery.po +5 -5
- data/test/functional/api/v2/fact_value_extensions_test.rb +1 -1
- data/test/functional/discovered_hosts_controller_test.rb +1 -1
- data/test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb +89 -0
- data/test/test_helper_discovery.rb +1 -1
- data/test/unit/discovery_attribute_set_test.rb +1 -1
- data/test/unit/host_discovered_test.rb +3 -3
- metadata +21 -17
- data/app/models/setting/discovered.rb +0 -22
data/test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative '../test_plugin_helper'
|
2
|
+
require ForemanDiscovery::Engine.root.join('db/migrate/20221102075151_migrate_discovery_hostname_and_fact_column_to_array')
|
3
|
+
|
4
|
+
class MigrateDiscoveryHostnameAndFactColumnToArrayTest < ActiveSupport::TestCase
|
5
|
+
let(:migrations_paths) { ActiveRecord::Migrator.migrations_paths + [ForemanDiscovery::Engine.root.join('db/migrate/').to_s] }
|
6
|
+
|
7
|
+
let(:previous_version) { '20221102065954'.to_i }
|
8
|
+
let(:current_version) { '20221102075151'.to_i }
|
9
|
+
|
10
|
+
#only load the two migrations we care about (previous one and current one)
|
11
|
+
let(:migrations) do
|
12
|
+
[
|
13
|
+
ActiveRecord::MigrationProxy.new("FixDiscoverySettingsCategoryToDsl", previous_version, "#{ForemanDiscovery::Engine.root}/db/migrate/20221102065954_fix_discovery_settings_category_to_dsl.rb", ""),
|
14
|
+
ActiveRecord::MigrationProxy.new("MigrateDiscoveryHostnameAndFactColumnToArray", current_version, "#{ForemanDiscovery::Engine.root}/db/migrate/20221102075151_migrate_discovery_hostname_and_fact_column_to_array.rb", "")
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def migrate_up
|
19
|
+
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, current_version).migrate
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup
|
23
|
+
ActiveRecord::Migration.suppress_messages do
|
24
|
+
ActiveRecord::Migrator.new(:down, migrations, ActiveRecord::SchemaMigration, previous_version).migrate
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_discovery_hostname_string
|
29
|
+
Setting['discovery_hostname'] = 'discovery_bootif'
|
30
|
+
|
31
|
+
migrate_up
|
32
|
+
|
33
|
+
assert_equal ['discovery_bootif'], Setting['discovery_hostname']
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_discovery_hostname_multistring
|
37
|
+
setting = Setting.find_or_create_by(name: 'discovery_hostname')
|
38
|
+
setting.value = 'discovery_bootif, fqdn'
|
39
|
+
setting.save(validate: false)
|
40
|
+
|
41
|
+
migrate_up
|
42
|
+
|
43
|
+
assert_equal ['discovery_bootif', 'fqdn'], Setting['discovery_hostname']
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_discovery_hostname_array
|
47
|
+
Setting['discovery_hostname'] = ['discovery_bootif']
|
48
|
+
|
49
|
+
migrate_up
|
50
|
+
|
51
|
+
assert_equal ['discovery_bootif'], Setting['discovery_hostname']
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_discovery_fact_column_empty
|
55
|
+
setting = Setting.find_or_create_by(name: 'discovery_fact_column')
|
56
|
+
setting.value = ''
|
57
|
+
setting.save(validate: false)
|
58
|
+
|
59
|
+
migrate_up
|
60
|
+
|
61
|
+
assert_equal [], Setting['discovery_fact_column']
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_discovery_fact_column_string
|
65
|
+
Setting['discovery_fact_column'] = 'bios_vendor'
|
66
|
+
|
67
|
+
migrate_up
|
68
|
+
|
69
|
+
assert_equal ['bios_vendor'], Setting['discovery_fact_column']
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_discovery_fact_column_multistring
|
73
|
+
setting = Setting.find_or_create_by(name: 'discovery_fact_column')
|
74
|
+
setting.value = 'bios_vendor, fqdn'
|
75
|
+
setting.save(validate: false)
|
76
|
+
|
77
|
+
migrate_up
|
78
|
+
|
79
|
+
assert_equal ['bios_vendor', 'fqdn'], Setting['discovery_fact_column']
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_discovery_fact_column_array
|
83
|
+
Setting['discovery_fact_column'] = ['bios_vendor']
|
84
|
+
|
85
|
+
migrate_up
|
86
|
+
|
87
|
+
assert_equal ['bios_vendor'], Setting['discovery_fact_column']
|
88
|
+
end
|
89
|
+
end
|
@@ -53,7 +53,7 @@ end
|
|
53
53
|
|
54
54
|
def set_default_settings
|
55
55
|
Setting['discovery_fact'] = 'discovery_bootif'
|
56
|
-
Setting['discovery_hostname'] = 'discovery_bootif'
|
56
|
+
Setting['discovery_hostname'] = ['discovery_bootif']
|
57
57
|
Setting['discovery_auto'] = true
|
58
58
|
Setting['discovery_reboot'] = true
|
59
59
|
Setting['discovery_organization'] = "Organization 1"
|
@@ -6,7 +6,7 @@ class DiscoveryAttributeSetTest < ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
setup do
|
8
8
|
@facts = parse_json_fixture('regular_host', true)
|
9
|
-
Setting['discovery_hostname'] = 'discovery_bootif'
|
9
|
+
Setting['discovery_hostname'] = ['discovery_bootif']
|
10
10
|
Setting['discovery_prefix'] = 'mac'
|
11
11
|
::ForemanDiscovery::HostConverter.stubs(:unused_ip_for_host)
|
12
12
|
end
|
@@ -181,7 +181,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
181
181
|
end
|
182
182
|
|
183
183
|
test "should create discovered host with hostname if a fact was supplied" do
|
184
|
-
Setting[:discovery_hostname] = 'somefact'
|
184
|
+
Setting[:discovery_hostname] = ['somefact']
|
185
185
|
facts = @facts.merge({"somefact" => "somename"})
|
186
186
|
host = discover_host_from_facts(facts)
|
187
187
|
assert_equal 'macsomename', host.name
|
@@ -219,7 +219,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
219
219
|
|
220
220
|
test "should create discovered host with fact_name as a name if it is a valid mac" do
|
221
221
|
Setting[:discovery_fact] = 'somefact'
|
222
|
-
Setting[:discovery_hostname] = 'somefact'
|
222
|
+
Setting[:discovery_hostname] = ['somefact']
|
223
223
|
facts = @facts.merge({"somefact" => "E4:1F:13:CC:36:5A"})
|
224
224
|
host = discover_host_from_facts(facts)
|
225
225
|
assert_equal 'mace41f13cc365a', host.name
|
@@ -277,7 +277,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
277
277
|
end
|
278
278
|
|
279
279
|
test "should raise when hostname fact cannot be found" do
|
280
|
-
Setting[:discovery_hostname] = 'macaddress_foo'
|
280
|
+
Setting[:discovery_hostname] = ['macaddress_foo']
|
281
281
|
exception = assert_raises(::Foreman::Exception) do
|
282
282
|
discover_host_from_facts(@facts)
|
283
283
|
end
|
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: 22.0.
|
4
|
+
version: 22.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditi Puntambekar
|
@@ -76,7 +76,7 @@ authors:
|
|
76
76
|
autorequire:
|
77
77
|
bindir: bin
|
78
78
|
cert_chain: []
|
79
|
-
date:
|
79
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
80
80
|
dependencies: []
|
81
81
|
description: MaaS Discovery Plugin engine for Foreman
|
82
82
|
email: gsutclif@redhat.com
|
@@ -109,7 +109,6 @@ files:
|
|
109
109
|
- app/models/host/managed_extensions.rb
|
110
110
|
- app/models/hostgroup_extensions.rb
|
111
111
|
- app/models/nic/managed_extensions.rb
|
112
|
-
- app/models/setting/discovered.rb
|
113
112
|
- app/services/discovery_fact_importer.rb
|
114
113
|
- app/services/foreman_discovery/fact_parser.rb
|
115
114
|
- app/services/foreman_discovery/fact_to_category_resolver.rb
|
@@ -190,6 +189,7 @@ files:
|
|
190
189
|
- db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
|
191
190
|
- db/migrate/20180412124505_add_priority_score_to_discovery_rules.rb
|
192
191
|
- db/migrate/20221102065954_fix_discovery_settings_category_to_dsl.rb
|
192
|
+
- db/migrate/20221102075151_migrate_discovery_hostname_and_fact_column_to_array.rb
|
193
193
|
- db/seeds.d/60_discovery_proxy_feature.rb
|
194
194
|
- db/seeds.d/70_discovery_mail_notification.rb
|
195
195
|
- db/seeds.d/80_discovery_ui_notification.rb
|
@@ -219,6 +219,8 @@ files:
|
|
219
219
|
- locale/it/foreman_discovery.po
|
220
220
|
- locale/ja/LC_MESSAGES/foreman_discovery.mo
|
221
221
|
- locale/ja/foreman_discovery.po
|
222
|
+
- locale/ka/LC_MESSAGES/foreman_discovery.mo
|
223
|
+
- locale/ka/foreman_discovery.po
|
222
224
|
- locale/ko/LC_MESSAGES/foreman_discovery.mo
|
223
225
|
- locale/ko/foreman_discovery.po
|
224
226
|
- locale/pt_BR/LC_MESSAGES/foreman_discovery.mo
|
@@ -257,6 +259,7 @@ files:
|
|
257
259
|
- test/functional/discovery_rules_controller_test.rb
|
258
260
|
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
259
261
|
- test/integration/discovered_hosts_test.rb
|
262
|
+
- test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb
|
260
263
|
- test/static_fixtures/redhat_kexec.erb
|
261
264
|
- test/test_helper_discovery.rb
|
262
265
|
- test/test_plugin_helper.rb
|
@@ -315,6 +318,18 @@ signing_key:
|
|
315
318
|
specification_version: 4
|
316
319
|
summary: MaaS Discovery Plugin for Foreman
|
317
320
|
test_files:
|
321
|
+
- test/unit/discovered_extensions_test.rb
|
322
|
+
- test/unit/discovered_mailer_test.rb
|
323
|
+
- test/unit/discovery_rule_test.rb
|
324
|
+
- test/unit/discovery_taxonomy_extensions_test.rb
|
325
|
+
- test/unit/fact_parser_test.rb
|
326
|
+
- test/unit/fact_to_category_resolver_test.rb
|
327
|
+
- test/unit/lldp_neighbors_test.rb
|
328
|
+
- test/unit/ui_notifications/destroy_host_test.rb
|
329
|
+
- test/unit/ui_notifications/new_host_test.rb
|
330
|
+
- test/unit/discovery_attribute_set_test.rb
|
331
|
+
- test/unit/host_discovered_test.rb
|
332
|
+
- test/unit/managed_extensions_test.rb
|
318
333
|
- test/factories/discovery_host_related.rb
|
319
334
|
- test/factories/discovery_rule_related.rb
|
320
335
|
- test/facts/bond0-eth0-eth1-active-passive.json
|
@@ -336,22 +351,11 @@ test_files:
|
|
336
351
|
- test/functional/api/v2/discovered_hosts_controller_test.rb
|
337
352
|
- test/functional/api/v2/discovery_rules_controller_test.rb
|
338
353
|
- test/functional/api/v2/fact_value_extensions_test.rb
|
339
|
-
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
340
354
|
- test/functional/discovery_rules_controller_test.rb
|
355
|
+
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
341
356
|
- test/functional/discovered_hosts_controller_test.rb
|
342
357
|
- test/integration/discovered_hosts_test.rb
|
343
|
-
- test/unit/ui_notifications/destroy_host_test.rb
|
344
|
-
- test/unit/ui_notifications/new_host_test.rb
|
345
|
-
- test/unit/discovered_mailer_test.rb
|
346
|
-
- test/unit/discovery_attribute_set_test.rb
|
347
|
-
- test/unit/discovery_rule_test.rb
|
348
|
-
- test/unit/discovery_taxonomy_extensions_test.rb
|
349
|
-
- test/unit/fact_parser_test.rb
|
350
|
-
- test/unit/fact_to_category_resolver_test.rb
|
351
|
-
- test/unit/lldp_neighbors_test.rb
|
352
|
-
- test/unit/discovered_extensions_test.rb
|
353
|
-
- test/unit/host_discovered_test.rb
|
354
|
-
- test/unit/managed_extensions_test.rb
|
355
|
-
- test/test_helper_discovery.rb
|
356
358
|
- test/test_plugin_helper.rb
|
359
|
+
- test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb
|
357
360
|
- test/static_fixtures/redhat_kexec.erb
|
361
|
+
- test/test_helper_discovery.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class Setting::Discovered
|
2
|
-
def self.discovery_fact_column_array
|
3
|
-
from_array(Setting['discovery_fact_column'])
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.discovery_hostname_fact_array
|
7
|
-
return [] if !Setting['discovery_hostname'].present?
|
8
|
-
from_array Setting['discovery_hostname']
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.discovery_lock?
|
12
|
-
Foreman::Cast.to_bool(Setting['discovery_lock'])
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.from_array(setting)
|
16
|
-
return [] unless setting.present?
|
17
|
-
setting.to_s.split(",").map(&:strip)
|
18
|
-
rescue Exception => e
|
19
|
-
logger.warn "Failed to parse discovery_fact_column, ignoring: #{e}"
|
20
|
-
[]
|
21
|
-
end
|
22
|
-
end
|