Sha256: 455952934bd3f3a31747197a17d298430d674614bad975049c9e6323c0b7b3f5

Contents?: true

Size: 1.94 KB

Versions: 174

Compression:

Stored size: 1.94 KB

Contents

module Katello
  module Concerns
    module OperatingsystemExtensions
      extend ActiveSupport::Concern

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

      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.unscoped.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.unscoped.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

174 entries across 174 versions & 1 rubygems

Version Path
katello-4.3.0.rc2.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.3.0.rc2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.3.0.rc1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.2.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.2.0.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.4 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.2.0.1.rc3 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.2.0.1.rc2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.2.0.rc2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.3 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.2.0.rc1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.2.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.0 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.0.rc2.2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.0.rc2.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.0.rc2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.0.rc1.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-4.1.0.rc1 app/models/katello/concerns/operatingsystem_extensions.rb