Sha256: 69b03a79a37cc72f1c950650e8bb5f6b812ef333e6a84653fb6e0e001f54c1b7

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require 'uri'

module ForemanBootdisk
  module HostExt
    extend ApipieDSL::Extension

    def bootdisk_template
      template = ProvisioningTemplate.unscoped.find_by(name: Setting[:bootdisk_host_template])
      unless template
        raise ::Foreman::Exception.new(N_('Unable to find template specified by %s setting'), 'bootdisk_host_template')
      end

      template
    end

    def bootdisk_template_render
      ForemanBootdisk::Renderer.new.render_template(template: bootdisk_template, host: self)
    end

    def bootdisk_build?
      provision_method == 'bootdisk'
    end

    def bootdisk?
      managed? && bootdisk_build? && SETTINGS[:unattended]
    end

    def bootdisk_downloadable?
      architecture.blank? || intel_arch?
    end

    def intel_arch?
      /i.86|x86[_-]64/ =~ architecture.name
    end

    def can_be_built?
      super || (managed? && SETTINGS[:unattended] && bootdisk_build? && !build?)
    end

    apipie_update :class do
      property :bootdisk_build?, one_of: [true, false], desc: 'Returns true if provision method for this host is bootdisk, false otherwise'
    end
  end
end

class Host::Managed::Jail < Safemode::Jail
  allow :bootdisk_build?
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_bootdisk-19.0.4.1 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-19.0.4 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-19.0.3 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-19.0.2 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-19.0.1 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-19.0.0 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-18.1.0 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-18.0.0 app/models/concerns/foreman_bootdisk/host_ext.rb
foreman_bootdisk-17.1.0 app/models/concerns/foreman_bootdisk/host_ext.rb