Class: ForemanBootdisk::Api::V2::DisksController

Inherits:
Api::V2::BaseController
  • Object
show all
Includes:
AllowedActions, Api::Version2
Defined in:
app/controllers/foreman_bootdisk/api/v2/disks_controller.rb

Instance Method Summary collapse

Methods included from AllowedActions

#bootdisk_type_allowed?

Instance Method Details

#genericObject



21
22
23
24
25
26
27
# File 'app/controllers/foreman_bootdisk/api/v2/disks_controller.rb', line 21

def generic
  # EFI not supported for iPXE generic bootdisk
  tmpl = ForemanBootdisk::Renderer.new.generic_template_render
  ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
    send_file(iso, filename: "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso")
  end
end

#hostObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/foreman_bootdisk/api/v2/disks_controller.rb', line 32

def host
  host = @disk
  if params[:full]
    return unless bootdisk_type_allowed?('full_host')
    begin
      ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
        send_file(iso, filename: "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso")
      end
    rescue ::Foreman::Exception => e
      raise e unless e.code == 'ERF42-2893'
      render_error json: { error: _('Host is not in build mode')}, status: :method_not_allowed
    end
  else
    return unless bootdisk_type_allowed?
    # EFI not supported for iPXE host bootdisk
    tmpl = host.bootdisk_template_render
    ForemanBootdisk::ISOGenerator.generate(ipxe: tmpl) do |iso|
      send_file(iso, filename: "#{host.name}.iso")
    end
  end
end

#indexObject



18
# File 'app/controllers/foreman_bootdisk/api/v2/disks_controller.rb', line 18

def index; end