foreman_discovery 17.0.1 → 18.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/discovered_hosts_controller.rb +10 -3
  3. data/app/models/discovery_fact_name.rb +9 -0
  4. data/app/models/host/discovered.rb +26 -9
  5. data/app/models/host/managed_extensions.rb +2 -2
  6. data/app/models/setting/discovered.rb +1 -0
  7. data/app/services/discovery_fact_importer.rb +5 -0
  8. data/app/services/foreman_discovery/host_converter.rb +3 -3
  9. data/app/views/discovered_hosts/welcome.html.erb +0 -1
  10. data/app/views/discovery_rules/welcome.html.erb +0 -1
  11. data/lib/foreman_discovery/engine.rb +3 -1
  12. data/lib/foreman_discovery/version.rb +1 -1
  13. data/locale/ca/LC_MESSAGES/foreman_discovery.mo +0 -0
  14. data/locale/ca/foreman_discovery.edit.po +44 -40
  15. data/locale/ca/foreman_discovery.po +13 -7
  16. data/locale/de/LC_MESSAGES/foreman_discovery.mo +0 -0
  17. data/locale/de/foreman_discovery.edit.po +42 -38
  18. data/locale/de/foreman_discovery.po +11 -5
  19. data/locale/en/LC_MESSAGES/foreman_discovery.mo +0 -0
  20. data/locale/en/foreman_discovery.edit.po +37 -29
  21. data/locale/en/foreman_discovery.po +7 -1
  22. data/locale/en_GB/LC_MESSAGES/foreman_discovery.mo +0 -0
  23. data/locale/en_GB/foreman_discovery.edit.po +39 -35
  24. data/locale/en_GB/foreman_discovery.po +8 -2
  25. data/locale/es/LC_MESSAGES/foreman_discovery.mo +0 -0
  26. data/locale/es/foreman_discovery.edit.po +42 -38
  27. data/locale/es/foreman_discovery.po +11 -5
  28. data/locale/foreman_discovery.pot +38 -30
  29. data/locale/fr/LC_MESSAGES/foreman_discovery.mo +0 -0
  30. data/locale/fr/foreman_discovery.edit.po +88 -84
  31. data/locale/fr/foreman_discovery.po +57 -51
  32. data/locale/gl/LC_MESSAGES/foreman_discovery.mo +0 -0
  33. data/locale/gl/foreman_discovery.edit.po +42 -38
  34. data/locale/gl/foreman_discovery.po +11 -5
  35. data/locale/it/LC_MESSAGES/foreman_discovery.mo +0 -0
  36. data/locale/it/foreman_discovery.edit.po +42 -38
  37. data/locale/it/foreman_discovery.po +11 -5
  38. data/locale/ja/LC_MESSAGES/foreman_discovery.mo +0 -0
  39. data/locale/ja/foreman_discovery.edit.po +74 -70
  40. data/locale/ja/foreman_discovery.po +43 -37
  41. data/locale/ko/LC_MESSAGES/foreman_discovery.mo +0 -0
  42. data/locale/ko/foreman_discovery.edit.po +42 -38
  43. data/locale/ko/foreman_discovery.po +11 -5
  44. data/locale/pt_BR/LC_MESSAGES/foreman_discovery.mo +0 -0
  45. data/locale/pt_BR/foreman_discovery.edit.po +42 -38
  46. data/locale/pt_BR/foreman_discovery.po +11 -5
  47. data/locale/ru/LC_MESSAGES/foreman_discovery.mo +0 -0
  48. data/locale/ru/foreman_discovery.edit.po +46 -42
  49. data/locale/ru/foreman_discovery.po +15 -9
  50. data/locale/sv_SE/LC_MESSAGES/foreman_discovery.mo +0 -0
  51. data/locale/sv_SE/foreman_discovery.edit.po +42 -38
  52. data/locale/sv_SE/foreman_discovery.po +11 -5
  53. data/locale/zh_CN/LC_MESSAGES/foreman_discovery.mo +0 -0
  54. data/locale/zh_CN/foreman_discovery.edit.po +90 -86
  55. data/locale/zh_CN/foreman_discovery.po +59 -53
  56. data/locale/zh_TW/LC_MESSAGES/foreman_discovery.mo +0 -0
  57. data/locale/zh_TW/foreman_discovery.edit.po +42 -38
  58. data/locale/zh_TW/foreman_discovery.po +11 -5
  59. data/package.json +1 -1
  60. data/test/functional/api/v2/fact_value_extensions_test.rb +1 -4
  61. data/test/functional/discovered_hosts_controller_test.rb +6 -5
  62. data/test/integration/discovered_hosts_test.rb +10 -4
  63. data/test/test_helper_discovery.rb +35 -27
  64. data/test/test_plugin_helper.rb +7 -0
  65. data/test/unit/discovered_extensions_test.rb +36 -16
  66. data/test/unit/discovery_attribute_set_test.rb +2 -8
  67. data/test/unit/fact_parser_test.rb +1 -4
  68. data/test/unit/managed_extensions_test.rb +1 -0
  69. metadata +12 -15
  70. data/test/functional/api/v2/settings_controller_test.rb +0 -22
  71. data/test/models/setting_test.rb +0 -11
  72. data/test/unit/setting_discovered_test.rb +0 -9
