Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #23267 - nil exception with PXELinux template #60

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 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,10 @@ 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
err = host.errors.full_messages.to_sentence
raise ::Foreman::Exception.new(N_('Unable to generate disk template, PXELinux template not found or: %s'), err)
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