foreman_discovery 21.0.5 → 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 +7 -15
- 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 +3 -1
- data/test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb +89 -0
- data/{app/views/foreman_discovery → test/static_fixtures}/redhat_kexec.erb +11 -7
- 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 +12 -16
- data/test/unit/managed_extensions_test.rb +2 -1
- data/webpack/src/ForemanDiscovery/DiscoveredHosts/Components/EmptyState/EmptyState.js +1 -1
- metadata +11 -8
- data/app/models/setting/discovered.rb +0 -22
- data/app/views/foreman_discovery/debian_kexec.erb +0 -41
- data/db/seeds.d/50_discovery_templates.rb +0 -31
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
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%#
|
2
2
|
kind: kexec
|
3
3
|
name: Discovery Red Hat kexec
|
4
|
+
model: ProvisioningTemplate
|
4
5
|
oses:
|
5
6
|
- CentOS 4
|
6
7
|
- CentOS 5
|
@@ -20,11 +21,14 @@ description: |
|
|
20
21
|
environments. The template must generate JSON format with the following items
|
21
22
|
"kernel", "initram", "append" and "extra". The kexec command is composed in
|
22
23
|
the following way:
|
23
|
-
|
24
|
+
|
24
25
|
kexec --force --debug --append=$append --initrd=$initram $extra $kernel
|
25
|
-
|
26
|
+
|
26
27
|
Please read kexec(8) man page for more information about semantics.
|
27
28
|
Extra options like --reset-vga can be set via "extra" array.
|
29
|
+
require:
|
30
|
+
- plugin: foreman_discovery
|
31
|
+
 version: 22.0.0
