foreman_discovery 17.0.4 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/discovered_hosts_controller.rb +10 -3
  3. data/app/controllers/discovery_rules_controller.rb +1 -1
  4. data/app/helpers/discovered_hosts_helper.rb +3 -2
  5. data/app/models/discovery_fact_name.rb +9 -0
  6. data/app/services/discovery_fact_importer.rb +5 -0
  7. data/app/services/foreman_discovery/host_converter.rb +3 -3
  8. data/app/views/discovered_hosts/welcome.html.erb +1 -2
  9. data/app/views/discovery_rules/welcome.html.erb +1 -2
  10. data/lib/foreman_discovery/engine.rb +3 -1
  11. data/lib/foreman_discovery/version.rb +1 -1
  12. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  13. data/locale/ca/foreman_discovery.po +13 -7
  14. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  15. data/locale/de/foreman_discovery.po +11 -5
  16. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  17. data/locale/en/foreman_discovery.po +7 -1
  18. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  19. data/locale/en_GB/foreman_discovery.po +8 -2
  20. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  21. data/locale/es/foreman_discovery.po +11 -5
  22. data/locale/foreman_discovery.pot +38 -30
  23. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  24. data/locale/fr/foreman_discovery.po +57 -51
  25. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  26. data/locale/gl/foreman_discovery.po +11 -5
  27. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  28. data/locale/it/foreman_discovery.po +11 -5
  29. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  30. data/locale/ja/foreman_discovery.po +43 -37
  31. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  32. data/locale/ko/foreman_discovery.po +11 -5
  33. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  34. data/locale/pt_BR/foreman_discovery.po +11 -5
  35. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  36. data/locale/ru/foreman_discovery.po +15 -9
  37. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  38. data/locale/sv_SE/foreman_discovery.po +11 -5
  39. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  40. data/locale/zh_CN/foreman_discovery.po +59 -53
  41. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  42. data/locale/zh_TW/foreman_discovery.po +11 -5
  43. data/package.json +1 -1
  44. data/test/functional/api/v2/fact_value_extensions_test.rb +1 -4
  45. data/test/functional/discovered_hosts_controller_test.rb +6 -5
  46. data/test/integration/discovered_hosts_test.rb +10 -4
  47. data/test/test_helper_discovery.rb +35 -27
  48. data/test/test_plugin_helper.rb +7 -0
  49. data/test/unit/discovered_extensions_test.rb +36 -16
  50. data/test/unit/discovery_attribute_set_test.rb +2 -8
  51. data/test/unit/fact_parser_test.rb +1 -4
  52. metadata +9 -12
  53. data/test/functional/api/v2/settings_controller_test.rb +0 -22
  54. data/test/models/setting_test.rb +0 -11
  55. data/test/unit/setting_discovered_test.rb +0 -9
@@ -156,7 +156,17 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
156
156
  subnet = FactoryBot.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")])
157
157
  host = discover_host_from_facts(facts)
158
158
  assert_equal subnet, host.subnet
159
- hostgroup = FactoryBot.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :pxe_loader => "PXELinux BIOS", :subnet => subnet, :domain => domain)
159
+ if defined? ForemanPuppet
160
+ hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_rootpass, :with_os,
161
+ pxe_loader: "PXELinux BIOS",
162
+ subnet: subnet,
163
+ domain: domain)
164
+ else
165
+ hostgroup = FactoryBot.create(:hostgroup, :with_rootpass, :with_os,
166
+ pxe_loader: "PXELinux BIOS",
167
+ subnet: subnet,
168
+ domain: domain)
169
+ end
160
170
  r1 = FactoryBot.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
161
171
  host.primary_interface.expects(:queue_tftp).at_least(1)
162
172
  host.primary_interface.expects(:queue_dhcp).at_least(1)
@@ -174,12 +184,12 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
174
184
  assert_equal hostgroup.subnet, managed_host.provision_interface.subnet
175
185
  refute_nil hostgroup.domain, managed_host.domain
176
186
  assert_equal hostgroup.domain, managed_host.domain
