Class: ForemanBootdisk::SubnetDisksController

Inherits:
ApplicationController
  • Object
show all
Includes:
PrettyError
Defined in:
app/controllers/foreman_bootdisk/subnet_disks_controller.rb

Instance Method Summary collapse

Methods included from PrettyError

#error_rendering

Instance Method Details

#subnetObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/foreman_bootdisk/subnet_disks_controller.rb', line 13

def subnet
  begin
    @subnet.tftp || raise(::Foreman::Exception.new(N_('TFTP feature not enabled for subnet %s'), @subnet.name))
    @subnet.httpboot || ForemanBootdisk.logger.warn('HTTPBOOT feature is not enabled for subnet %s, UEFI may not be available for bootdisk' % @subnet.name)

    tmpl_bios = ForemanBootdisk::Renderer.new.generic_template_render(@subnet)
    tmpl_efi = ForemanBootdisk::Renderer.new.generic_efi_template_render(@subnet)
  rescue StandardError => e
    error_rendering(e)
    redirect_back(fallback_location: '/')
    return
  end

  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl_bios, grub: tmpl_efi) do |iso|
    send_file(iso, filename: "bootdisk_subnet_#{@subnet.name}.iso")
  end
end