|
28
32
|
-%>
|
29
33
|
<%
|
30
34
|
mac = @host.facts['discovery_bootif']
|
@@ -44,13 +48,13 @@ description: |
|
|
44
48
|
extra << "--kexec-file-syscall" if @host.pxe_loader.include?('SecureBoot')
|
45
49
|
-%>
|
46
50
|
{
|
47
|
-
|
48
|
-
|
51
|
+
"kernel": "<%= @kernel_uri %>",
|
52
|
+
"initram": "<%= @initrd_uri %>",
|
49
53
|
<% if (@host.operatingsystem.name == 'Fedora' and @host.operatingsystem.major.to_i > 16) or
|
50
|
-
|
54
|
+
(@host.operatingsystem.name != 'Fedora' and @host.operatingsystem.major.to_i >= 7) -%>
|
51
55
|
"append": "inst.ks=<%= foreman_url('provision') + "&static=yes" %> inst.ks.sendmac <%= "ip=#{ip}::#{gw}:#{mask}:::none nameserver=#{dns} ksdevice=bootif BOOTIF=#{bootif} nomodeset nokaslr " + options.compact.join(' ') %>",
|
52
56
|
<% else -%>
|
53
57
|
"append": "inst.ks=<%= foreman_url('provision') + "&static=yes" %> kssendmac nicdelay=5 <%= "ip=#{ip} netmask=#{mask} gateway=#{gw} dns=#{dns} ksdevice=#{mac} BOOTIF=#{bootif} nomodeset nokaslr " + options.compact.join(' ') %>",
|
54
58
|
<% end -%>
|
55
|
-
|
56
|
-
}
|
59
|
+
"extra": <%= extra %>
|
60
|
+
}
|
@@ -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
|
@@ -293,22 +293,18 @@ class HostDiscoveredTest < ActiveSupport::TestCase
|
|
293
293
|
host1 = FactoryBot.create(:host, :type => "Host::Discovered", :organization => org1)
|
294
294
|
host2 = FactoryBot.create(:host, :type => "Host::Discovered", :organization => org2)
|
295
295
|
host3 = FactoryBot.create(:host, :type => "Host::Discovered", :organization => org3)
|
296
|
-
hosts = nil
|
297
296
|
|
298
297
|
assert_nil Organization.current
|
299
|
-
as_user(user_subset) do
|
300
|
-
hosts = Host::Discovered.all
|
301
|
-
end
|
302
|
-
assert_includes hosts, host1
|
303
|
-
assert_includes hosts, host2
|
304
|
-
refute_includes hosts, host3
|
305
298
|
|
306
|
-
as_user(
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
299
|
+
hosts = as_user(user_subset) { Host::Discovered.all }.map(&:name)
|
300
|
+
assert_includes hosts, host1.name
|
301
|
+
assert_includes hosts, host2.name
|
302
|
+
refute_includes hosts, host3.name
|
303
|
+
|
304
|
+
hosts = as_user(user_all) { Host::Discovered.all }.map(&:name)
|
305
|
+
assert_includes hosts, host1.name
|
306
|
+
assert_includes hosts, host2.name
|
307
|
+
assert_includes hosts, host3.name
|
312
308
|
end
|
313
309
|
|
314
310
|
test "provisioning a discovered host without saving it doesn't create a token" do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative '../test_plugin_helper'
|
2
|
+
require 'test_helper'
|
2
3
|
|
3
4
|
class ManagedExtensionsTest < ActiveSupport::TestCase
|
4
5
|
class StubHost < ApplicationRecord
|
@@ -10,7 +11,7 @@ class ManagedExtensionsTest < ActiveSupport::TestCase
|
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
|
-
let(:kexec_template) { FactoryBot.build(:provisioning_template, :template => File.read(File.expand_path(File.join("..", "..", "
|
14
|
+
let(:kexec_template) { FactoryBot.build(:provisioning_template, :template => File.read(File.expand_path(File.join("..", "..", "static_fixtures", "redhat_kexec.erb"), __FILE__))) }
|
14
15
|
|
15
16
|
context "stubbed orchestration" do
|
16
17
|
setup 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: 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: 2023-
|
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
|
@@ -166,8 +165,6 @@ files:
|
|
166
165
|
- app/views/discovery_rules/index.html.erb
|
167
166
|
- app/views/discovery_rules/new.html.erb
|
168
167
|
- app/views/discovery_rules/welcome.html.erb
|
169
|
-
- app/views/foreman_discovery/debian_kexec.erb
|
170
|
-
- app/views/foreman_discovery/redhat_kexec.erb
|
171
168
|
- config/as_deprecation_whitelist.yaml
|
172
169
|
- config/initializers/discovery_setup.rb
|
173
170
|
- config/routes.rb
|
@@ -192,7 +189,7 @@ files:
|
|
192
189
|
- db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
|
193
190
|
- db/migrate/20180412124505_add_priority_score_to_discovery_rules.rb
|
194
191
|
- db/migrate/20221102065954_fix_discovery_settings_category_to_dsl.rb
|
195
|
-
- db/
|
192
|
+
- db/migrate/20221102075151_migrate_discovery_hostname_and_fact_column_to_array.rb
|
196
193
|
- db/seeds.d/60_discovery_proxy_feature.rb
|
197
194
|
- db/seeds.d/70_discovery_mail_notification.rb
|
198
195
|
- db/seeds.d/80_discovery_ui_notification.rb
|
@@ -222,6 +219,8 @@ files:
|
|
222
219
|
- locale/it/foreman_discovery.po
|
223
220
|
- locale/ja/LC_MESSAGES/foreman_discovery.mo
|
224
221
|
- locale/ja/foreman_discovery.po
|
222
|
+
- locale/ka/LC_MESSAGES/foreman_discovery.mo
|
223
|
+
- locale/ka/foreman_discovery.po
|
225
224
|
- locale/ko/LC_MESSAGES/foreman_discovery.mo
|
226
225
|
- locale/ko/foreman_discovery.po
|
227
226
|
- locale/pt_BR/LC_MESSAGES/foreman_discovery.mo
|
@@ -260,6 +259,8 @@ files:
|
|
260
259
|
- test/functional/discovery_rules_controller_test.rb
|
261
260
|
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
262
261
|
- test/integration/discovered_hosts_test.rb
|
262
|
+
- test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb
|
263
|
+
- test/static_fixtures/redhat_kexec.erb
|
263
264
|
- test/test_helper_discovery.rb
|
264
265
|
- test/test_plugin_helper.rb
|
265
266
|
- test/unit/discovered_extensions_test.rb
|
@@ -319,7 +320,6 @@ summary: MaaS Discovery Plugin for Foreman
|
|
319
320
|
test_files:
|
320
321
|
- test/unit/discovered_extensions_test.rb
|
321
322
|
- test/unit/discovered_mailer_test.rb
|
322
|
-
- test/unit/discovery_attribute_set_test.rb
|
323
323
|
- test/unit/discovery_rule_test.rb
|
324
324
|
- test/unit/discovery_taxonomy_extensions_test.rb
|
325
325
|
- test/unit/fact_parser_test.rb
|
@@ -327,6 +327,7 @@ test_files:
|
|
327
327
|
- test/unit/lldp_neighbors_test.rb
|
328
328
|
- test/unit/ui_notifications/destroy_host_test.rb
|
329
329
|
- test/unit/ui_notifications/new_host_test.rb
|
330
|
+
- test/unit/discovery_attribute_set_test.rb
|
330
331
|
- test/unit/host_discovered_test.rb
|
331
332
|
- test/unit/managed_extensions_test.rb
|
332
333
|
- test/factories/discovery_host_related.rb
|
@@ -354,5 +355,7 @@ test_files:
|
|
354
355
|
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
355
356
|
- test/functional/discovered_hosts_controller_test.rb
|
356
357
|
- test/integration/discovered_hosts_test.rb
|
357
|
-
- test/test_helper_discovery.rb
|
358
358
|
- test/test_plugin_helper.rb
|
359
|
+
- test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb
|
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
|
@@ -1,41 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
kind: kexec
|
3
|
-
name: Discovery Debian kexec
|
4
|
-
oses:
|
5
|
-
- Debian
|
6
|
-
- Ubuntu
|
7
|
-
description: |
|
8
|
-
This template is used to pass command line options to kexec when reloading
|
9
|
-
kernel on a discovered host instead of rebooting. This is useful in PXE-less
|
10
|
-
environments. The template must generate JSON format with the following items
|
11
|
-
"kernel", "initram", "append" and "extra". The kexec command is composed in
|
12
|
-
the following way:
|
13
|
-
|
14
|
-
kexec --force --debug --append=$append --initrd=$initram $extra $kernel
|
15
|
-
|
16
|
-
Please read kexec(8) man page for more information about semantics.
|
17
|
-
Extra options like --reset-vga can be set via "extra" array.
|
18
|
-
-%>
|
19
|
-
<%
|
20
|
-
mac = @host.facts['discovery_bootif']
|
21
|
-
bootif = host_param("hardware_type", "01") + '-' + mac.gsub(':', '-') if mac
|
22
|
-
ip_cidr = @host.facts['discovery_ip_cidr']
|
23
|
-
ip = @host.facts['discovery_ip']
|
24
|
-
mask = @host.facts['discovery_netmask']
|
25
|
-
gw = @host.facts['discovery_gateway']
|
26
|
-
dns = @host.facts['discovery_dns']
|
27
|
-
options = ["nomodeset", "nokaslr", "auto=true"]
|
28
|
-
options << @host.facts['append']
|
29
|
-
options << "domain=#{@host.domain}"
|
30
|
-
options << 'console-setup/ask_detect=false console-setup/layout=USA console-setup/variant=USA keyboard-configuration/layoutcode=us localechooser/translation/warn-light=true localechooser/translation/warn-severe=true'
|
31
|
-
options << "locale=#{host_param('lang') || 'en_US'}"
|
32
|
-
options << "inst.stage2=#{@host.operatingsystem.medium_uri(@host)}" if @host.operatingsystem.name.match(/Atomic/i)
|
33
|
-
extra = []
|
34
|
-
extra << "--kexec-file-syscall" if @host.pxe_loader.include?('SecureBoot')
|
35
|
-
-%>
|
36
|
-
{
|
37
|
-
"kernel": "<%= @kernel_uri %>",
|
38
|
-
"initram": "<%= @initrd_uri %>",
|
39
|
-
"append": "url=<%= foreman_url('provision') + "&static=yes" %> interface=<%= mac %> netcfg/get_ipaddress=<%= ip %> netcfg/get_netmask=<%= mask %> netcfg/get_gateway=<%= gw %> netcfg/get_nameservers=<%= dns %> netcfg/disable_dhcp=true netcfg/get_hostname=<%= @host.name %> BOOTIF=<%= bootif %> <%= options.compact.join(' ') %>",
|
40
|
-
"extra": <%= extra %>
|
41
|
-
}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
organizations = Organization.unscoped.all
|
2
|
-
locations = Location.unscoped.all
|
3
|
-
|
4
|
-
kind = TemplateKind.unscoped.find_or_create_by(name: 'kexec')
|
5
|
-
kind.description = N_("Command line options for kexec during PXE-less provisioning.")
|
6
|
-
kind.save!
|
7
|
-
|
8
|
-
ProvisioningTemplate.without_auditing do
|
9
|
-
[['redhat_kexec.erb', 'Red Hat'], ['debian_kexec.erb', 'Debian']].each do |tmpl_names|
|
10
|
-
content = File.read(File.join(ForemanDiscovery::Engine.root, 'app', 'views', 'foreman_discovery', tmpl_names[0]))
|
11
|
-
tmpl = ProvisioningTemplate.unscoped.where(:name => "Discovery #{tmpl_names[1]} kexec").first_or_create(
|
12
|
-
:template_kind_id => kind.id,
|
13
|
-
:snippet => false,
|
14
|
-
:template => content
|
15
|
-
)
|
16
|
-
tmpl.attributes = {
|
17
|
-
:template => content,
|
18
|
-
:default => true,
|
19
|
-
:vendor => "Foreman Discovery",
|
20
|
-
:locked => true
|
21
|
-
}
|
22
|
-
tmpl.template = content
|
23
|
-
tmpl.organizations = organizations
|
24
|
-
tmpl.locations = locations
|
25
|
-
|
26
|
-
metadata = Template.parse_metadata(content)
|
27
|
-
tmpl.description = metadata['description']
|
28
|
-
|
29
|
-
tmpl.save!(:validate => false) if tmpl.changes.present?
|
30
|
-
end
|
31
|
-
end
|