Sha256: 2443d932370890ead64a60d8fd6553e7f3eff96c1211b734f9595ae3c03e9381

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'uri'

module ForemanBootdisk::Api::V2
  class SubnetDisksController < ::Api::V2::BaseController
    include ::Api::Version2

    resource_description do
      api_base_url "/bootdisk/api"
    end

    before_filter :find_resource, :only => :subnet

    skip_after_filter :log_response_body

    # no-op, but required for apipie documentation
    api :GET, '', N_('Subnet boot disks')
    def index; end

    api :GET, '/subnets/:subnet_id', N_('Download subnet generic image')
    param :subnet_id, :identifier_dottable, :required => true
    def subnet
      subnet = @subnet_disk
      subnet.tftp || raise(::Foreman::Exception.new(N_("TFTP feature not enabled for subnet %s"), subnet.name))
      tmpl = ForemanBootdisk::Renderer.new.generic_template_render(subnet)
      ForemanBootdisk::ISOGenerator.generate(:ipxe => tmpl) do |iso|
        name=subnet.name
        send_data File.read(iso), :filename => "bootdisk_subnet_#{name}.iso"
      end
    end

    private

    def resource_scope
      Subnet.authorized('view_subnets')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foreman_bootdisk-9.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-8.1.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-8.0.2 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-8.0.1 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-7.0.1 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-8.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-7.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-6.1.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb