Sha256: 4d99cb2133d74a129fc0057573affb8955ee0205c6c641173017bd626930aa58

Contents?: true

Size: 1.49 KB

Versions: 31

Compression:

Stored size: 1.49 KB

Contents

module Katello
  module Validators
    class HostgroupKickstartRepositoryValidator < ActiveModel::Validator
      def validate(facet)
        # check content source first, otherwise it's meaningless to proceed
        if facet.content_source && facet.lifecycle_environment
          valid = facet.content_source.lifecycle_environments.include?(facet.lifecycle_environment)
          facet.errors.add(:base, _("The selected content source and lifecycle environment do not match")) && return unless valid
        end

        return unless facet.kickstart_repository_id

        msg = if facet.content_source.blank?
                _("Please select a content source before assigning a kickstart repository")
              elsif facet.hostgroup.operatingsystem.blank?
                _("Please select an operating system before assigning a kickstart repository")
              elsif !facet.hostgroup.operatingsystem.is_a?(Redhat)
                _("Kickstart repositories can only be assigned to hosts in the Red Hat family")
              elsif facet.hostgroup.architecture.blank?
                _("Please select an architecture before assigning a kickstart repository")
              elsif !facet.hostgroup.matching_kickstart_repository?(facet)
                _("The selected kickstart repository is not part of the assigned content view, lifecycle environment,
                  content source, operating system, and architecture")
              end

        facet.errors.add(:base, msg) if msg
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
katello-4.0.3 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.5 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.2.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.4 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.1.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.3.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.1.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.3 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.0 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.0.rc3.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.0.rc3 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.2.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.17.3 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.0.rc2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.18.1.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.17.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-4.0.0.rc1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb