Sha256: 3037e8c6bd6e0a53930fdc905588e0f069ec73cfa03b2624414d2b9456a2f861

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'uri'

module ForemanBootdisk
  module HostExt
    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
  end
end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_bootdisk-16.1.0 app/models/concerns/foreman_bootdisk/host_ext.rb