Sha256: 22661f5431ad99325a6ecf385dca660a0aa3a4e5db5bd06aa128c9562c1808d3

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

module Katello
  module Concerns
    module OperatingsystemExtensions
      extend ActiveSupport::Concern

      REDHAT_ATOMIC_HOST_DISTRO_NAME = "Red Hat Enterprise Linux Atomic Host"
      REDHAT_ATOMIC_HOST_OS = "RedHat_Enterprise_Linux_Atomic_Host"

      included do
        after_create :assign_templates!
        before_create :set_atomic_attributes, :if => proc { |os| os.name == ::Operatingsystem::REDHAT_ATOMIC_HOST_OS }
      end

      def assign_templates!
        # Automatically assign default templates
        if self.family == 'Redhat'
          TemplateKind.all.each do |kind|
            if name == ::Operatingsystem::REDHAT_ATOMIC_HOST_OS && kind.name == "provision"
              provisioning_template_name = Setting["katello_default_atomic_provision"]
            else
              provisioning_template_name = Setting["katello_default_#{kind.name}"]
            end

            if (template = ProvisioningTemplate.find_by_name(provisioning_template_name))
              provisioning_templates << template unless provisioning_templates.include?(template)
              if OsDefaultTemplate.where(:template_kind_id => kind.id, :operatingsystem_id => id).empty?
                OsDefaultTemplate.create(:template_kind_id => kind.id, :provisioning_template_id => template.id, :operatingsystem_id => id)
              end
            end
          end

          if (ptable = Ptable.find_by_name(Setting["katello_default_ptable"]))
            ptables << ptable unless ptables.include?(ptable)
          end
        end
      end

      def set_atomic_attributes
        self.description = "#{::Operatingsystem::REDHAT_ATOMIC_HOST_DISTRO_NAME} #{release}"
        self.architectures << Architecture.where(:name => "x86_64").first_or_create
        self.family = "Redhat"
      end

      def atomic?
        name.match(/.*atomic.*/i)
      end
    end
  end
end

class ::Operatingsystem::Jail < Safemode::Jail
  allow :atomic?
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katello-3.0.2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-3.0.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-3.0.0 app/models/katello/concerns/operatingsystem_extensions.rb
katello-3.0.0.rc7 app/models/katello/concerns/operatingsystem_extensions.rb