Class: Katello::SmartProxyHelper

Inherits:
Object
  • Object
show all
Defined in:
app/services/katello/smart_proxy_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(smart_proxy) ⇒ SmartProxyHelper

Returns a new instance of SmartProxyHelper.



4
5
6
# File 'app/services/katello/smart_proxy_helper.rb', line 4

def initialize(smart_proxy)
  @smart_proxy = smart_proxy
end

Instance Attribute Details

#smart_proxyObject

Returns the value of attribute smart_proxy.



3
4
5
# File 'app/services/katello/smart_proxy_helper.rb', line 3

def smart_proxy
  @smart_proxy
end

Instance Method Details

#==(other) ⇒ Object



8
9
10
# File 'app/services/katello/smart_proxy_helper.rb', line 8

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

#clear_smart_proxy_sync_histories(repo_list = []) ⇒ Object



24
25
26
27
28
29
30
31
# File 'app/services/katello/smart_proxy_helper.rb', line 24

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

#combined_repos_available_to_capsule(environment = nil, content_view = nil, repository = nil) ⇒ Object



33
34
35
36
37
38
39
40
# File 'app/services/katello/smart_proxy_helper.rb', line 33

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

#default_capsule?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/services/katello/smart_proxy_helper.rb', line 12

def default_capsule?
  @smart_proxy.pulp_primary?
end

#lifecycle_environment_check(environment = nil, repository = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'app/services/katello/smart_proxy_helper.rb', line 16

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

#repositories_available_to_capsule(environments = nil, content_view = nil) ⇒ Object



42
43
44
45
46
47
# File 'app/services/katello/smart_proxy_helper.rb', line 42

def repositories_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.smart_proxy_syncable
end

#unsyncable_content_typesObject



49
50
51
52
53
54
55
56
# File 'app/services/katello/smart_proxy_helper.rb', line 49

def unsyncable_content_types
  unsyncable_content_types = ::Katello::RepositoryTypeManager.defined_repository_types.keys.collect do |type_name|
    unless @smart_proxy.capabilities(::SmartProxy::PULP3_FEATURE).include?(::Katello::RepositoryTypeManager.defined_repository_types[type_name].pulp3_plugin)
      type_name
    end
  end
  unsyncable_content_types.compact & repositories_available_to_capsule.map(&:content_type)
end