Class: Katello::Pulp3::SmartProxyMirrorRepository
Instance Attribute Summary
#smart_proxy
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #current_repositories, #delete_orphan_repository_versions, instance_for_type, #orphan_repositories, #pulp3_enabled_repo_types
Constructor Details
Returns a new instance of SmartProxyMirrorRepository.
4
5
6
7
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 4
def initialize(smart_proxy)
fail "Cannot use a central pulp smart proxy" if smart_proxy.pulp_primary?
@smart_proxy = smart_proxy
end
|
Class Method Details
.orphan_distribution?(distribution) ⇒ Boolean
70
71
72
73
74
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 70
def self.orphan_distribution?(distribution)
distribution.try(:publication).nil? &&
distribution.try(:repository).nil? &&
distribution.try(:repository_version).nil?
end
|
Instance Method Details
#delete_orphan_alternate_content_sources ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 76
def delete_orphan_alternate_content_sources
tasks = []
known_acs_hrefs = []
known_acss = smart_proxy.smart_proxy_alternate_content_sources
known_acs_hrefs = known_acss.pluck(:alternate_content_source_href) if known_acss.present?
file_acs_api = ::Katello::Pulp3::Repository.api(smart_proxy, 'file').alternate_content_source_api
yum_acs_api = ::Katello::Pulp3::Repository.api(smart_proxy, 'yum').alternate_content_source_api
orphan_file_acs_hrefs = file_acs_api.list.results.map(&:pulp_href) - known_acs_hrefs
orphan_yum_acs_hrefs = yum_acs_api.list.results.map(&:pulp_href) - known_acs_hrefs
orphan_file_acs_hrefs.each do |orphan_file_acs_href|
tasks << file_acs_api.delete(orphan_file_acs_href)
end
orphan_yum_acs_hrefs.each do |orphan_yum_acs_href|
tasks << yum_acs_api.delete(orphan_yum_acs_href)
end
end
|
#delete_orphan_distributions ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 52
def delete_orphan_distributions
tasks = []
pulp3_enabled_repo_types.each do |repo_type|
orphan_distributions(repo_type).each do |distribution|
tasks << repo_type.pulp3_api(smart_proxy).delete_distribution(distribution.pulp_href)
end
end
tasks
end
|
#delete_orphan_remotes ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 97
def delete_orphan_remotes
tasks = []
smart_proxy_helper = ::Katello::SmartProxyHelper.new(smart_proxy)
repo_names = smart_proxy_helper.combined_repos_available_to_capsule.map(&:pulp_id)
acs_remotes = Katello::SmartProxyAlternateContentSource.pluck(:remote_href)
pulp3_enabled_repo_types.each do |repo_type|
api = repo_type.pulp3_api(smart_proxy)
remotes = api.remotes_list
remotes.each do |remote|
if !repo_names.include?(remote.name) && !acs_remotes.include?(remote.pulp_href)
tasks << api.delete_remote(remote.pulp_href)
end
end
end
tasks
end
|
#delete_orphan_repositories ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 40
def delete_orphan_repositories
tasks = []
orphaned_repositories.each do |api, pulp3_repo_list|
tasks << pulp3_repo_list.collect do |repo|
api.repositories_api.delete(repo.pulp_href)
end
end
tasks.flatten!
end
|
#orphan_distributions(repo_type) ⇒ Object
62
63
64
65
66
67
68
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 62
def orphan_distributions(repo_type)
api = repo_type.pulp3_api(smart_proxy)
api.distributions_list_all.select do |distribution|
dist = api.get_distribution(distribution.pulp_href)
self.class.orphan_distribution?(dist)
end
end
|
#orphan_repository_versions ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 22
def orphan_repository_versions
repo_version_map = {}
pulp3_enabled_repo_types.each do |repo_type|
api = repo_type.pulp3_api(smart_proxy)
version_hrefs = api.repository_versions
orphan_version_hrefs = api.list_all.collect do |pulp_repo|
mirror_repo_versions = api.versions_list_for_repository(pulp_repo.pulp_href, ordering: ['-pulp_created'])
version_hrefs = mirror_repo_versions.select { |repo_version| repo_version.number != 0 }.collect { |version| version.pulp_href }
version_hrefs - [pulp_repo.latest_version_href]
end
repo_version_map[api] = orphan_version_hrefs.flatten
end
repo_version_map
end
|
#orphaned_repositories ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/services/katello/pulp3/smart_proxy_mirror_repository.rb', line 9
def orphaned_repositories
repo_map = {}
smart_proxy_helper = ::Katello::SmartProxyHelper.new(smart_proxy)
katello_pulp_ids = smart_proxy_helper.combined_repos_available_to_capsule.map(&:pulp_id)
pulp3_enabled_repo_types.each do |repo_type|
api = repo_type.pulp3_api(smart_proxy)
repo_map[api] = api.list_all.reject { |capsule_repo| katello_pulp_ids.include? capsule_repo.name }
end
repo_map
end
|