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.



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

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



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

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

#clear_smart_proxy_sync_histories(repo_list = []) ⇒ Object



30
31
32
33
34
35
36
37
# File 'app/services/katello/smart_proxy_helper.rb', line 30

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



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

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

#default_capsule?Boolean

Returns:

  • (Boolean)


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

def default_capsule?
  @smart_proxy.pulp_primary?
end

#library_export_repo(repository = nil) ⇒ Object



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

def library_export_repo(repository = nil)
  cv = repository.content_view if repository
  cv.library_export?
end

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



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

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



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

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

#unsyncable_content_typesObject



55
56
57
58
59
60
61
62
# File 'app/services/katello/smart_proxy_helper.rb', line 55

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