foreman_bootdisk 10.0.0 → 10.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22c86a63777cd84947eaaa64505cd6ab37910773
4
- data.tar.gz: 6095c49c84e7c98a4addd7426e280ae33b6ed47a
3
+ metadata.gz: 650c3fef3d65bf931b5b55742b6edf13ab569b85
4
+ data.tar.gz: 5ba2e8581df468982cea40b986fbfe2e659b2832
5
5
  SHA512:
6
- metadata.gz: 06ac35157d5df78c69f34e6cbeb79c89eb0c121341617adbbf504a569b1e9522cec3e540c0b49b3184a8225ede573286bd917e6626f1f00e91786acdbac45406
7
- data.tar.gz: 4c90bda0e2f90075b3065e9eebb192bae0ea27f87bd95f830a5d21256d3267d481baac3a1e7060ef2bdbcd41f22f72690dc726660fec68476931c0652750f11b
6
+ metadata.gz: 6281f104fa4b4bd26517485a3c597fb428ddbfb6900e15116b9ecf69f488c1f1e46cc95261829afcd7031ad4d6cc169760c315a7a2b1097d63706dc5b5bd0e46
7
+ data.tar.gz: 29bfcedcadee57b04a791c064ebe1fa56327f0cdd54ec96578b2eacd899540dc737472dadea02a4aa34aa8582aef5a26bec7722a8a169864eb4e84eda4a7ddda
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v10.0.1
4
+ * Fix rake tasks are Taxonomy and User aware (#21877)
5
+ * Revert alias_method_chain with Module#prepend for Katello 3.4 compatibility
6
+
3
7
  ## v10.0.0
4
8
  * retry vmware iso boot 10 times before giving up (#19013)
5
9
  * fix duplicate template creation during database seeding (#19733)
@@ -1,6 +1,12 @@
1
1
  module ForemanBootdisk::UnattendedControllerExt
2
- def find_host_by_ip_or_mac
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ alias_method_chain :find_host_by_ip_or_mac, :param_mac
6
+ end
7
+
8
+ def find_host_by_ip_or_mac_with_param_mac
3
9
  request.env['HTTP_X_RHN_PROVISIONING_MAC_0'] = "unknown #{params['mac']}" unless request.env.has_key?('HTTP_X_RHN_PROVISIONING_MAC_0') || params['mac'].nil?
4
- super
10
+ find_host_by_ip_or_mac_without_param_mac
5
11
  end
6
12
  end
@@ -1,5 +1,11 @@
1
1
  module ForemanBootdisk::HostsHelperExt
2
- def host_title_actions(*args)
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ alias_method_chain :host_title_actions, :bootdisk
6
+ end
7
+
8
+ def host_title_actions_with_bootdisk(*args)
3
9
  if @host.bootdisk_downloadable?
4
10
  title_actions(
5
11
  button_group(
@@ -18,7 +24,7 @@ module ForemanBootdisk::HostsHelperExt
18
24
  bootdisk_button_disabled
19
25
  end
20
26
 
21
- super
27
+ host_title_actions_without_bootdisk(*args)
22
28
  end
23
29
 
24
30
  def bootdisk_button_disabled
@@ -1,12 +1,19 @@
1
1
  module ForemanBootdisk
2
2
  module ComputeResources
3
3
  module Vmware
4
- def capabilities
5
- super + [:bootdisk]
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method_chain :capabilities, :bootdisk
8
+ alias_method_chain :parse_args, :bootdisk
9
+ end
10
+
11
+ def capabilities_with_bootdisk
12
+ capabilities_without_bootdisk + [:bootdisk]
6
13
  end
7
14
 
8
- def parse_args(args = {})
9
- args = super
15
+ def parse_args_with_bootdisk(args = {})
16
+ args = parse_args_without_bootdisk args
10
17
  if args[:provision_method] == 'bootdisk'
11
18
  args[:cdroms] = [new_cdrom]
12
19
  args[:boot_order] = ['cdrom', 'disk']
@@ -1,8 +1,15 @@
1
1
  require 'uri'
2
2
 
3
3
  module ForemanBootdisk::HostExt
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method_chain :validate_media?, :bootdisk
8
+ alias_method_chain :can_be_built?, :bootdisk
9
+ end
10
+
4
11
  def bootdisk_template
5
- ProvisioningTemplate.find_by_name(Setting[:bootdisk_host_template]) || raise(::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_host_template'))
12
+ ProvisioningTemplate.unscoped.find_by_name(Setting[:bootdisk_host_template]) || raise(::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_host_template'))
6
13
  end
7
14
 
8
15
  def bootdisk_template_render
@@ -34,11 +41,11 @@ module ForemanBootdisk::HostExt
34
41
  /i.86|x86[_-]64/ =~ architecture.name
35
42
  end
36
43
 
37
- def validate_media?
38
- super || (managed && bootdisk_build? && build?)
44
+ def validate_media_with_bootdisk?
45
+ validate_media_without_bootdisk? || (managed && bootdisk_build? && build?)
39
46
  end
40
47
 
41
- def can_be_built?
42
- super || (managed? and SETTINGS[:unattended] and bootdisk_build? and !build?)
48
+ def can_be_built_with_bootdisk?
49
+ can_be_built_without_bootdisk? || (managed? and SETTINGS[:unattended] and bootdisk_build? and !build?)
43
50
  end
44
51
  end
@@ -8,7 +8,7 @@ module ForemanBootdisk
8
8
  include RendererMethods
9
9
 
10
10
  def generic_template_render(subnet = nil)
11
- tmpl = ProvisioningTemplate.find_by_name(Setting[:bootdisk_generic_host_template]) || raise(::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_generic_host_template'))
11
+ tmpl = ProvisioningTemplate.unscoped.find_by_name(Setting[:bootdisk_generic_host_template]) || raise(::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_generic_host_template'))
12
12
 
13
13
  if subnet.present?
14
14
  # rendering a subnet-level bootdisk requires tricking the renderer into thinking it has a
@@ -76,11 +76,11 @@ module ForemanBootdisk
76
76
 
77
77
  config.to_prepare do
78
78
  begin
79
- Host::Managed.send(:prepend, ForemanBootdisk::HostExt)
79
+ Host::Managed.send(:include, ForemanBootdisk::HostExt)
80
80
  Host::Managed.send(:include, ForemanBootdisk::Orchestration::Compute) if SETTINGS[:unattended]
81
- HostsHelper.send(:prepend, ForemanBootdisk::HostsHelperExt)
82
- UnattendedController.send(:prepend, ForemanBootdisk::UnattendedControllerExt)
83
- Foreman::Model::Vmware.send(:prepend, ForemanBootdisk::ComputeResources::Vmware) if Foreman::Model::Vmware.available?
81
+ HostsHelper.send(:include, ForemanBootdisk::HostsHelperExt)
82
+ UnattendedController.send(:include, ForemanBootdisk::UnattendedControllerExt)
83
+ Foreman::Model::Vmware.send(:include, ForemanBootdisk::ComputeResources::Vmware) if Foreman::Model::Vmware.available?
84
84
  rescue => e
85
85
  puts "#{ForemanBootdisk::ENGINE_NAME}: skipping engine hook (#{e.to_s})"
86
86
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanBootdisk
2
- VERSION = '10.0.0'
2
+ VERSION = '10.0.1'
3
3
  end
@@ -16,46 +16,54 @@ namespace :bootdisk do
16
16
  namespace :generate do
17
17
  desc 'Generate a static boot disk for a specific host. NAME=fqdn, OUTPUT path'
18
18
  task :host => :environment do
19
- host = Host::Base.find_by_name(ENV['NAME']) || raise("cannot find host '#{ENV['NAME']}', specify NAME=fqdn")
20
- tmpl = host.bootdisk_template_render
19
+ User.as_anonymous_admin do
20
+ host = Host::Base.unscoped.find_by_name(ENV['NAME']) || raise("cannot find host '#{ENV['NAME']}', specify NAME=fqdn")
21
+ tmpl = host.bootdisk_template_render
21
22
 
22
- ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl, :dir => outputdir) do |image|
23
- output = ENV['OUTPUT'] || File.join(outputdir, "#{host.name}.iso")
24
- FileUtils.mv image, output
25
- puts "Wrote #{output}"
23
+ ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl, :dir => outputdir) do |image|
24
+ output = ENV['OUTPUT'] || File.join(outputdir, "#{host.name}.iso")
25
+ FileUtils.mv image, output
26
+ puts "Wrote #{output}"
27
+ end
26
28
  end
27
29
  end
28
30
 
29
31
  desc 'Generate a full boot disk for a specific host with the OS bootloader included. NAME=fqdn, OUTPUT path'
30
32
  task :full_host => :environment do
31
- host = Host::Base.find_by_name(ENV['NAME']) || raise("cannot find host '#{ENV['NAME']}', specify NAME=fqdn")
32
- ForemanBootdisk::ISOGenerator.generate_full_host(host, :dir => outputdir) do |image|
33
- output = ENV['OUTPUT'] || File.join(outputdir, "#{host.name}_#{Date.today.strftime('%Y%m%d')}.iso")
34
- FileUtils.cp image, output
35
- puts "Wrote #{output}"
33
+ User.as_anonymous_admin do
34
+ host = Host::Base.unscoped.find_by_name(ENV['NAME']) || raise("cannot find host '#{ENV['NAME']}', specify NAME=fqdn")
35
+ ForemanBootdisk::ISOGenerator.generate_full_host(host, :dir => outputdir) do |image|
36
+ output = ENV['OUTPUT'] || File.join(outputdir, "#{host.name}_#{Date.today.strftime('%Y%m%d')}.iso")
37
+ FileUtils.cp image, output
38
+ puts "Wrote #{output}"
39
+ end
36
40
  end
37
41
  end
38
42
 
39
43
  desc 'Generate a generic boot disk. OUTPUT=path'
40
44
  task :generic => :environment do
41
- tmpl = ForemanBootdisk::Renderer.new.generic_template_render
45
+ User.as_anonymous_admin do
46
+ tmpl = ForemanBootdisk::Renderer.new.generic_template_render
42
47
 
43
- ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl, :dir => outputdir) do |image|
44
- output = ENV['OUTPUT'] || File.join(outputdir, "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
45
- FileUtils.cp image, output
46
- puts "Wrote #{output}"
48
+ ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl, :dir => outputdir) do |image|
49
+ output = ENV['OUTPUT'] || File.join(outputdir, "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
50
+ FileUtils.cp image, output
51
+ puts "Wrote #{output}"
52
+ end
47
53
  end
48
54
  end
49
55
 
50
56
  desc 'Generate a subnet disk for a specific subnet. NAME=subnet, OUTPUT=path'
51
57
  task :subnet => :environment do
52
- subnet = Subnet.find_by_name(ENV['NAME']) || raise("cannot find subnet '#{ENV['NAME']}', specify NAME=subnet")
53
- subnet.tftp || raise(::Foreman::Exception.new(N_("TFTP feature not enabled for subnet %s"), subnet.name))
54
- tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
55
- ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl, :dir => outputdir) do |image|
56
- output = ENV['OUTPUT'] || File.join(outputdir, "bootdisk_subnet_#{subnet.name}.iso")
57
- FileUtils.cp image, output
58
- puts "Wrote #{output}"
58
+ User.as_anonymous_admin do
59
+ subnet = Subnet.unscoped.find_by_name(ENV['NAME']) || raise("cannot find subnet '#{ENV['NAME']}', specify NAME=subnet")
60
+ subnet.tftp || raise(::Foreman::Exception.new(N_("TFTP feature not enabled for subnet %s"), subnet.name))
61
+ tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
62
+ ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl, :dir => outputdir) do |image|
63
+ output = ENV['OUTPUT'] || File.join(outputdir, "bootdisk_subnet_#{subnet.name}.iso")
64
+ FileUtils.cp image, output
65
+ puts "Wrote #{output}"
66
+ end
59
67
  end
60
68
  end
61
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_bootdisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 10.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Plugin for Foreman that creates iPXE-based boot disks to provision hosts
14
14
  without the need for PXE infrastructure.