Sha256: 4b67a35bd6d24b16db62fadd7329bd533c17c674dee5a8974c05b370414cda66

Contents?: true

Size: 1.73 KB

Versions: 28

Compression:

Stored size: 1.73 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_master?
    end

    def repos_available_to_capsule(environment = nil, content_view = nil, repository = nil)
      ret = []
      if repository
        environment = repository.environment
        ret = [repository]
      else
        yum_repos = fetch_repos_available_to_capsule(environment, content_view) || []
        puppet_envs = fetch_puppet_environments_available_to_capsule(environment, content_view) || []
        ret = yum_repos + puppet_envs
      end

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

      ret
    end

    private

    def fetch_repos_available_to_capsule(environments = nil, content_view = nil)
      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.select(&:node_syncable?)
    end

    def fetch_puppet_environments_available_to_capsule(environments = nil, content_view = nil)
      environments = @smart_proxy.lifecycle_environments if environments.nil?
      puppet_environments = Katello::ContentViewPuppetEnvironment.in_environment(environments)
      puppet_environments = puppet_environments.in_content_view(content_view) if content_view
      puppet_environments
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
katello-3.17.0.rc1 app/services/katello/smart_proxy_helper.rb
katello-3.16.0 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc5.1 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc5 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc4.1 app/services/katello/smart_proxy_helper.rb
katello-3.15.3.1 app/services/katello/smart_proxy_helper.rb
katello-3.15.3 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc4 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc3.1 app/services/katello/smart_proxy_helper.rb
katello-3.15.2 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc3 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc2.1 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc2 app/services/katello/smart_proxy_helper.rb
katello-3.15.1.1 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc1.1 app/services/katello/smart_proxy_helper.rb
katello-3.15.1 app/services/katello/smart_proxy_helper.rb
katello-3.16.0.rc1 app/services/katello/smart_proxy_helper.rb
katello-3.15.0.1 app/services/katello/smart_proxy_helper.rb
katello-3.15.0 app/services/katello/smart_proxy_helper.rb
katello-3.15.0.rc2 app/services/katello/smart_proxy_helper.rb