Sha256: 309d79616ff0c0bef177207dc42edfaf6e953a3af28830515b8f167a9ebf3b7e

Contents?: true

Size: 1.59 KB

Versions: 19

Compression:

Stored size: 1.59 KB

Contents

module Katello
  class SmartProxyHelper
    attr_accessor :smart_proxy
    def initialize(smart_proxy)
      @smart_proxy = smart_proxy
    end

    def ==(other)
      other.class == self.class && other.smart_proxy == smart_proxy
    end

    def default_capsule?
      @smart_proxy.pulp_primary?
    end

    def lifecycle_environment_check(environment = nil, repository = nil)
      environment = repository.environment if repository

      if environment && !self.smart_proxy.lifecycle_environments.include?(environment)
        fail _("Lifecycle environment '%{environment}' is not attached to this capsule.") % { :environment => environment.name }
      end
    end

    def clear_smart_proxy_sync_histories(repo_list = [])
      if repo_list.empty?
        @smart_proxy.smart_proxy_sync_histories.delete_all
        return
      end
      repo_ids = repo_list.map(&:id)
      @smart_proxy.smart_proxy_sync_histories.where("repository_id IN (?)", repo_ids).delete_all
    end

    def combined_repos_available_to_capsule(environment = nil, content_view = nil, repository = nil)
      lifecycle_environment_check(environment, repository)
      if repository
        [repository]
      else
        repositories_available_to_capsule(environment, content_view)
      end
    end

    def repositories_available_to_capsule(environments, content_view)
      environments = @smart_proxy.lifecycle_environments if environments.nil?
      yum_repos = Katello::Repository.in_environment(environments)
      yum_repos = yum_repos.in_content_views([content_view]) if content_view
      yum_repos.smart_proxy_syncable
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
katello-4.2.2 app/services/katello/smart_proxy_helper.rb
katello-4.3.0.rc1 app/services/katello/smart_proxy_helper.rb
katello-4.2.1 app/services/katello/smart_proxy_helper.rb
katello-4.2.0.1 app/services/katello/smart_proxy_helper.rb
katello-4.1.4 app/services/katello/smart_proxy_helper.rb
katello-4.2.0.1.rc3 app/services/katello/smart_proxy_helper.rb
katello-4.2.0.1.rc2 app/services/katello/smart_proxy_helper.rb
katello-4.2.0.rc2 app/services/katello/smart_proxy_helper.rb
katello-4.1.3 app/services/katello/smart_proxy_helper.rb
katello-4.2.0.rc1 app/services/katello/smart_proxy_helper.rb
katello-4.1.2.1 app/services/katello/smart_proxy_helper.rb
katello-4.1.2 app/services/katello/smart_proxy_helper.rb
katello-4.1.1 app/services/katello/smart_proxy_helper.rb
katello-4.1.0 app/services/katello/smart_proxy_helper.rb
katello-4.1.0.rc2.2 app/services/katello/smart_proxy_helper.rb
katello-4.1.0.rc2.1 app/services/katello/smart_proxy_helper.rb
katello-4.1.0.rc2 app/services/katello/smart_proxy_helper.rb
katello-4.1.0.rc1.1 app/services/katello/smart_proxy_helper.rb
katello-4.1.0.rc1 app/services/katello/smart_proxy_helper.rb