177
- refute_nil hostgroup.environment, managed_host.environment
178
- assert_equal hostgroup.environment, managed_host.environment
179
- refute_nil hostgroup.puppet_proxy, managed_host.puppet_proxy
180
- assert_equal hostgroup.puppet_proxy, managed_host.puppet_proxy
181
- refute_nil hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
182
- assert_equal hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
187
+ if defined? ForemanPuppet
188
+ refute_nil hostgroup.environment, managed_host.environment
189
+ assert_equal hostgroup.environment, managed_host.environment
190
+ refute_nil hostgroup.puppet_proxy, managed_host.puppet_proxy
191
+ assert_equal hostgroup.puppet_proxy, managed_host.puppet_proxy
192
+ end
183
193
  end
184
194
 
185
195
  class StubIPAM
@@ -196,7 +206,7 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
196
206
  subnet2 = FactoryBot.create(:subnet_ipv4, :tftp, :dhcp, :name => 'subnet_101', :network => '192.168.101.0', :organizations => [Organization.find_by_name("Organization 1")], :locations => [Location.find_by_name("Location 1")])
197
207
  host = discover_host_from_facts(facts)
198
208
  assert_equal subnet, host.subnet
199
- hostgroup = FactoryBot.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :pxe_loader => "PXELinux BIOS", :subnet => subnet2, :domain => domain)
209
+ hostgroup = FactoryBot.create(:hostgroup, :with_rootpass, :with_os, :pxe_loader => "PXELinux BIOS", :subnet => subnet2, :domain => domain)
200
210
  r1 = FactoryBot.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
201
211
  Subnet.any_instance.expects(:unused_ip).with(host.mac).returns(StubIPAM.new)
202
212
  host.primary_interface.stubs(:queue_tftp)
@@ -219,7 +229,7 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
219
229
  subnet2 = FactoryBot.create(:subnet_ipv6, :tftp, :dhcp, :network => "2001:db9::/32", :mask => "ffff:ffff::", :name => "ipv6_provision", :ipam => IPAM::MODES[:eui64], :organizations => [Organization.find_by_name("Organization 1")], :locations => [Location.find_by_name("Location 1")])
220
230
  host = discover_host_from_facts(facts)
221
231
  assert_equal subnet, host.subnet6
222
- hostgroup = FactoryBot.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :pxe_loader => "PXELinux BIOS", :subnet6 => subnet2, :domain => domain)
232
+ hostgroup = FactoryBot.create(:hostgroup, :with_rootpass, :with_os, :pxe_loader => "PXELinux BIOS", :subnet6 => subnet2, :domain => domain)
223
233
  r1 = FactoryBot.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
224
234
  host.primary_interface.stubs(:queue_tftp)
225
235
  host.primary_interface.stubs(:queue_dhcp)
@@ -239,7 +249,17 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
239
249
  refute host.subnet
240
250
  domain = FactoryBot.create(:domain)
241
251
  subnet = FactoryBot.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")])
242
- hostgroup = FactoryBot.create(:hostgroup, :with_environment, :with_rootpass, :with_puppet_orchestration, :with_os, :pxe_loader => "PXELinux BIOS", :subnet => subnet, :domain => domain)
252
+ if defined? ForemanPuppet
253
+ hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_rootpass, :with_os,
254
+ pxe_loader: "PXELinux BIOS",
255
+ subnet: subnet,
256
+ domain: domain)
257
+ else
258
+ hostgroup = FactoryBot.create(:hostgroup, :with_rootpass, :with_os,
259
+ pxe_loader: "PXELinux BIOS",
260
+ subnet: subnet,
261
+ domain: domain)
262
+ end
243
263
  r1 = FactoryBot.create(:discovery_rule, :priority => 1, :search => "facts.somefact = abc", :organizations => [host.organization], :locations => [host.location], :hostgroup => hostgroup)
244
264
  host.primary_interface.expects(:queue_tftp).at_least(1)
245
265
  host.primary_interface.expects(:queue_dhcp).at_least(1)
@@ -257,12 +277,12 @@ class DiscoveredExtensionsTest < ActiveSupport::TestCase
257
277
  assert_equal hostgroup.subnet, managed_host.provision_interface.subnet
258
278
  refute_nil hostgroup.domain, managed_host.domain
259
279
  assert_equal hostgroup.domain, managed_host.domain
