Sha256: bdea2173e9a71251c96eaf5de9bac07ee1ebea6aa6a3b606b7bd153e59796004

Contents?: true

Size: 1020 Bytes

Versions: 10

Compression:

Stored size: 1020 Bytes

Contents

module Katello
  module Concerns
    module OperatingsystemExtensions
      extend ActiveSupport::Concern

      included do
        after_create :assign_templates!
      end

      def assign_templates!
        # Automatically assign default templates
        if self.family == 'Redhat'
          TemplateKind.all.each do |kind|
            if (template = ProvisioningTemplate.find_by_name(Setting["katello_default_#{kind.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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
katello-2.4.5 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.4 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.3 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-3.0.0.rc1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.1 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.0 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.0.rc3 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.0.rc2 app/models/katello/concerns/operatingsystem_extensions.rb
katello-2.4.0.rc1 app/models/katello/concerns/operatingsystem_extensions.rb