@@ -28,10 +28,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
28
28
  end
29
29
 
30
30
  def test_index_with_custom_column
31
- FactoryBot.create(:setting,
32
- :name => 'discovery_fact_column',
33
- :value => "bios_vendor",
34
- :category => 'Setting::Discovered')
31
+ Setting['discovery_fact_column'] = "bios_vendor"
35
32
  facts = @facts.merge({"bios_vendor" => "QEMU"})
36
33
  discover_host_from_facts(facts)
37
34
  get :index, params: {}, session: set_session_user_default_reader
@@ -85,7 +82,11 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
85
82
 
86
83
  def test_edit_form_quick_submit
87
84
  domain = FactoryBot.create(:domain)
88
- hostgroup = FactoryBot.create(:hostgroup, :with_subnet, :with_environment, :with_rootpass, :with_os, :domain => domain)
85
+ if defined? ForemanPuppet
86
+ hostgroup = FactoryBot.create(:hostgroup, :with_subnet, :with_puppet_enc, :with_rootpass, :with_os, :domain => domain)
87
+ else
88
+ hostgroup = FactoryBot.create(:hostgroup, :with_subnet, :with_rootpass, :with_os, :domain => domain)
89
+ end
89
90
  new_ip = hostgroup.subnet.ipaddr.to_s