260
- refute_nil hostgroup.environment, managed_host.environment
261
- assert_equal hostgroup.environment, managed_host.environment
262
- refute_nil hostgroup.puppet_proxy, managed_host.puppet_proxy
263
- assert_equal hostgroup.puppet_proxy, managed_host.puppet_proxy
264
- refute_nil hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
265
- assert_equal hostgroup.puppet_ca_proxy, managed_host.puppet_ca_proxy
280
+ if defined? ForemanPuppet
281
+ refute_nil hostgroup.environment, managed_host.environment
282
+ assert_equal hostgroup.environment, managed_host.environment
283
+ refute_nil hostgroup.puppet_proxy, managed_host.puppet_proxy
284
+ assert_equal hostgroup.puppet_proxy, managed_host.puppet_proxy
285
+ end
266
286
  end
267
287
 
268
288
  def setup_normal_renderer
@@ -6,14 +6,8 @@ class DiscoveryAttributeSetTest < ActiveSupport::TestCase
6
6
 
7
7
  setup do
8
8
  @facts = parse_json_fixture('regular_host', true)
9
- FactoryBot.create(:setting,
10
- :name => 'discovery_hostname',
11
- :value => 'discovery_bootif',
12
- :category => 'Setting::Discovered')
13
- FactoryBot.create(:setting,
14
- :name => 'discovery_prefix',
15
- :value => 'mac',
16
- :category => 'Setting::Discovered')
9
+ Setting['discovery_hostname'] = 'discovery_bootif'
10
+ Setting['discovery_prefix'] = 'mac'
17
11
  ::ForemanDiscovery::HostConverter.stubs(:unused_ip_for_host)
18
12
  end
19
13
 
@@ -55,10 +55,7 @@ class FactParserTest < ActiveSupport::TestCase
55
55
  end
56
56
 
57
57
  test "#suggested_primary_interface detects interface even when 'ignore_puppet_facts_for_provisioning' is set" do
58
- FactoryBot.create(:setting,
59
- :name => 'ignore_puppet_facts_for_provisioning',
60
- :value => true,
61
- :category => 'Setting::Provisioning')
58
+ Setting['ignore_puppet_facts_for_provisioning'] = true
62
59
  assert_equal 'eth2', @parser.suggested_primary_interface(@host).try(:first)
63
60
  end
64
61
 
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: 17.0.4
4
+ version: 18.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditi Puntambekar
@@ -41,6 +41,7 @@ authors:
41
41
  - Lukáš Zapletal
42
42
  - Marek Hulan
43
43
  - Marek Hulán
44
+ - MariaAga
44
45
  - Martin Bačovský
45
46
  - Matt Jarvis
46
47
  - Michael Moll
@@ -73,7 +74,7 @@ authors:
73
74
  autorequire:
74
75
  bindir: bin
75
76
  cert_chain: []
76
- date: 2021-10-05 00:00:00.000000000 Z
77
+ date: 2021-09-20 00:00:00.000000000 Z
77
78
  dependencies: []
78
79
  description: MaaS Discovery Plugin engine for Foreman
79
80
  email: gsutclif@redhat.com
@@ -100,12 +101,14 @@ files:
100
101
  - app/mailers/discovered_mailer.rb
101
102
  - app/models/concerns/discovery_taxonomy_extensions.rb
102
103
  - app/models/discovery_attribute_set.rb
104
+ - app/models/discovery_fact_name.rb
103
105
  - app/models/discovery_rule.rb
104
106
  - app/models/host/discovered.rb
105
107
  - app/models/host/managed_extensions.rb
106
108
  - app/models/hostgroup_extensions.rb
107
109
  - app/models/nic/managed_extensions.rb
108
110
  - app/models/setting/discovered.rb
111
+ - app/services/discovery_fact_importer.rb
109
112
  - app/services/foreman_discovery/fact_parser.rb
110
113
  - app/services/foreman_discovery/fact_to_category_resolver.rb
111
114
  - app/services/foreman_discovery/host_converter.rb
@@ -266,12 +269,10 @@ files:
266
269
  - test/functional/api/v2/discovered_hosts_controller_test.rb
267
270
  - test/functional/api/v2/discovery_rules_controller_test.rb
268
271
  - test/functional/api/v2/fact_value_extensions_test.rb
269
- - test/functional/api/v2/settings_controller_test.rb
270
272
  - test/functional/discovered_hosts_controller_test.rb
271
273
  - test/functional/discovery_rules_controller_test.rb
272
274
  - test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
273
275
  - test/integration/discovered_hosts_test.rb
274
- - test/models/setting_test.rb
275
276
  - test/test_helper_discovery.rb
276
277
  - test/test_plugin_helper.rb
277
278
  - test/unit/discovered_extensions_test.rb
