Sha256: e2cea0f1bee94a780a79317b1b2822dee8b85338c61f7c8bef6aa05865d95517

Contents?: true

Size: 1.04 KB

Versions: 7

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_action :find_resource, :only => :subnet

    skip_after_action :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

7 entries across 7 versions & 1 rubygems

Version Path
foreman_bootdisk-12.0.1 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-13.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-12.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-11.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-10.0.2 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-10.0.1 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb
foreman_bootdisk-10.0.0 app/controllers/foreman_bootdisk/api/v2/subnet_disks_controller.rb