Skip to content

Commit

Permalink
Fixes #23267 - nil exception with PXELinux template
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed May 29, 2018
1 parent 385199f commit ec64b23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/services/foreman_bootdisk/iso_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def self.generate_full_host(host, opts = {}, &block)
raise ::Foreman::Exception.new(N_('Host is not in build mode, so the template cannot be rendered')) unless host.build?

tmpl = host.send(:generate_pxe_template, :PXELinux)
raise ::Foreman::Exception.new(N_('Unable to generate disk template: %s'), host.errors.full_messages.to_sentence) if tmpl == false
unless tmpl
raise ::Foreman::Exception.new(N_('Unable to generate disk template: %s'), host.errors.full_messages.to_sentence)
end

# pxe_files and filename conversion is utterly bizarre
# aim to convert filenames to something usable under ISO 9660, update the template to match
Expand Down
5 changes: 2 additions & 3 deletions test/unit/iso_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ class ForemanBootdisk::IsoGeneratorTest < ActiveSupport::TestCase
end

test "full host image generation generates via PXELinux type" do
@host.expects(:generate_pxe_template).with(:PXELinux).returns("Template")
@host.operatingsystem.expects(:pxe_files).returns([])
@host.operatingsystem.expects(:kernel).returns("kernel")
@host.operatingsystem.expects(:initrd).returns("initrd")
ForemanBootdisk::ISOGenerator.expects(:generate).with({:isolinux => nil, :files => []}, anything)
ForemanBootdisk::ISOGenerator.expects(:generate).with({:isolinux => "Template", :files => []}, anything)
ForemanBootdisk::ISOGenerator.generate_full_host(@host)
end
end

0 comments on commit ec64b23

Please sign in to comment.