Sha256: d2a1c3a16825853256407ffe620ed32ea113fe0f147d32d7b3f3ecbc4cc8276d

Contents?: true

Size: 1.73 KB

Versions: 8

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_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 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) + puppet_environments_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

    def puppet_environments_available_to_capsule(environments, content_view)
      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

8 entries across 8 versions & 1 rubygems

Version Path
katello-3.17.3 app/services/katello/smart_proxy_helper.rb
katello-3.17.2 app/services/katello/smart_proxy_helper.rb
katello-3.17.1 app/services/katello/smart_proxy_helper.rb
katello-3.17.0 app/services/katello/smart_proxy_helper.rb
katello-3.18.0.rc1 app/services/katello/smart_proxy_helper.rb
katello-3.17.0.rc2.2 app/services/katello/smart_proxy_helper.rb
katello-3.17.0.rc2.1 app/services/katello/smart_proxy_helper.rb
katello-3.17.0.rc2 app/services/katello/smart_proxy_helper.rb