@@ -284,7 +285,6 @@ files:
284
285
  - test/unit/host_discovered_test.rb
285
286
  - test/unit/lldp_neighbors_test.rb
286
287
  - test/unit/managed_extensions_test.rb
287
- - test/unit/setting_discovered_test.rb
288
288
  - test/unit/ui_notifications/destroy_host_test.rb
289
289
  - test/unit/ui_notifications/new_host_test.rb
290
290
  - webpack/__mocks__/foremanReact/common/I18n.js
@@ -351,24 +351,21 @@ test_files:
351
351
  - test/functional/api/v2/discovery_rules_controller_test.rb
352
352
  - test/functional/api/v2/discovered_hosts_controller_test.rb
353
353
  - test/functional/api/v2/fact_value_extensions_test.rb
354
- - test/functional/api/v2/settings_controller_test.rb
355
354
  - test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
356
- - test/functional/discovered_hosts_controller_test.rb
357
355
  - test/functional/discovery_rules_controller_test.rb
356
+ - test/functional/discovered_hosts_controller_test.rb
358
357
  - test/integration/discovered_hosts_test.rb
359
358
  - test/unit/ui_notifications/destroy_host_test.rb
360
359
  - test/unit/ui_notifications/new_host_test.rb
361
360
  - test/unit/discovered_mailer_test.rb
362
361
  - test/unit/discovery_taxonomy_extensions_test.rb
363
362
  - test/unit/lldp_neighbors_test.rb
363
+ - test/unit/host_discovered_test.rb
364
364
  - test/unit/discovery_rule_test.rb
365
365
  - test/unit/fact_to_category_resolver_test.rb
366
- - test/unit/discovered_extensions_test.rb
366
+ - test/unit/managed_extensions_test.rb
367
367
  - test/unit/discovery_attribute_set_test.rb
368
368
  - test/unit/fact_parser_test.rb
369
- - test/unit/setting_discovered_test.rb
370
- - test/unit/managed_extensions_test.rb
371
- - test/unit/host_discovered_test.rb
372
- - test/models/setting_test.rb
369
+ - test/unit/discovered_extensions_test.rb
373
370
  - test/test_helper_discovery.rb
374
371
  - test/test_plugin_helper.rb
@@ -1,22 +0,0 @@
1
- require_relative '../../../test_plugin_helper'
2
-
3
- class Api::V2::SettingsControllerTest < ActionController::TestCase
4
- setup do
5
- FactoryBot.create(:setting, :name => 'discovery_prefix', :value => 'mac', :category => 'Setting::Discovered')
6
- end
7
-
8
- test_attributes :pid => '2c5ecb7e-87bc-4980-9620-7ae00e3f360e'
9
- test "should not update hostname prefix without value" do
10
- setting = Setting.find_by_name("discovery_prefix")
11
- put :update, params: { :id => setting.id, :setting => { :value => '' } }
12
- assert_nil JSON.parse(@response.body)['value']
13
- end
14
-
15
- test_attributes :pid => '4969994d-f934-4f0e-9a98-476b87eb0527'
16
- test "should update hostname prefix" do
17
- value = RFauxFactory.gen_alpha
18
- setting = Setting.find_by_name("discovery_prefix")
19
- put :update, params: { :id => setting.id, :setting => { :value => value } }
20
- assert_equal JSON.parse(@response.body)['value'], value, "Can't update discovery_prefix setting with valid value #{value}"
21
- end
22
- end
@@ -1,11 +0,0 @@
1
- require_relative '../test_plugin_helper'
2
-
3
- class SettingTest < ActiveSupport::TestCase
4
- test "should update hostname prefix with multiple valid values" do
5
- setting = FactoryBot.create(:setting, :name => 'discovery_prefix', :value => 'mac', :category => 'Setting::Discovered')
6
- RFauxFactory.gen_strings(exclude: [:numeric, :alphanumeric]).values.each do |value|
7
- setting.value = value
8
- assert setting.valid?, "Can't update discovery_prefix setting with valid value #{value}"
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- require_relative '../test_plugin_helper'
2
-
3
- class SettingDiscoveredTest < ActiveSupport::TestCase
4
- test "can create setting of discovered type" do
5
- assert Setting.create(:name => "foo", :default => "bar", :description => "test foo", :category => "Setting::Discovered")
6
- s = Setting::Discovered.first
7
- assert_equal "foo", s.name
8
- end
9
- end