katello 3.16.0.rc5.1 → 3.16.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of katello might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/katello/api/registry/registry_proxies_controller.rb +39 -23
- data/app/helpers/katello/content_view_helper.rb +15 -0
- data/app/lib/actions/katello/content_view/incremental_updates.rb +3 -1
- data/app/lib/actions/katello/content_view/publish.rb +55 -16
- data/app/lib/actions/katello/content_view_version/incremental_update.rb +81 -51
- data/app/lib/actions/katello/repository/multi_clone_contents.rb +66 -0
- data/app/lib/actions/katello/repository/multi_clone_to_version.rb +30 -0
- data/app/lib/actions/pulp3/abstract_async_task.rb +62 -58
- data/app/lib/actions/pulp3/content_migration.rb +4 -0
- data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +1 -2
- data/app/lib/actions/pulp3/orchestration/repository/multi_copy_all_units.rb +36 -0
- data/app/lib/actions/pulp3/repository/multi_copy_content.rb +28 -0
- data/app/lib/actions/pulp3/repository/multi_copy_units.rb +14 -7
- data/app/lib/actions/pulp3/repository/save_version.rb +11 -3
- data/app/lib/actions/pulp3/repository/save_versions.rb +47 -13
- data/app/lib/katello/errors.rb +1 -15
- data/app/models/katello/content_view.rb +18 -6
- data/app/models/katello/content_view_erratum_filter.rb +13 -0
- data/app/models/katello/content_view_module_stream_filter.rb +19 -0
- data/app/models/katello/module_stream.rb +1 -1
- data/app/services/katello/pulp3/api/core.rb +4 -0
- data/app/services/katello/pulp3/erratum.rb +3 -1
- data/app/services/katello/pulp3/migration.rb +3 -2
- data/app/services/katello/pulp3/migration_plan.rb +6 -6
- data/app/services/katello/pulp3/repository.rb +10 -1
- data/app/services/katello/pulp3/repository/yum.rb +168 -35
- data/app/services/katello/pulp3/task.rb +100 -0
- data/app/services/katello/pulp3/task_group.rb +79 -0
- data/lib/katello/version.rb +1 -1
- data/webpack/redux/actions/RedHatRepositories/helpers.js +5 -5
- metadata +17 -10
data/app/lib/katello/errors.rb
CHANGED
@@ -112,21 +112,7 @@ module Katello
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
class Pulp3Error < StandardError
|
116
|
-
def self.from_task(task)
|
117
|
-
if task[:state] == 'canceled'
|
118
|
-
self.new(_("Task canceled"))
|
119
|
-
elsif task[:state] == 'failed'
|
120
|
-
message = if task[:error][:description].blank?
|
121
|
-
_("Pulp task error")
|
122
|
-
else
|
123
|
-
task[:error][:description]
|
124
|
-
end
|
125
|
-
self.new(message)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
115
|
+
class Pulp3Error < StandardError; end
|
130
116
|
class Pulp3MigrationError < StandardError; end
|
131
117
|
|
132
118
|
class PulpError < StandardError
|
@@ -289,9 +289,21 @@ module Katello
|
|
289
289
|
where("#{Katello::ContentViewVersion.table_name}.content_view_id" => self.id)
|
290
290
|
end
|
291
291
|
|
292
|
-
def repositories_to_publish
|
292
|
+
def repositories_to_publish(override_components = nil)
|
293
293
|
if composite?
|
294
|
-
|
294
|
+
components_to_publish = []
|
295
|
+
components.each do |component|
|
296
|
+
override_component = override_components&.detect do |override_cvv|
|
297
|
+
override_cvv.content_view == component.content_view
|
298
|
+
end
|
299
|
+
|
300
|
+
if override_component
|
301
|
+
components_to_publish << override_component
|
302
|
+
else
|
303
|
+
components_to_publish << component
|
304
|
+
end
|
305
|
+
end
|
306
|
+
ids = components_to_publish.flat_map { |version| version.repositories.archived }.map(&:id)
|
295
307
|
Repository.where(:id => ids)
|
296
308
|
else
|
297
309
|
repositories
|
@@ -302,11 +314,11 @@ module Katello
|
|
302
314
|
composite? ? repositories_to_publish.pluck(&:id) : repository_ids
|
303
315
|
end
|
304
316
|
|
305
|
-
def repositories_to_publish_by_library_instance
|
317
|
+
def repositories_to_publish_by_library_instance(override_components = nil)
|
306
318
|
# retrieve the list of repositories in a hash, where the key
|
307
319
|
# is the library instance id, and the value is an array
|
308
320
|
# of the repositories for that instance.
|
309
|
-
repositories_to_publish.inject({}) do |result, repo|
|
321
|
+
repositories_to_publish(override_components).inject({}) do |result, repo|
|
310
322
|
result[repo.library_instance] ||= []
|
311
323
|
result[repo.library_instance] << repo
|
312
324
|
result
|
@@ -326,8 +338,8 @@ module Katello
|
|
326
338
|
component_composites.where(latest: true).joins(:composite_content_view).where(self.class.table_name => {auto_publish: true})
|
327
339
|
end
|
328
340
|
|
329
|
-
def publish_repositories
|
330
|
-
repositories = composite? ? repositories_to_publish_by_library_instance.values : repositories_to_publish
|
341
|
+
def publish_repositories(override_components = nil)
|
342
|
+
repositories = composite? ? repositories_to_publish_by_library_instance(override_components).values : repositories_to_publish
|
331
343
|
repositories.each do |repos|
|
332
344
|
if repos.is_a? Array
|
333
345
|
yield repos
|
@@ -30,6 +30,7 @@ module Katello
|
|
30
30
|
if filter_by_id?
|
31
31
|
errata_ids = erratum_rules.map(&:errata_id)
|
32
32
|
errata_pulp_ids = errata_package_pulp_ids_from_errata_ids(repo, errata_ids)
|
33
|
+
errata_pulp_ids += errata_module_stream_pulp_ids_from_errata_ids(errata_ids)
|
33
34
|
else
|
34
35
|
clauses = []
|
35
36
|
clauses << errata_from
|
@@ -37,7 +38,9 @@ module Katello
|
|
37
38
|
clauses << types_clause
|
38
39
|
package_filenames = Erratum.list_filenames_by_clauses(repo, clauses.compact)
|
39
40
|
errata_pulp_ids = errata_package_pulp_ids_from_package_filenames(repo, package_filenames)
|
41
|
+
errata_pulp_ids += errata_module_stream_pulp_ids_from_clauses(repo, clauses.compact)
|
40
42
|
end
|
43
|
+
|
41
44
|
errata_pulp_ids
|
42
45
|
end
|
43
46
|
|
@@ -48,10 +51,20 @@ module Katello
|
|
48
51
|
repo.rpms.where("filename ILIKE ANY ( array[?] )", query_params)
|
49
52
|
end
|
50
53
|
|
54
|
+
def errata_module_stream_pulp_ids_from_clauses(repo, clauses)
|
55
|
+
module_streams = Erratum.list_modular_streams_by_clauses(repo, clauses)
|
56
|
+
module_streams.pluck(:pulp_id)
|
57
|
+
end
|
58
|
+
|
51
59
|
def errata_package_pulp_ids_from_package_filenames(repo, package_filenames)
|
52
60
|
rpms_by_filename(repo, package_filenames).pluck(:pulp_id)
|
53
61
|
end
|
54
62
|
|
63
|
+
def errata_module_stream_pulp_ids_from_errata_ids(errata_ids)
|
64
|
+
module_streams = Katello::Erratum.where(:errata_id => errata_ids).map(&:module_streams).compact.flatten
|
65
|
+
module_streams.pluck(:pulp_id)
|
66
|
+
end
|
67
|
+
|
55
68
|
def errata_package_pulp_ids_from_errata_ids(repo, errata_ids)
|
56
69
|
package_filenames = Katello::ErratumPackage.joins(:erratum).where("#{Erratum.table_name}.errata_id" => errata_ids).pluck(:filename)
|
57
70
|
rpms_by_filename(repo, package_filenames).pluck(:pulp_id)
|
@@ -18,5 +18,24 @@ module Katello
|
|
18
18
|
def original_module_streams=(value)
|
19
19
|
self[:original_module_streams] = value
|
20
20
|
end
|
21
|
+
|
22
|
+
def content_unit_pulp_ids(repo, dependents = false)
|
23
|
+
content_unit_ids = []
|
24
|
+
module_ids = []
|
25
|
+
|
26
|
+
self.module_stream_rules.each do |rule|
|
27
|
+
module_ids << rule.module_stream_id
|
28
|
+
end
|
29
|
+
if self.original_module_streams
|
30
|
+
module_ids.concat(repo.module_streams_without_errata.map(&:id))
|
31
|
+
end
|
32
|
+
modules_streams = ModuleStream.where(id: module_ids).includes(:rpms)
|
33
|
+
content_unit_ids += modules_streams.pluck(:pulp_id).flatten.uniq
|
34
|
+
if dependents && !modules_streams.empty?
|
35
|
+
rpms = modules_streams.map(&:rpms).flatten
|
36
|
+
content_unit_ids += rpms.pluck(:pulp_id).flatten.uniq
|
37
|
+
end
|
38
|
+
content_unit_ids.uniq
|
39
|
+
end
|
21
40
|
end
|
22
41
|
end
|
@@ -65,7 +65,7 @@ module Katello
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def module_spec_hash
|
68
|
-
{:name => name, :stream => stream, :version => version, :context => context, :arch => arch, :id => id}.compact
|
68
|
+
{:name => name, :stream => stream, :version => version, :context => context, :arch => arch, :pulp_id => pulp_id, :id => id}.compact
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.parse_module_spec(module_spec)
|
@@ -26,8 +26,10 @@ module Katello
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def update_model(model)
|
29
|
-
keys = %w(title id severity
|
29
|
+
keys = %w(title id severity issued_date type description reboot_suggested solution updated_date summary)
|
30
30
|
custom_json = backend_data.slice(*keys)
|
31
|
+
custom_json["issued"] = custom_json.delete("issued_date")
|
32
|
+
custom_json["updated"] = custom_json.delete("updated_date")
|
31
33
|
|
32
34
|
# handle SUSE epoch dates
|
33
35
|
custom_json["issued"] = convert_date_if_epoch(custom_json["issued"])
|
@@ -68,8 +68,9 @@ module Katello
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def create_migrations
|
71
|
-
|
72
|
-
|
71
|
+
plan = Katello::Pulp3::MigrationPlan.new(@repository_types)
|
72
|
+
Rails.logger.info(plan)
|
73
|
+
[migration_plan_api.create(plan: plan.generate.as_json).pulp_href]
|
73
74
|
end
|
74
75
|
|
75
76
|
def start_migration(plan_href)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Katello
|
2
2
|
module Pulp3
|
3
3
|
class MigrationPlan
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(repository_type_labels)
|
5
|
+
@repository_types = repository_type_labels
|
6
6
|
end
|
7
7
|
|
8
8
|
def master_proxy
|
@@ -17,12 +17,12 @@ module Katello
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def generate_plugins
|
20
|
-
|
20
|
+
@repository_types.map do |repository_type|
|
21
21
|
{
|
22
|
-
type: pulp2_repository_type(
|
23
|
-
repositories: repository_migrations(
|
22
|
+
type: pulp2_repository_type(repository_type),
|
23
|
+
repositories: repository_migrations(repository_type)
|
24
24
|
}
|
25
|
-
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def pulp2_repository_type(repository_type)
|
@@ -193,8 +193,12 @@ module Katello
|
|
193
193
|
ignore_404_exception { api.repositories_api.delete(href) } if href
|
194
194
|
end
|
195
195
|
|
196
|
+
def sync_params
|
197
|
+
{remote: repo.remote_href, mirror: repo.root.mirror_on_sync}
|
198
|
+
end
|
199
|
+
|
196
200
|
def sync
|
197
|
-
sync_url_params =
|
201
|
+
sync_url_params = sync_params
|
198
202
|
skip_type_param = skip_types
|
199
203
|
sync_url_params[:skip_types] = skip_type_param if skip_type_param
|
200
204
|
repository_sync_url_data = api.class.repository_sync_url_class.new(sync_url_params)
|
@@ -352,6 +356,11 @@ module Katello
|
|
352
356
|
api.repositories_api.modify(repository_reference.repository_href, add_content_units: content_unit_href)
|
353
357
|
end
|
354
358
|
|
359
|
+
def add_content_for_repo(repository_href, content_unit_href)
|
360
|
+
content_unit_href = [content_unit_href] unless content_unit_href.is_a?(Array)
|
361
|
+
api.repositories_api.modify(repository_href, add_content_units: content_unit_href)
|
362
|
+
end
|
363
|
+
|
355
364
|
def unit_keys(uploads)
|
356
365
|
uploads.map do |upload|
|
357
366
|
upload.except('id')
|
@@ -31,6 +31,10 @@ module Katello
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
+
def sync_params
|
35
|
+
{remote: repo.remote_href, mirror: repo.root.mirror_on_sync, optimize: false}
|
36
|
+
end
|
37
|
+
|
34
38
|
def mirror_remote_options
|
35
39
|
policy = smart_proxy.download_policy
|
36
40
|
|
@@ -70,48 +74,79 @@ module Katello
|
|
70
74
|
"/pulp/repos/#{repo.relative_path}/".sub('//', '/')
|
71
75
|
end
|
72
76
|
|
73
|
-
def
|
74
|
-
additional_repo_map = {})
|
77
|
+
def multi_copy_units(repo_id_map, dependency_solving)
|
75
78
|
tasks = []
|
76
79
|
|
77
|
-
content_unit_hrefs.
|
78
|
-
|
80
|
+
if repo_id_map.values.pluck(:content_unit_hrefs).flatten.any?
|
81
|
+
data = PulpRpmClient::Copy.new
|
82
|
+
data.dependency_solving = dependency_solving
|
83
|
+
data.config = []
|
84
|
+
repo_id_map.each do |source_repo_ids, dest_repo_id_map|
|
85
|
+
dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
|
86
|
+
dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
|
87
|
+
content_unit_hrefs = dest_repo_id_map[:content_unit_hrefs]
|
88
|
+
# Not needed during incremental update due to dest_base_version
|
89
|
+
unless dest_repo_id_map[:base_version]
|
90
|
+
source_repo_for_package_envs = ::Katello::Repository.find(source_repo_ids.first)
|
91
|
+
unless source_repo_for_package_envs.library_instance?
|
92
|
+
source_repo_for_package_envs = source_repo_for_package_envs.library_instance
|
93
|
+
end
|
94
|
+
package_env_hrefs = packageenvironments({ :repository_version => source_repo_for_package_envs.version_href }).map(&:pulp_href).sort
|
95
|
+
tasks << remove_all_content_from_repo(dest_repo_href)
|
96
|
+
tasks << add_content_for_repo(dest_repo_href, package_env_hrefs) unless package_env_hrefs.empty?
|
97
|
+
end
|
98
|
+
source_repo_ids.each do |source_repo_id|
|
99
|
+
source_repo_version = ::Katello::Repository.find(source_repo_id).version_href
|
100
|
+
config = { source_repo_version: source_repo_version, dest_repo: dest_repo_href, content: content_unit_hrefs }
|
101
|
+
config[:dest_base_version] = dest_repo_id_map[:base_version] if dest_repo_id_map[:base_version]
|
102
|
+
data.config << config
|
103
|
+
end
|
104
|
+
end
|
105
|
+
# FIXME: data's content being [] causes all content to be copied back
|
106
|
+
tasks << api.copy_api.copy_content(data)
|
107
|
+
else
|
108
|
+
tasks << remove_all_content_from_mapping(repo_id_map)
|
109
|
+
end
|
110
|
+
tasks.flatten
|
111
|
+
end
|
112
|
+
|
113
|
+
def remove_all_content_from_mapping(repo_id_map)
|
114
|
+
tasks = []
|
115
|
+
repo_id_map.each do |_source_repo_ids, dest_repo_id_map|
|
116
|
+
dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
|
117
|
+
dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
|
118
|
+
tasks << remove_all_content_from_repo(dest_repo_href)
|
119
|
+
end
|
120
|
+
tasks
|
121
|
+
end
|
122
|
+
|
123
|
+
def copy_units(source_repository, content_unit_hrefs, dependency_solving)
|
124
|
+
tasks = []
|
125
|
+
|
126
|
+
if content_unit_hrefs.sort!.any?
|
79
127
|
data = PulpRpmClient::Copy.new
|
80
128
|
data.config = [{
|
81
129
|
source_repo_version: source_repository.version_href,
|
82
130
|
dest_repo: repository_reference.repository_href,
|
83
|
-
dest_base_version:
|
131
|
+
dest_base_version: 0,
|
84
132
|
content: content_unit_hrefs
|
85
133
|
}]
|
86
134
|
data.dependency_solving = dependency_solving
|
87
|
-
|
88
|
-
# repo_map example: {
|
89
|
-
# <source_repo_id>: {
|
90
|
-
# dest_repo: <dest_repo_id>,
|
91
|
-
# base_version: <base_version>
|
92
|
-
# }
|
93
|
-
# }
|
94
|
-
additional_repo_map.each do |source_repo, dest_repo_map|
|
95
|
-
source_repo_version = ::Katello::Repository.find(source_repo).version_href
|
96
|
-
|
97
|
-
dest_repo = ::Katello::Repository.find(dest_repo_map[:dest_repo])
|
98
|
-
dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
|
99
|
-
data.config << {
|
100
|
-
source_repo_version: source_repo_version,
|
101
|
-
dest_repo: dest_repo_href,
|
102
|
-
dest_base_version: dest_repo_map[:base_version],
|
103
|
-
content: content_unit_hrefs
|
104
|
-
}
|
105
|
-
end
|
106
|
-
end
|
135
|
+
package_env_hrefs = packageenvironments({ :repository_version => source_repository.version_href }).map(&:pulp_href).sort
|
107
136
|
tasks << api.copy_api.copy_content(data)
|
137
|
+
tasks << add_content(package_env_hrefs) unless package_env_hrefs.empty?
|
108
138
|
else
|
109
139
|
tasks << remove_all_content
|
110
140
|
end
|
111
|
-
|
112
141
|
tasks
|
113
142
|
end
|
114
143
|
|
144
|
+
def remove_all_content_from_repo(repo_href)
|
145
|
+
data = PulpRpmClient::RepositoryAddRemoveContent.new(
|
146
|
+
remove_content_units: ['*'])
|
147
|
+
api.repositories_api.modify(repo_href, data)
|
148
|
+
end
|
149
|
+
|
115
150
|
def remove_all_content
|
116
151
|
data = PulpRpmClient::RepositoryAddRemoveContent.new(
|
117
152
|
remove_content_units: ['*'])
|
@@ -119,7 +154,7 @@ module Katello
|
|
119
154
|
end
|
120
155
|
|
121
156
|
def packageenvironments(options = {})
|
122
|
-
api.content_package_environments_api.list(options)
|
157
|
+
Katello::Pulp3::Api::Core.fetch_from_list { |page_opts| api.content_package_environments_api.list(page_opts.merge(options)) }
|
123
158
|
end
|
124
159
|
|
125
160
|
def metadatafiles(options = {})
|
@@ -130,6 +165,94 @@ module Katello
|
|
130
165
|
api.content_distribution_trees_api.list(options)
|
131
166
|
end
|
132
167
|
|
168
|
+
def add_filter_content(source_repo_ids, filters, filter_list_map)
|
169
|
+
filters.each do |filter|
|
170
|
+
if filter.inclusion
|
171
|
+
source_repo_ids.each do |repo_id|
|
172
|
+
filter_list_map[:whitelist_ids] += filter.content_unit_pulp_ids(::Katello::Repository.find(repo_id))
|
173
|
+
end
|
174
|
+
else
|
175
|
+
source_repo_ids.each do |repo_id|
|
176
|
+
filter_list_map[:blacklist_ids] += filter.content_unit_pulp_ids(::Katello::Repository.find(repo_id))
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
filter_list_map
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_un_modular_rpms(source_repo_ids, filters, filter_list_map)
|
184
|
+
if (filter_list_map[:whitelist_ids].empty? && filters.select { |filter| filter.inclusion }.empty?)
|
185
|
+
filter_list_map[:whitelist_ids] += source_repo_ids.collect do |source_repo_id|
|
186
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
187
|
+
source_repo.rpms.where(:modular => false).pluck(:pulp_id).sort
|
188
|
+
end
|
189
|
+
end
|
190
|
+
filter_list_map
|
191
|
+
end
|
192
|
+
|
193
|
+
def add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
|
194
|
+
inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
|
195
|
+
exclusion_modular_filters = modular_filters - inclusion_modular_filters
|
196
|
+
if inclusion_modular_filters.empty? &&
|
197
|
+
!(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
|
198
|
+
source_repo_ids.each do |source_repo_id|
|
199
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
200
|
+
filter_list_map[:whitelist_ids] += source_repo.rpms.where(:modular => true).pluck(:pulp_id).sort
|
201
|
+
filter_list_map[:whitelist_ids] += source_repo.module_streams.pluck(:pulp_id).sort
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
unless inclusion_modular_filters.empty?
|
206
|
+
filter_list_map[:whitelist_ids] += source_repo_ids.collect do |source_repo_id|
|
207
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
208
|
+
modular_packages(source_repo, inclusion_modular_filters)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
unless exclusion_modular_filters.empty?
|
213
|
+
filter_list_map[:blacklist_ids] += source_repo_ids.collect do |source_repo_id|
|
214
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
215
|
+
modular_packages(source_repo, exclusion_modular_filters)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
filter_list_map
|
220
|
+
end
|
221
|
+
|
222
|
+
def copy_content_from_mapping(repo_id_map, options = {})
|
223
|
+
repo_id_map.each do |source_repo_ids, dest_repo_map|
|
224
|
+
filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
|
225
|
+
filter_class.where(:id => dest_repo_map[:filter_ids])
|
226
|
+
end
|
227
|
+
modular_filters = ContentViewModuleStreamFilter.where(:id => dest_repo_map[:filter_ids])
|
228
|
+
filters.flatten!.compact!
|
229
|
+
|
230
|
+
filter_list_map = { whitelist_ids: [], blacklist_ids: [] }
|
231
|
+
filter_list_map = add_filter_content(source_repo_ids, filters, filter_list_map)
|
232
|
+
filter_list_map = add_un_modular_rpms(source_repo_ids, filters, filter_list_map)
|
233
|
+
filter_list_map = add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
|
234
|
+
|
235
|
+
whitelist_ids = filter_list_map[:whitelist_ids].flatten&.uniq
|
236
|
+
blacklist_ids = filter_list_map[:blacklist_ids].flatten&.uniq
|
237
|
+
content_unit_hrefs = whitelist_ids - blacklist_ids
|
238
|
+
|
239
|
+
if content_unit_hrefs.any?
|
240
|
+
source_repo_ids.each do |source_repo_id|
|
241
|
+
content_unit_hrefs += additional_content_hrefs(::Katello::Repository.find(source_repo_id), content_unit_hrefs)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
source_repo_ids.each do |source_repo_id|
|
245
|
+
content_unit_hrefs += ::Katello::Repository.find(source_repo_id).srpms.pluck(:pulp_id)
|
246
|
+
end
|
247
|
+
|
248
|
+
dest_repo_map[:content_unit_hrefs] = content_unit_hrefs.uniq.sort
|
249
|
+
end
|
250
|
+
|
251
|
+
dependency_solving = options[:solve_dependencies] || false
|
252
|
+
|
253
|
+
multi_copy_units(repo_id_map, dependency_solving)
|
254
|
+
end
|
255
|
+
|
133
256
|
def copy_content_for_source(source_repository, options = {})
|
134
257
|
filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
|
135
258
|
filter_class.where(:id => options[:filter_ids])
|
@@ -147,12 +270,18 @@ module Katello
|
|
147
270
|
end
|
148
271
|
end
|
149
272
|
|
150
|
-
if whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?
|
151
|
-
whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort
|
152
|
-
end
|
273
|
+
whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort if (whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?)
|
153
274
|
|
275
|
+
modular_filters = ContentViewModuleStreamFilter.where(:id => options[:filter_ids])
|
276
|
+
inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
|
277
|
+
exclusion_modular_filters = modular_filters - inclusion_modular_filters
|
278
|
+
if inclusion_modular_filters.empty? && !(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
|
279
|
+
whitelist_ids += source_repository.rpms.where(:modular => true).pluck(:pulp_id).sort
|
280
|
+
whitelist_ids += source_repository.module_streams.pluck(:pulp_id).sort
|
281
|
+
end
|
282
|
+
whitelist_ids += modular_packages(source_repository, inclusion_modular_filters) unless inclusion_modular_filters.empty?
|
283
|
+
blacklist_ids += modular_packages(source_repository, exclusion_modular_filters) unless exclusion_modular_filters.empty?
|
154
284
|
content_unit_hrefs = whitelist_ids - blacklist_ids
|
155
|
-
|
156
285
|
if content_unit_hrefs.any?
|
157
286
|
content_unit_hrefs += additional_content_hrefs(source_repository, content_unit_hrefs)
|
158
287
|
end
|
@@ -162,6 +291,14 @@ module Katello
|
|
162
291
|
copy_units(source_repository, content_unit_hrefs.uniq, dependency_solving)
|
163
292
|
end
|
164
293
|
|
294
|
+
def modular_packages(source_repository, filters)
|
295
|
+
list_ids = []
|
296
|
+
filters.each do |filter|
|
297
|
+
list_ids += filter.content_unit_pulp_ids(source_repository, true)
|
298
|
+
end
|
299
|
+
list_ids
|
300
|
+
end
|
301
|
+
|
165
302
|
def additional_content_hrefs(source_repository, content_unit_hrefs)
|
166
303
|
repo_service = source_repository.backend_service(SmartProxy.pulp_master)
|
167
304
|
options = { :repository_version => source_repository.version_href }
|
@@ -172,10 +309,6 @@ module Katello
|
|
172
309
|
package_groups_to_include = filter_package_groups_by_pulp_href(source_repository.package_groups, content_unit_hrefs)
|
173
310
|
content_unit_hrefs += package_groups_to_include.pluck(:pulp_id)
|
174
311
|
|
175
|
-
package_environment_hrefs_to_include = filter_package_environments_by_pulp_hrefs(
|
176
|
-
repo_service.packageenvironments(options).results, package_groups_to_include.pluck(:pulp_id))
|
177
|
-
content_unit_hrefs += package_environment_hrefs_to_include
|
178
|
-
|
179
312
|
metadata_file_hrefs_to_include = filter_metadatafiles_by_pulp_hrefs(
|
180
313
|
repo_service.metadatafiles(options).results, content_unit_hrefs)
|
181
314
|
content_unit_hrefs += metadata_file_hrefs_to_include
|