foreman_discovery 21.0.3 → 22.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f46a7cb5e8d9844eab1344f89727588ea50ac3a4b4132b9f57b31c59890654f4
4
- data.tar.gz: 616421f009b108959eb3620b962a34ae1272cf0aaeee05969b531cbe9c23062d
3
+ metadata.gz: 88ecd56a2e51a5e9f79ad75f9b3214dbd639bd7dccef4fad054b02ed930047ea
4
+ data.tar.gz: 6ff4fafc798c38ef7097fcef16b777966ba9154ca1f13af52d62b47c2ef6eea5
5
5
  SHA512:
6
- metadata.gz: c58e346d7b486ac0fe4d0e97abd4253af4f80d5f3bcd1895e9e989a53b75deb41570485c29126f43346714cacdb06dedf4ae7e20eed399132e93c964b92f07dd
7
- data.tar.gz: 05353a4e56ddec1d1c2d97c127b8c18d34bc69055404d98893eec32922e43a24bbfcee5ba5f422f4c0252724ccab544b3c50406197eae8d5cb325ab01f4f0bd5
6
+ metadata.gz: 7d28310f1bc924f34c60cbe5f0998ad567a61b3ef244503a7247204ef6ffd784e241243bb0b3b4e3f86ff2d619d89961469716966e0e9fa4d851a88010eb19e0
7
+ data.tar.gz: 5194001c735a6edbee4a50fb5fe5eb4e9f18d19a74317c4bd15dae1d32f74a35d49d4136c0acfc9df45e4dc7f12671a15fe60b9bd8efde3aefeca4174ba29bff
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixDiscoverySettingsCategoryToDsl < ActiveRecord::Migration[6.0]
4
+ def up
5
+ # rubocop:disable Rails/SkipsModelValidations
6
+ Setting.where(category: 'Setting::Discovered').update_all(category: 'Setting')
7
+ # rubocop:enable Rails/SkipsModelValidations
8
+ end
9
+ end
@@ -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.2'
46
+ requires_foreman '>= 3.3'
47
47
 
48
48
  # settings
49
49
  settings do
@@ -310,7 +310,7 @@ module ForemanDiscovery
310
310
  :edit_discovery_rules,
311
311
  :destroy_discovery_rules,
312
312
  ]
313
- if defined?(ForemanPuppet::VERSION)
313
+ if defined?(ForemanPuppet::Engine)
314
314
  MANAGER += [ :view_environments, :view_puppetclasses ]
315
315
  end
316
316
  role "Discovery Reader", READER, "Role granting permissions to view discovered hosts"
@@ -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"]
@@ -1,3 +1,3 @@
1
1
  module ForemanDiscovery
2
- VERSION = "21.0.3"
2
+ VERSION = "22.0.2"
3
3
  end
@@ -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
- "kernel": "<%= @kernel_uri %>",
48
- "initram": "<%= @initrd_uri %>",
51
+ "kernel": "<%= @kernel_uri %>",
52
+ "initram": "<%= @initrd_uri %>",
49
53
  <% if (@host.operatingsystem.name == 'Fedora' and @host.operatingsystem.major.to_i > 16) or
50
- (@host.operatingsystem.name != 'Fedora' and @host.operatingsystem.major.to_i >= 7) -%>
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
- "extra": <%= extra %>
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(user_all) do
307
- hosts = Host::Discovered.all
308
- end
309
- assert_includes hosts, host1
310
- assert_includes hosts, host2
311
- assert_includes hosts, host3
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("..", "..", "..", "app", "views", "foreman_discovery", "redhat_kexec.erb"), __FILE__))) }
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
@@ -12,7 +12,7 @@ const EmptyState = props => {
12
12
  };
13
13
  return (
14
14
  <ForemanEmptyState
15
- header="Foreman Discovery"
15
+ header={__('Foreman Discovery')}
16
16
  description={description}
17
17
  icon="gears"
18
18
  iconType="fa"
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: 21.0.3
4
+ version: 22.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditi Puntambekar
@@ -14,7 +14,6 @@ authors:
14
14
  - Avi Sharvit
15
15
  - Bryan Kearney
16
16
  - bshuster
17
- - ChairmanTubeAmp
18
17
  - Daniel Lobato
19
18
  - Daniel Lobato Garcia
20
19
  - Daniel Lobato García
@@ -27,6 +26,7 @@ authors:
27
26
  - Ewoud Kohl van Wijngaarden
28
27
  - Frank Wall
29
28
  - Greg Sutcliffe
29
+ - ChairmanTubeAmp
30
30
  - Ido Kanner
31
31
  - imriz
32
32
  - Imri Zvik
@@ -48,11 +48,10 @@ authors:
48
48
  - Matt Jarvis
49
49
  - Michael Moll
50
50
  - Nick
51
- - nofar
52
51
  - odovzhenko
53
52
  - Ohad Levy
54
- - Ondřej Ezr
55
53
  - Ondrej Prazak
54
+ - Ondřej Ezr
56
55
  - Ori Rabin
57
56
  - orrabin
58
57
  - Partha Aji
@@ -77,7 +76,7 @@ authors:
77
76
  autorequire:
78
77
  bindir: bin
79
78
  cert_chain: []
80
- date: 2022-09-06 00:00:00.000000000 Z
79
+ date: 2022-11-03 00:00:00.000000000 Z
81
80
  dependencies: []
82
81
  description: MaaS Discovery Plugin engine for Foreman
83
82
  email: gsutclif@redhat.com
@@ -167,8 +166,6 @@ files:
167
166
  - app/views/discovery_rules/index.html.erb
168
167
  - app/views/discovery_rules/new.html.erb
169
168
  - app/views/discovery_rules/welcome.html.erb
170
- - app/views/foreman_discovery/debian_kexec.erb
171
- - app/views/foreman_discovery/redhat_kexec.erb
172
169
  - config/as_deprecation_whitelist.yaml
173
170
  - config/initializers/discovery_setup.rb
174
171
  - config/routes.rb
@@ -192,7 +189,7 @@ files:
192
189
  - db/migrate/20161006094714_add_constraints_on_subnets_smart_proxies.rb
193
190
  - db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
194
191
  - db/migrate/20180412124505_add_priority_score_to_discovery_rules.rb
195
- - db/seeds.d/50_discovery_templates.rb
192
+ - db/migrate/20221102065954_fix_discovery_settings_category_to_dsl.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
@@ -344,7 +342,6 @@ test_files:
344
342
  - test/integration/discovered_hosts_test.rb
345
343
  - test/unit/ui_notifications/destroy_host_test.rb
346
344
  - test/unit/ui_notifications/new_host_test.rb
347
- - test/unit/discovered_extensions_test.rb
348
345
  - test/unit/discovered_mailer_test.rb
349
346
  - test/unit/discovery_attribute_set_test.rb
350
347
  - test/unit/discovery_rule_test.rb
@@ -352,7 +349,9 @@ test_files:
352
349
  - test/unit/fact_parser_test.rb
353
350
  - test/unit/fact_to_category_resolver_test.rb
354
351
  - test/unit/lldp_neighbors_test.rb
352
+ - test/unit/discovered_extensions_test.rb
355
353
  - test/unit/host_discovered_test.rb
356
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