Sha256: 26f9db3f303c8cdb5fb5217442c3cdd7c845c7d858bead0f63ad5284ebc7bfe6

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

require 'uri'

module ForemanBootdisk
  class DisksController < ::ApplicationController
    before_filter :find_resource, :only => %w[host full_host]

    def generic
      begin
        tmpl = ForemanBootdisk::Renderer.new.generic_template_render
      rescue => e
        error _('Failed to render boot disk template: %s') % e
        redirect_to :back
        return
      end

      ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl) do |iso|
        send_data File.read(iso), :filename => "bootdisk_#{URI.parse(Setting[:foreman_url]).host}.iso"
      end
    end

    def host
      host = @disk
      begin
        tmpl = host.bootdisk_template_render
      rescue => e
        error _('Failed to render boot disk template: %s') % e
        redirect_to :back
        return
      end

      ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl) do |iso|
        send_data File.read(iso), :filename => "#{host.name}.iso"
      end
    end

    def full_host
      host = @disk
      ForemanBootdisk::ISOGenerator.generate_full_host(host) do |iso|
        send_data File.read(iso), :filename => "#{host.name}#{ForemanBootdisk::ISOGenerator.token_expiry(host)}.iso"
      end
    end

    def help
    end

    private

    def resource_scope(controller = controller_name)
      Host::Managed.authorized(:view_hosts)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_bootdisk-6.0.0 app/controllers/foreman_bootdisk/disks_controller.rb
foreman_bootdisk-5.0.0 app/controllers/foreman_bootdisk/disks_controller.rb
foreman_bootdisk-4.0.2 app/controllers/foreman_bootdisk/disks_controller.rb
foreman_bootdisk-4.0.1 app/controllers/foreman_bootdisk/disks_controller.rb
foreman_bootdisk-4.0.0 app/controllers/foreman_bootdisk/disks_controller.rb