foreman_discovery 21.0.5 → 22.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_discovery/engine.rb +1 -3
- data/lib/foreman_discovery/version.rb +1 -1
- data/test/functional/discovered_hosts_controller_test.rb +2 -0
- data/{app/views/foreman_discovery → test/static_fixtures}/redhat_kexec.erb +11 -7
- data/test/unit/host_discovered_test.rb +9 -13
- data/test/unit/managed_extensions_test.rb +2 -1
- data/webpack/src/ForemanDiscovery/DiscoveredHosts/Components/EmptyState/EmptyState.js +1 -1
- metadata +17 -18
- data/app/views/foreman_discovery/debian_kexec.erb +0 -41
- data/db/seeds.d/50_discovery_templates.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88ecd56a2e51a5e9f79ad75f9b3214dbd639bd7dccef4fad054b02ed930047ea
|
4
|
+
data.tar.gz: 6ff4fafc798c38ef7097fcef16b777966ba9154ca1f13af52d62b47c2ef6eea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d28310f1bc924f34c60cbe5f0998ad567a61b3ef244503a7247204ef6ffd784e241243bb0b3b4e3f86ff2d619d89961469716966e0e9fa4d851a88010eb19e0
|
7
|
+
data.tar.gz: 5194001c735a6edbee4a50fb5fe5eb4e9f18d19a74317c4bd15dae1d32f74a35d49d4136c0acfc9df45e4dc7f12671a15fe60b9bd8efde3aefeca4174ba29bff
|
@@ -43,7 +43,7 @@ module ForemanDiscovery
|
|
43
43
|
|
44
44
|
initializer 'foreman_discovery.register_plugin', :before => :finisher_hook do |app|
|
45
45
|
Foreman::Plugin.register :foreman_discovery do
|
46
|
-
requires_foreman '>= 3.
|
46
|
+
requires_foreman '>= 3.3'
|
47
47
|
|
48
48
|
# settings
|
49
49
|
settings do
|
@@ -337,8 +337,6 @@ module ForemanDiscovery
|
|
337
337
|
# add dashboard widget
|
338
338
|
widget 'discovery_widget', :name=>N_('Discovered Hosts'), :sizex => 6, :sizey =>1
|
339
339
|
|
340
|
-
template_labels 'kexec' => N_('Discovery Kexec template')
|
341
|
-
|
342
340
|
# apipie API documentation
|
343
341
|
# Only available in 1.8, otherwise it has to be in the initializer below
|
344
342
|
apipie_documented_controllers ["#{ForemanDiscovery::Engine.root}/app/controllers/api/v2/*.rb"]
|
@@ -303,6 +303,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
303
303
|
Host::Managed.any_instance.stubs(:queue_puppetca_create).returns(true)
|
304
304
|
Host::Managed.any_instance.stubs(:queue_puppetca_certname_reset).returns(true)
|
305
305
|
Host::Managed.any_instance.stubs(:queue_puppetca_autosign_destroy).returns(true)
|
306
|
+
ProxyAPI::DNS.any_instance.stubs(:set).returns(true)
|
306
307
|
put :update, params: {:commit => "Update", :id => host.id,
|
307
308
|
:host => {
|
308
309
|
:name => 'mytest',
|
@@ -354,6 +355,7 @@ class DiscoveredHostsControllerTest < ActionController::TestCase
|
|
354
355
|
def prepare_hostgroup_for_dns_rebuild(host)
|
355
356
|
hostgroup = setup_hostgroup(host)
|
356
357
|
hostgroup.domain = FactoryBot.create(:domain, :name => 'myorchdomain.net', :dns => FactoryBot.create(:smart_proxy, :features => [FactoryBot.create(:feature, :dns)]))
|
358
|
+
hostgroup.save
|
357
359
|
hostgroup
|
358
360
|
end
|
359
361
|
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
|
+
}
|
@@ -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.2
|
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: 2022-11-03 00:00:00.000000000 Z
|
80
80
|
dependencies: []
|
81
81
|
description: MaaS Discovery Plugin engine for Foreman
|
82
82
|
email: gsutclif@redhat.com
|
@@ -166,8 +166,6 @@ files:
|
|
166
166
|
- app/views/discovery_rules/index.html.erb
|
167
167
|
- app/views/discovery_rules/new.html.erb
|
168
168
|
- app/views/discovery_rules/welcome.html.erb
|
169
|
-
- app/views/foreman_discovery/debian_kexec.erb
|
170
|
-
- app/views/foreman_discovery/redhat_kexec.erb
|
171
169
|
- config/as_deprecation_whitelist.yaml
|
172
170
|
- config/initializers/discovery_setup.rb
|
173
171
|
- config/routes.rb
|
@@ -192,7 +190,6 @@ files:
|
|
192
190
|
- db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
|
193
191
|
- db/migrate/20180412124505_add_priority_score_to_discovery_rules.rb
|
194
192
|
- db/migrate/20221102065954_fix_discovery_settings_category_to_dsl.rb
|
195
|
-
- db/seeds.d/50_discovery_templates.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
|
@@ -260,6 +257,7 @@ files:
|
|
260
257
|
- test/functional/discovery_rules_controller_test.rb
|
261
258
|
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
262
259
|
- test/integration/discovered_hosts_test.rb
|
260
|
+
- test/static_fixtures/redhat_kexec.erb
|
263
261
|
- test/test_helper_discovery.rb
|
264
262
|
- test/test_plugin_helper.rb
|
265
263
|
- test/unit/discovered_extensions_test.rb
|
@@ -317,18 +315,6 @@ signing_key:
|
|
317
315
|
specification_version: 4
|
318
316
|
summary: MaaS Discovery Plugin for Foreman
|
319
317
|
test_files:
|
320
|
-
- test/unit/discovered_extensions_test.rb
|
321
|
-
- test/unit/discovered_mailer_test.rb
|
322
|
-
- test/unit/discovery_attribute_set_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/host_discovered_test.rb
|
331
|
-
- test/unit/managed_extensions_test.rb
|
332
318
|
- test/factories/discovery_host_related.rb
|
333
319
|
- test/factories/discovery_rule_related.rb
|
334
320
|
- test/facts/bond0-eth0-eth1-active-passive.json
|
@@ -350,9 +336,22 @@ test_files:
|
|
350
336
|
- test/functional/api/v2/discovered_hosts_controller_test.rb
|
351
337
|
- test/functional/api/v2/discovery_rules_controller_test.rb
|
352
338
|
- test/functional/api/v2/fact_value_extensions_test.rb
|
353
|
-
- test/functional/discovery_rules_controller_test.rb
|
354
339
|
- test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb
|
340
|
+
- test/functional/discovery_rules_controller_test.rb
|
355
341
|
- test/functional/discovered_hosts_controller_test.rb
|
356
342
|
- 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
|
357
355
|
- test/test_helper_discovery.rb
|
358
356
|
- test/test_plugin_helper.rb
|
357
|
+
- test/static_fixtures/redhat_kexec.erb
|
@@ -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
|