90
91
  host = discover_host_from_facts(@facts.merge({
91
92
  'ipaddress' => new_ip,
@@ -161,9 +161,11 @@ class DiscoveredHostsTest < IntegrationTestWithJavascript
161
161
  let(:hostgroup_environment) { FactoryBot.create(:environment) }
162
162
  let(:hostgroup_domain) { FactoryBot.create(:domain) }
163
163
  let(:hostgroup) do
164
- FactoryBot.create(:hostgroup, :with_os,
165
- environment: hostgroup_environment,
166
- domain: hostgroup_domain)
164
+ if defined?(ForemanPuppet)
165
+ FactoryBot.create(:hostgroup, :with_os, environment: hostgroup_environment, domain: hostgroup_domain)
166
+ else
167
+ FactoryBot.create(:hostgroup, :with_os, domain: hostgroup_domain)
168
+ end
167
169
  end
168
170
 
169
171
  setup do
@@ -174,10 +176,14 @@ class DiscoveredHostsTest < IntegrationTestWithJavascript
174
176
  end
175
177
 
176
178
  it 'sets inherited attributes' do
177
- %i[environment architecture operatingsystem].each do |attribute|
179
+ %i[architecture operatingsystem].each do |attribute|
178
180
  assert_selected "#host_#{attribute}_id", hostgroup.send(attribute).id
179
181
  end
180
182
 
183
+ if defined? ForemanPuppet
184
+ assert_selected "#host_puppet_attributes_environment_id", hostgroup.send(:environment).id
185
+ end
186
+
181
187
  page.find('a[href="#network"]').click
182
188
  page.find_button('Edit').click
183
189
  assert_selected '#host_interfaces_attributes_0_domain_id',
@@ -52,40 +52,46 @@ def extract_form_errors(response)
52
52
  end
53
53
 
54
54
  def set_default_settings
55
- FactoryBot.create(:setting, :name => 'discovery_fact', :value => 'discovery_bootif', :category => 'Setting::Discovered')
56
- FactoryBot.create(:setting, :name => 'discovery_hostname', :value => 'discovery_bootif', :category => 'Setting::Discovered')
57
- FactoryBot.create(:setting, :name => 'discovery_auto', :value => true, :category => 'Setting::Discovered')
58
- FactoryBot.create(:setting, :name => 'discovery_reboot', :value => true, :category => 'Setting::Discovered')
59
- FactoryBot.create(:setting, :name => 'discovery_organization', :value => "Organization 1", :category => 'Setting::Discovered')
60
- FactoryBot.create(:setting, :name => 'discovery_location', :value => "Location 1", :category => 'Setting::Discovered')
61
- FactoryBot.create(:setting, :name => 'discovery_prefix', :value => 'mac', :category => 'Setting::Discovered')
62
- FactoryBot.create(:setting, :name => 'discovery_clean_facts', :value => false, :category => 'Setting::Discovered')
63
- FactoryBot.create(:setting, :name => 'discovery_lock', :value => false, :category => 'Setting::Discovered')
64
- FactoryBot.create(:setting, :name => 'discovery_pxelinux_lock_template', :value => 'pxelinux_discovery', :category => 'Setting::Discovered')
65
- FactoryBot.create(:setting, :name => 'discovery_pxegrub_lock_template', :value => 'pxegrub_discovery', :category => 'Setting::Discovered')
66
- FactoryBot.create(:setting, :name => 'discovery_pxegrub2_lock_template', :value => 'pxegrub2_discovery', :category => 'Setting::Discovered')
67
- FactoryBot.create(:setting, :name => 'discovery_always_rebuild_dns', :value => true, :category => 'Setting::Discovered')
68
- FactoryBot.create(:setting, :name => 'discovery_error_on_existing', :value => false, :category => 'Setting::Discovered')
69
- FactoryBot.create(:setting, :name => 'discovery_naming', :value => 'Fact', :category => 'Setting::Discovered')
70
- FactoryBot.create(:setting, :name => 'discovery_auto_bond', :value => false, :category => 'Setting::Discovered')
55
+ Setting['discovery_fact'] = 'discovery_bootif'
56
+ Setting['discovery_hostname'] = 'discovery_bootif'
57
+ Setting['discovery_auto'] = true
58
+ Setting['discovery_reboot'] = true
59
+ Setting['discovery_organization'] = "Organization 1"
60
+ Setting['discovery_location'] = "Location 1"
61
+ Setting['discovery_prefix'] = 'mac'
62
+ Setting['discovery_clean_facts'] = false
63
+ Setting['discovery_lock'] = false
64
+ Setting['discovery_pxelinux_lock_template'] = 'pxelinux_discovery'
65
+ Setting['discovery_pxegrub_lock_template'] = 'pxegrub_discovery'
66
+ Setting['discovery_pxegrub2_lock_template'] = 'pxegrub2_discovery'
67
+ Setting['discovery_always_rebuild_dns'] = true
68
+ Setting['discovery_error_on_existing'] = false
69
+ Setting['discovery_naming'] = 'Fact'
70
+ Setting['discovery_auto_bond'] = false
71
71
  end
72
72
 
73
73
  def setup_hostgroup(host)
74
74
  domain = FactoryBot.create(:domain)
75
75
  subnet = FactoryBot.create(:subnet_ipv4, :network => "192.168.100.0")
76
- environment = FactoryBot.create(:environment, :organizations => [host.organization], :locations => [host.location])
77
76
  medium = FactoryBot.create(:medium, :organizations => [host.organization], :locations => [host.location])
78
77
  os = FactoryBot.create(:operatingsystem, :with_ptables, :with_archs, :media => [medium])
79
- hostgroup = FactoryBot.create(
80
- :hostgroup, :with_rootpass, :with_puppet_orchestration,
78
+ args = {
81
79
  :operatingsystem => os,
82
80
  :architecture => os.architectures.first,
83
81
  :ptable => os.ptables.first,
84
82
  :medium => os.media.first,
85
- :environment => environment,
86
83
  :subnet => subnet,
87
84
  :domain => domain,
88
- :organizations => [host.organization], :locations => [host.location])
85
+ :organizations => [host.organization],
86
+ :locations => [host.location]
87
+ }
88
+ if defined?(ForemanPuppet)
89
+ environment = FactoryBot.create(:environment, :organizations => [host.organization], :locations => [host.location])
90
+ args[:environment] = environment
91
+ hostgroup = FactoryBot.create(:hostgroup, :with_rootpass, :with_puppet_enc, **args)
92
+ else
93
+ hostgroup = FactoryBot.create(:hostgroup, :with_rootpass, **args)
94
+ end
89
95
  domain.subnets << hostgroup.subnet
90
96
  hostgroup.medium.organizations |= [host.organization]
91
97
  hostgroup.medium.locations |= [host.location]
@@ -95,12 +101,14 @@ def setup_hostgroup(host)
95
101
  hostgroup.domain.locations |= [host.location]
96
102
  hostgroup.subnet.organizations |= [host.organization]
97
103
  hostgroup.subnet.locations |= [host.location]
98
- hostgroup.environment.organizations |= [host.organization]
99
- hostgroup.environment.locations |= [host.location]
100
- hostgroup.puppet_proxy.organizations |= [host.organization]
101
- hostgroup.puppet_proxy.locations |= [host.location]
102
- hostgroup.puppet_ca_proxy.organizations |= [host.organization]
103
- hostgroup.puppet_ca_proxy.locations |= [host.location]
104
+ if defined?(ForemanPuppet)
105
+ hostgroup.environment.organizations |= [host.organization]
106
+ hostgroup.environment.locations |= [host.location]
107
+ hostgroup.puppet_proxy.organizations |= [host.organization]
108
+ hostgroup.puppet_proxy.locations |= [host.location]
109
+ hostgroup.puppet_ca_proxy.organizations |= [host.organization]
110
+ hostgroup.puppet_ca_proxy.locations |= [host.location]
111
+ end
104
112
  hostgroup
105
113
  end
106
114
 
@@ -4,4 +4,11 @@ require_relative './test_helper_discovery'
4
4
 
5
5
  # Add plugin to FactoryBot's paths
6
6
  FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
7
+
8
+ # Add dependencies
9
+ if defined? ForemanPuppet
10
+ FactoryBot.definition_file_paths << File.join("#{ForemanPuppet::Engine.root}/test", 'factories')
11
+ end
12
+
13
+ # And reload
7
14
  FactoryBot.reload
@@ -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
 
@@ -19,6 +19,7 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
19
19
  @host = StubHost.new
20
20
  @host.type = "Host::Discovered"
21
21
  @host.stubs(:ip).returns("192.168.1.1")
22
+ @host.stubs(:ip6).returns(nil)
22
23
  @host.stubs(:old).returns(@host)
23
24
  @facts = {}
24
25
  @host.stubs(:facts).returns(@facts)
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.1
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-06-16 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
@@ -349,26 +349,23 @@ test_files:
349
349
  - test/facts/only-ipv6.json
350
350
  - test/facts/skylake-ipv6.json
351
351
  - test/functional/api/v2/discovery_rules_controller_test.rb
352
- - test/functional/api/v2/fact_value_extensions_test.rb
353
- - test/functional/api/v2/settings_controller_test.rb
354
352
  - test/functional/api/v2/discovered_hosts_controller_test.rb
353
+ - test/functional/api/v2/fact_value_extensions_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
- - test/models/setting_test.rb
360
358
  - test/unit/ui_notifications/destroy_host_test.rb
361
359
  - test/unit/ui_notifications/new_host_test.rb
362
360
  - test/unit/discovered_mailer_test.rb
363
361
  - test/unit/discovery_taxonomy_extensions_test.rb
364
- - test/unit/fact_parser_test.rb
365
362
  - test/unit/lldp_neighbors_test.rb
366
- - test/unit/setting_discovered_test.rb
367
- - test/unit/discovered_extensions_test.rb
368
- - test/unit/discovery_attribute_set_test.rb
369
363
  - test/unit/host_discovered_test.rb
370
- - test/unit/managed_extensions_test.rb
371
364
  - test/unit/discovery_rule_test.rb
372
365
  - test/unit/fact_to_category_resolver_test.rb
373
- - test/test_plugin_helper.rb
366
+ - test/unit/managed_extensions_test.rb
367
+ - test/unit/discovery_attribute_set_test.rb
368
+ - test/unit/fact_parser_test.rb
369
+ - test/unit/discovered_extensions_test.rb
374
370
  - test/test_helper_discovery.rb
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