Sha256: bb81bcd9e419e2da32d4c4b2b5cfb5c4976be502153e659d24df4c3fbec946f1

Contents?: true

Size: 1.52 KB

Versions: 17

Compression:

Stored size: 1.52 KB

Contents

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

        return unless hostgroup.kickstart_repository_id

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

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
katello-3.12.3 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.12.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.12.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.11.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.10.2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.12.0 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.12.0.rc2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.10.1.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.12.0.rc1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.10.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.11.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.11.0 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.11.0.rc2 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.11.0.rc1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.10.0 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.10.0.rc1.1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb
katello-3.10.0.rc1 app/lib/katello/validators/hostgroup_kickstart_repository_validator.rb