katello 3.16.0.rc4 → 3.16.1
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/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +3 -3
- data/app/controllers/katello/api/v2/api_controller.rb +1 -0
- data/app/controllers/katello/api/v2/content_view_filters_controller.rb +5 -1
- data/app/controllers/katello/api/v2/content_view_versions_controller.rb +3 -0
- data/app/controllers/katello/api/v2/content_views_controller.rb +7 -0
- data/app/controllers/katello/api/v2/host_tracer_controller.rb +0 -5
- data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +15 -0
- data/app/controllers/katello/api/v2/repositories_controller.rb +10 -1
- data/app/controllers/katello/concerns/api/v2/associations_permission_check.rb +67 -0
- data/app/controllers/katello/concerns/hosts_controller_extensions.rb +11 -5
- data/app/helpers/katello/content_view_helper.rb +15 -0
- data/app/lib/actions/katello/capsule_content/refresh_repos.rb +5 -1
- data/app/lib/actions/katello/capsule_content/sync.rb +3 -6
- data/app/lib/actions/katello/capsule_content/sync_capsule.rb +31 -17
- data/app/lib/actions/katello/content_view/incremental_updates.rb +8 -1
- data/app/lib/actions/katello/content_view/presenters/incremental_updates_presenter.rb +2 -1
- data/app/lib/actions/katello/content_view/publish.rb +55 -16
- data/app/lib/actions/katello/content_view_version/incremental_update.rb +120 -26
- data/app/lib/actions/katello/host/attach_subscriptions.rb +5 -1
- data/app/lib/actions/katello/product/destroy.rb +25 -4
- data/app/lib/actions/katello/repository/destroy.rb +5 -1
- data/app/lib/actions/katello/repository/multi_clone_contents.rb +62 -0
- data/app/lib/actions/katello/repository/multi_clone_to_version.rb +30 -0
- data/app/lib/actions/katello/repository/sync.rb +35 -25
- data/app/lib/actions/katello/repository/update.rb +11 -16
- data/app/lib/actions/katello/repository/verify_checksum.rb +28 -0
- data/app/lib/actions/katello/sync_plan/run.rb +1 -1
- data/app/lib/actions/pulp/abstract_async_task.rb +1 -0
- data/app/lib/actions/pulp/consumer/sync_capsule.rb +8 -0
- data/app/lib/actions/pulp/orchestration/repository/sync.rb +2 -1
- data/app/lib/actions/pulp/repository/presenters/deb_presenter.rb +2 -2
- data/app/lib/actions/pulp/repository/sync.rb +2 -1
- data/app/lib/actions/pulp3/abstract_async_task.rb +62 -58
- data/app/lib/actions/pulp3/capsule_content/refresh_content_guard.rb +17 -0
- data/app/lib/actions/pulp3/capsule_content/sync.rb +3 -1
- data/app/lib/actions/pulp3/{ContentGuard → content_guard}/refresh.rb +0 -0
- data/app/lib/actions/pulp3/content_migration.rb +4 -0
- data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +2 -4
- data/app/lib/actions/pulp3/orchestration/repository/multi_copy_all_units.rb +36 -0
- data/app/lib/actions/pulp3/orchestration/repository/sync.rb +3 -1
- data/app/lib/actions/pulp3/orchestration/repository/trigger_update_repo_cert_guard.rb +22 -0
- data/app/lib/actions/pulp3/repository/copy_content.rb +0 -1
- data/app/lib/actions/pulp3/repository/multi_copy_content.rb +28 -0
- data/app/lib/actions/pulp3/repository/multi_copy_units.rb +55 -0
- data/app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb +1 -1
- data/app/lib/actions/pulp3/repository/presenters/repair_presenter.rb +85 -0
- data/app/lib/actions/pulp3/repository/repair.rb +29 -0
- data/app/lib/actions/pulp3/repository/save_version.rb +20 -8
- data/app/lib/actions/pulp3/repository/save_versions.rb +73 -0
- data/app/lib/actions/pulp3/repository/sync.rb +1 -1
- data/app/lib/actions/pulp3/repository/update_cv_repository_cert_guard.rb +6 -2
- data/app/lib/actions/pulp3/repository/upload_file.rb +1 -1
- data/app/lib/katello/concerns/base_template_scope_extensions.rb +4 -14
- data/app/lib/katello/errors.rb +1 -15
- data/app/lib/katello/resources/cdn.rb +3 -2
- data/app/lib/katello/util/cdn_var_substitutor.rb +9 -6
- data/app/models/katello/concerns/smart_proxy_extensions.rb +14 -3
- 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_filter.rb +4 -0
- data/app/models/katello/content_view_module_stream_filter.rb +30 -3
- data/app/models/katello/content_view_package_filter.rb +1 -1
- data/app/models/katello/glue/pulp/repo.rb +1 -0
- data/app/models/katello/host/content_facet.rb +11 -5
- data/app/models/katello/module_stream.rb +1 -1
- data/app/models/katello/ping.rb +1 -3
- data/app/models/katello/repository.rb +16 -0
- data/app/models/setting/content.rb +3 -1
- data/app/presenters/katello/sync_status_presenter.rb +4 -2
- data/app/services/cert/certs.rb +10 -2
- data/app/services/katello/pulp/repository/yum.rb +2 -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 +9 -4
- data/app/services/katello/pulp3/migration_plan.rb +6 -6
- data/app/services/katello/pulp3/repository.rb +13 -5
- data/app/services/katello/pulp3/repository/yum.rb +246 -25
- data/app/services/katello/pulp3/repository_mirror.rb +7 -2
- data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +1 -1
- data/app/services/katello/pulp3/task.rb +100 -0
- data/app/services/katello/pulp3/task_group.rb +79 -0
- data/app/services/katello/smart_proxy_helper.rb +13 -16
- data/app/views/katello/api/v2/content_view_filters/base.json.rabl +4 -0
- data/config/routes/api/rhsm.rb +1 -0
- data/config/routes/api/v2.rb +2 -0
- data/db/migrate/20200709021250_add_original_modules_to_content_view_module_stream_filter.rb +5 -0
- data/db/migrate/20200721142707_remove_duplicate_katello_pools_index.rb +5 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.routes.js +1 -13
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/filter-details.controller.js +17 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/module-stream-filter-details.html +17 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/errata.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/product-bulk-action.factory.js +1 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details.controller.js +6 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-details.html +7 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repository.factory.js +1 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +15 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/views/products.html +6 -0
- data/engines/bastion_katello/app/assets/stylesheets/bastion_katello/bastion_katello.scss +4 -0
- data/lib/katello/engine.rb +0 -1
- data/lib/katello/permission_creator.rb +2 -2
- data/lib/katello/plugin.rb +2 -1
- data/lib/katello/tasks/reports.rake +16 -0
- data/lib/katello/version.rb +1 -1
- data/webpack/redux/actions/RedHatRepositories/helpers.js +6 -6
- metadata +37 -14
- data/app/lib/actions/katello/repository/update_cv_repo_cert_guard.rb +0 -17
@@ -19,6 +19,8 @@ module Katello
|
|
19
19
|
def sync_progress
|
20
20
|
return {:state => nil} unless @repo
|
21
21
|
return empty_task(@repo) unless @task
|
22
|
+
display_output = @task.humanized[:output]
|
23
|
+
display_output = display_output.split("\n")[0] if (display_output && @repo.version_href)
|
22
24
|
{
|
23
25
|
:id => @repo.id,
|
24
26
|
:product_id => @repo.product.id,
|
@@ -29,8 +31,8 @@ module Katello
|
|
29
31
|
:start_time => format_date(@task.started_at),
|
30
32
|
:finish_time => format_date(@task.ended_at),
|
31
33
|
:duration => format_duration(@task.ended_at, @task.started_at),
|
32
|
-
:display_size =>
|
33
|
-
:size =>
|
34
|
+
:display_size => display_output,
|
35
|
+
:size => display_output,
|
34
36
|
:is_running => @task.pending && @task.state != 'paused',
|
35
37
|
:error_details => @task.errors
|
36
38
|
}
|
data/app/services/cert/certs.rb
CHANGED
@@ -9,11 +9,19 @@ module Cert
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.ssl_client_cert
|
12
|
-
@ssl_client_cert ||= OpenSSL::X509::Certificate.new(File.open(
|
12
|
+
@ssl_client_cert ||= OpenSSL::X509::Certificate.new(File.open(ssl_client_cert_filename, 'r').read)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.ssl_client_cert_filename
|
16
|
+
Setting['pulp_client_cert']
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.ssl_client_key
|
16
|
-
@ssl_client_key ||= OpenSSL::PKey::RSA.new(File.open(
|
20
|
+
@ssl_client_key ||= OpenSSL::PKey::RSA.new(File.open(ssl_client_key_filename, 'r').read)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.ssl_client_key_filename
|
24
|
+
Setting['pulp_client_key']
|
17
25
|
end
|
18
26
|
|
19
27
|
def self.verify_ueber_cert(organization)
|
@@ -246,7 +246,8 @@ module Katello
|
|
246
246
|
remove = clause_gen.remove_clause
|
247
247
|
remove_clauses = {filters: {unit: remove}} if remove
|
248
248
|
else
|
249
|
-
|
249
|
+
non_modular_rpms = ::Katello::Rpm.in_repositories(repo).non_modular.pluck(:filename)
|
250
|
+
copy_clauses = non_modular_rpms.blank? ? nil : {filters: {unit: ContentViewPackageFilter.generate_rpm_clauses(non_modular_rpms)}}
|
250
251
|
remove_clauses = nil
|
251
252
|
end
|
252
253
|
|
@@ -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"])
|
@@ -35,11 +35,15 @@ module Katello
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def pulp2_content_api
|
38
|
-
Pulp2to3MigrationClient::
|
38
|
+
Pulp2to3MigrationClient::Pulp2ContentApi.new(api_client)
|
39
|
+
rescue NameError
|
40
|
+
Pulp2to3MigrationClient::Pulp2contentApi.new(api_client) #backwards compatible
|
39
41
|
end
|
40
42
|
|
41
43
|
def pulp2_repositories_api
|
42
|
-
Pulp2to3MigrationClient::
|
44
|
+
Pulp2to3MigrationClient::Pulp2RepositoriesApi.new(api_client)
|
45
|
+
rescue NameError
|
46
|
+
Pulp2to3MigrationClient::Pulp2repositoriesApi.new(api_client) #backwards compatible
|
43
47
|
end
|
44
48
|
|
45
49
|
def create_and_run_migrations
|
@@ -64,8 +68,9 @@ module Katello
|
|
64
68
|
end
|
65
69
|
|
66
70
|
def create_migrations
|
67
|
-
|
68
|
-
|
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]
|
69
74
|
end
|
70
75
|
|
71
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,14 +193,17 @@ module Katello
|
|
193
193
|
ignore_404_exception { api.repositories_api.delete(href) } if href
|
194
194
|
end
|
195
195
|
|
196
|
-
def sync
|
197
|
-
|
198
|
-
skip_type_param = skip_types
|
199
|
-
sync_url_params[:skip_types] = skip_type_param if skip_type_param
|
200
|
-
repository_sync_url_data = api.class.repository_sync_url_class.new(sync_url_params)
|
196
|
+
def sync(options = {})
|
197
|
+
repository_sync_url_data = api.class.repository_sync_url_class.new(sync_url_params(options))
|
201
198
|
[api.repositories_api.sync(repository_reference.repository_href, repository_sync_url_data)]
|
202
199
|
end
|
203
200
|
|
201
|
+
def sync_url_params(_sync_options)
|
202
|
+
params = {remote: repo.remote_href, mirror: repo.root.mirror_on_sync}
|
203
|
+
params[:skip_types] = skip_types if skip_types
|
204
|
+
params
|
205
|
+
end
|
206
|
+
|
204
207
|
def create_publication
|
205
208
|
publication_data = api.class.publication_class.new(repository_version: repo.version_href)
|
206
209
|
api.publications_api.create(publication_data)
|
@@ -352,6 +355,11 @@ module Katello
|
|
352
355
|
api.repositories_api.modify(repository_reference.repository_href, add_content_units: content_unit_href)
|
353
356
|
end
|
354
357
|
|
358
|
+
def add_content_for_repo(repository_href, content_unit_href)
|
359
|
+
content_unit_href = [content_unit_href] unless content_unit_href.is_a?(Array)
|
360
|
+
api.repositories_api.modify(repository_href, add_content_units: content_unit_href)
|
361
|
+
end
|
362
|
+
|
355
363
|
def unit_keys(uploads)
|
356
364
|
uploads.map do |upload|
|
357
365
|
upload.except('id')
|
@@ -3,10 +3,13 @@ require 'pulp_rpm_client'
|
|
3
3
|
module Katello
|
4
4
|
module Pulp3
|
5
5
|
class Repository
|
6
|
+
# rubocop:disable Metrics/ClassLength
|
6
7
|
class Yum < ::Katello::Pulp3::Repository
|
7
8
|
include Katello::Util::Errata
|
8
9
|
include Katello::Util::PulpcoreContentFilters
|
9
10
|
|
11
|
+
UNIT_LIMIT = 10_000
|
12
|
+
|
10
13
|
def remote_options
|
11
14
|
if root.url.blank?
|
12
15
|
common_remote_options.merge(url: nil, policy: root.download_policy)
|
@@ -59,6 +62,12 @@ module Katello
|
|
59
62
|
end
|
60
63
|
end
|
61
64
|
|
65
|
+
def sync_url_params(sync_options)
|
66
|
+
params = super
|
67
|
+
params[:optimize] = sync_options[:optimize] if sync_options.key?(:optimize)
|
68
|
+
params
|
69
|
+
end
|
70
|
+
|
62
71
|
def self.distribution_bootable?(distribution)
|
63
72
|
file_paths = distribution.results.first.images.map(&:path)
|
64
73
|
file_paths.any? do |path|
|
@@ -70,30 +79,149 @@ module Katello
|
|
70
79
|
"/pulp/repos/#{repo.relative_path}/".sub('//', '/')
|
71
80
|
end
|
72
81
|
|
73
|
-
def
|
82
|
+
def multi_copy_units(repo_id_map, dependency_solving)
|
74
83
|
tasks = []
|
75
84
|
|
76
|
-
if content_unit_hrefs.any?
|
85
|
+
if repo_id_map.values.pluck(:content_unit_hrefs).flatten.any?
|
77
86
|
data = PulpRpmClient::Copy.new
|
78
|
-
data.
|
79
|
-
|
87
|
+
data.dependency_solving = dependency_solving
|
88
|
+
data.config = []
|
89
|
+
repo_id_map.each do |source_repo_ids, dest_repo_id_map|
|
90
|
+
dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
|
91
|
+
dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
|
92
|
+
content_unit_hrefs = dest_repo_id_map[:content_unit_hrefs]
|
93
|
+
# Not needed during incremental update due to dest_base_version
|
94
|
+
unless dest_repo_id_map[:base_version]
|
95
|
+
source_repo_for_package_envs = ::Katello::Repository.find(source_repo_ids.first)
|
96
|
+
unless source_repo_for_package_envs.library_instance?
|
97
|
+
source_repo_for_package_envs = source_repo_for_package_envs.library_instance
|
98
|
+
end
|
99
|
+
package_env_hrefs = packageenvironments({ :repository_version => source_repo_for_package_envs.version_href }).map(&:pulp_href).sort
|
100
|
+
tasks << remove_all_content_from_repo(dest_repo_href)
|
101
|
+
tasks << add_content_for_repo(dest_repo_href, package_env_hrefs) unless package_env_hrefs.empty?
|
102
|
+
end
|
103
|
+
source_repo_ids.each do |source_repo_id|
|
104
|
+
source_repo_version = ::Katello::Repository.find(source_repo_id).version_href
|
105
|
+
config = { source_repo_version: source_repo_version, dest_repo: dest_repo_href, content: content_unit_hrefs }
|
106
|
+
config[:dest_base_version] = dest_repo_id_map[:base_version] if dest_repo_id_map[:base_version]
|
107
|
+
data.config << config
|
108
|
+
end
|
109
|
+
end
|
110
|
+
tasks << copy_content_chunked(data)
|
111
|
+
else
|
112
|
+
tasks << remove_all_content_from_mapping(repo_id_map)
|
113
|
+
end
|
114
|
+
tasks.flatten
|
115
|
+
end
|
116
|
+
|
117
|
+
def copy_api_data_dup(data)
|
118
|
+
data_dup = PulpRpmClient::Copy.new
|
119
|
+
data_dup.dependency_solving = data.dependency_solving
|
120
|
+
data_dup.config = []
|
121
|
+
data.config.each do |repo_config|
|
122
|
+
config_hash = {
|
123
|
+
source_repo_version: repo_config[:source_repo_version],
|
124
|
+
dest_repo: repo_config[:dest_repo],
|
125
|
+
content: []
|
126
|
+
}
|
127
|
+
config_hash[:dest_base_version] = repo_config[:dest_base_version] if repo_config[:dest_base_version]
|
128
|
+
data_dup.config << config_hash
|
129
|
+
end
|
130
|
+
data_dup
|
131
|
+
end
|
132
|
+
|
133
|
+
def copy_content_chunked(data)
|
134
|
+
tasks = []
|
135
|
+
# Don't chunk if there aren't enough content units
|
136
|
+
if data.config.sum { |repo_config| repo_config[:content].size } <= UNIT_LIMIT
|
137
|
+
return api.copy_api.copy_content(data)
|
138
|
+
end
|
139
|
+
|
140
|
+
unit_copy_counter = 0
|
141
|
+
i = 0
|
142
|
+
leftover_units = data.config.first[:content].deep_dup
|
143
|
+
|
144
|
+
# Copy data and clear its content fields
|
145
|
+
data_dup = copy_api_data_dup(data)
|
146
|
+
|
147
|
+
while i < data_dup.config.size
|
148
|
+
# Copy all units within repo or only some?
|
149
|
+
if leftover_units.length < UNIT_LIMIT - unit_copy_counter
|
150
|
+
copy_amount = leftover_units.length
|
151
|
+
else
|
152
|
+
copy_amount = UNIT_LIMIT - unit_copy_counter
|
153
|
+
end
|
154
|
+
|
155
|
+
data_dup.config[i][:content] = leftover_units.pop(copy_amount)
|
156
|
+
unit_copy_counter += copy_amount
|
157
|
+
# Do copy call if limit is reached or if we're under the limit but on the last repo config.
|
158
|
+
if unit_copy_counter >= UNIT_LIMIT || (i == data_dup.config.size - 1 && leftover_units.empty?)
|
159
|
+
tasks << api.copy_api.copy_content(data_dup)
|
160
|
+
unit_copy_counter = 0
|
161
|
+
end
|
162
|
+
|
163
|
+
if leftover_units.empty?
|
164
|
+
# Nothing more to copy -- clear current config's content
|
165
|
+
data_dup.config[i][:content] = []
|
166
|
+
i += 1
|
167
|
+
# Fetch unit list for next data config
|
168
|
+
leftover_units = data.config[i][:content].deep_dup unless i == data_dup.config.size
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
tasks
|
173
|
+
end
|
174
|
+
|
175
|
+
def remove_all_content_from_mapping(repo_id_map)
|
176
|
+
tasks = []
|
177
|
+
repo_id_map.each do |_source_repo_ids, dest_repo_id_map|
|
178
|
+
dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
|
179
|
+
dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
|
180
|
+
tasks << remove_all_content_from_repo(dest_repo_href)
|
181
|
+
end
|
182
|
+
tasks
|
183
|
+
end
|
184
|
+
|
185
|
+
def copy_units(source_repository, content_unit_hrefs, dependency_solving)
|
186
|
+
tasks = []
|
187
|
+
|
188
|
+
if content_unit_hrefs.sort!.any?
|
189
|
+
data = PulpRpmClient::Copy.new
|
190
|
+
data.config = [{
|
191
|
+
source_repo_version: source_repository.version_href,
|
80
192
|
dest_repo: repository_reference.repository_href,
|
81
193
|
dest_base_version: 0,
|
82
|
-
content: content_unit_hrefs
|
83
|
-
]
|
194
|
+
content: content_unit_hrefs
|
195
|
+
}]
|
84
196
|
data.dependency_solving = dependency_solving
|
197
|
+
package_env_hrefs = packageenvironments({ :repository_version => source_repository.version_href }).map(&:pulp_href).sort
|
85
198
|
tasks << api.copy_api.copy_content(data)
|
199
|
+
tasks << add_content(package_env_hrefs) unless package_env_hrefs.empty?
|
86
200
|
else
|
87
|
-
|
88
|
-
remove_content_units: ['*'])
|
89
|
-
tasks << api.repositories_api.modify(repository_reference.repository_href, data)
|
201
|
+
tasks << remove_all_content
|
90
202
|
end
|
91
|
-
|
92
203
|
tasks
|
93
204
|
end
|
94
205
|
|
206
|
+
def remove_all_content_from_repo(repo_href)
|
207
|
+
data = PulpRpmClient::RepositoryAddRemoveContent.new(
|
208
|
+
remove_content_units: ['*'])
|
209
|
+
api.repositories_api.modify(repo_href, data)
|
210
|
+
end
|
211
|
+
|
212
|
+
def repair(repository_version_href)
|
213
|
+
data = PulpRpmClient::RepositoryVersion.new
|
214
|
+
api.repository_versions_api.repair(repository_version_href, data)
|
215
|
+
end
|
216
|
+
|
217
|
+
def remove_all_content
|
218
|
+
data = PulpRpmClient::RepositoryAddRemoveContent.new(
|
219
|
+
remove_content_units: ['*'])
|
220
|
+
api.repositories_api.modify(repository_reference.repository_href, data)
|
221
|
+
end
|
222
|
+
|
95
223
|
def packageenvironments(options = {})
|
96
|
-
api.content_package_environments_api.list(options)
|
224
|
+
Katello::Pulp3::Api::Core.fetch_from_list { |page_opts| api.content_package_environments_api.list(page_opts.merge(options)) }
|
97
225
|
end
|
98
226
|
|
99
227
|
def metadatafiles(options = {})
|
@@ -104,6 +232,94 @@ module Katello
|
|
104
232
|
api.content_distribution_trees_api.list(options)
|
105
233
|
end
|
106
234
|
|
235
|
+
def add_filter_content(source_repo_ids, filters, filter_list_map)
|
236
|
+
filters.each do |filter|
|
237
|
+
if filter.inclusion
|
238
|
+
source_repo_ids.each do |repo_id|
|
239
|
+
filter_list_map[:whitelist_ids] += filter.content_unit_pulp_ids(::Katello::Repository.find(repo_id))
|
240
|
+
end
|
241
|
+
else
|
242
|
+
source_repo_ids.each do |repo_id|
|
243
|
+
filter_list_map[:blacklist_ids] += filter.content_unit_pulp_ids(::Katello::Repository.find(repo_id))
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
filter_list_map
|
248
|
+
end
|
249
|
+
|
250
|
+
def add_un_modular_rpms(source_repo_ids, filters, filter_list_map)
|
251
|
+
if (filter_list_map[:whitelist_ids].empty? && filters.select { |filter| filter.inclusion }.empty?)
|
252
|
+
filter_list_map[:whitelist_ids] += source_repo_ids.collect do |source_repo_id|
|
253
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
254
|
+
source_repo.rpms.where(:modular => false).pluck(:pulp_id).sort
|
255
|
+
end
|
256
|
+
end
|
257
|
+
filter_list_map
|
258
|
+
end
|
259
|
+
|
260
|
+
def add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
|
261
|
+
inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
|
262
|
+
exclusion_modular_filters = modular_filters - inclusion_modular_filters
|
263
|
+
if inclusion_modular_filters.empty? &&
|
264
|
+
!(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
|
265
|
+
source_repo_ids.each do |source_repo_id|
|
266
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
267
|
+
filter_list_map[:whitelist_ids] += source_repo.rpms.where(:modular => true).pluck(:pulp_id).sort
|
268
|
+
filter_list_map[:whitelist_ids] += source_repo.module_streams.pluck(:pulp_id).sort
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
unless inclusion_modular_filters.empty?
|
273
|
+
filter_list_map[:whitelist_ids] += source_repo_ids.collect do |source_repo_id|
|
274
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
275
|
+
modular_packages(source_repo, inclusion_modular_filters)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
unless exclusion_modular_filters.empty?
|
280
|
+
filter_list_map[:blacklist_ids] += source_repo_ids.collect do |source_repo_id|
|
281
|
+
source_repo = ::Katello::Repository.find(source_repo_id)
|
282
|
+
modular_packages(source_repo, exclusion_modular_filters)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
filter_list_map
|
287
|
+
end
|
288
|
+
|
289
|
+
def copy_content_from_mapping(repo_id_map, options = {})
|
290
|
+
repo_id_map.each do |source_repo_ids, dest_repo_map|
|
291
|
+
filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
|
292
|
+
filter_class.where(:id => dest_repo_map[:filter_ids])
|
293
|
+
end
|
294
|
+
modular_filters = ContentViewModuleStreamFilter.where(:id => dest_repo_map[:filter_ids])
|
295
|
+
filters.flatten!.compact!
|
296
|
+
|
297
|
+
filter_list_map = { whitelist_ids: [], blacklist_ids: [] }
|
298
|
+
filter_list_map = add_filter_content(source_repo_ids, filters, filter_list_map)
|
299
|
+
filter_list_map = add_un_modular_rpms(source_repo_ids, filters, filter_list_map)
|
300
|
+
filter_list_map = add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
|
301
|
+
|
302
|
+
whitelist_ids = filter_list_map[:whitelist_ids].flatten&.uniq
|
303
|
+
blacklist_ids = filter_list_map[:blacklist_ids].flatten&.uniq
|
304
|
+
content_unit_hrefs = whitelist_ids - blacklist_ids
|
305
|
+
|
306
|
+
if content_unit_hrefs.any?
|
307
|
+
source_repo_ids.each do |source_repo_id|
|
308
|
+
content_unit_hrefs += additional_content_hrefs(::Katello::Repository.find(source_repo_id), content_unit_hrefs)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
source_repo_ids.each do |source_repo_id|
|
312
|
+
content_unit_hrefs += ::Katello::Repository.find(source_repo_id).srpms.pluck(:pulp_id)
|
313
|
+
end
|
314
|
+
|
315
|
+
dest_repo_map[:content_unit_hrefs] = content_unit_hrefs.uniq.sort
|
316
|
+
end
|
317
|
+
|
318
|
+
dependency_solving = options[:solve_dependencies] || false
|
319
|
+
|
320
|
+
multi_copy_units(repo_id_map, dependency_solving)
|
321
|
+
end
|
322
|
+
|
107
323
|
def copy_content_for_source(source_repository, options = {})
|
108
324
|
filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
|
109
325
|
filter_class.where(:id => options[:filter_ids])
|
@@ -121,19 +337,33 @@ module Katello
|
|
121
337
|
end
|
122
338
|
end
|
123
339
|
|
124
|
-
if whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?
|
125
|
-
whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort
|
126
|
-
end
|
340
|
+
whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort if (whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?)
|
127
341
|
|
342
|
+
modular_filters = ContentViewModuleStreamFilter.where(:id => options[:filter_ids])
|
343
|
+
inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
|
344
|
+
exclusion_modular_filters = modular_filters - inclusion_modular_filters
|
345
|
+
if inclusion_modular_filters.empty? && !(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
|
346
|
+
whitelist_ids += source_repository.rpms.where(:modular => true).pluck(:pulp_id).sort
|
347
|
+
whitelist_ids += source_repository.module_streams.pluck(:pulp_id).sort
|
348
|
+
end
|
349
|
+
whitelist_ids += modular_packages(source_repository, inclusion_modular_filters) unless inclusion_modular_filters.empty?
|
350
|
+
blacklist_ids += modular_packages(source_repository, exclusion_modular_filters) unless exclusion_modular_filters.empty?
|
128
351
|
content_unit_hrefs = whitelist_ids - blacklist_ids
|
129
|
-
|
130
352
|
if content_unit_hrefs.any?
|
131
353
|
content_unit_hrefs += additional_content_hrefs(source_repository, content_unit_hrefs)
|
132
354
|
end
|
133
355
|
content_unit_hrefs += source_repository.srpms.pluck(:pulp_id)
|
134
356
|
|
135
357
|
dependency_solving = options[:solve_dependencies] || false
|
136
|
-
copy_units(source_repository
|
358
|
+
copy_units(source_repository, content_unit_hrefs.uniq, dependency_solving)
|
359
|
+
end
|
360
|
+
|
361
|
+
def modular_packages(source_repository, filters)
|
362
|
+
list_ids = []
|
363
|
+
filters.each do |filter|
|
364
|
+
list_ids += filter.content_unit_pulp_ids(source_repository, true)
|
365
|
+
end
|
366
|
+
list_ids
|
137
367
|
end
|
138
368
|
|
139
369
|
def additional_content_hrefs(source_repository, content_unit_hrefs)
|
@@ -146,10 +376,6 @@ module Katello
|
|
146
376
|
package_groups_to_include = filter_package_groups_by_pulp_href(source_repository.package_groups, content_unit_hrefs)
|
147
377
|
content_unit_hrefs += package_groups_to_include.pluck(:pulp_id)
|
148
378
|
|
149
|
-
package_environment_hrefs_to_include = filter_package_environments_by_pulp_hrefs(
|
150
|
-
repo_service.packageenvironments(options).results, package_groups_to_include.pluck(:pulp_id))
|
151
|
-
content_unit_hrefs += package_environment_hrefs_to_include
|
152
|
-
|
153
379
|
metadata_file_hrefs_to_include = filter_metadatafiles_by_pulp_hrefs(
|
154
380
|
repo_service.metadatafiles(options).results, content_unit_hrefs)
|
155
381
|
content_unit_hrefs += metadata_file_hrefs_to_include
|
@@ -158,11 +384,6 @@ module Katello
|
|
158
384
|
repo_service.distributiontrees(options).results, content_unit_hrefs)
|
159
385
|
content_unit_hrefs + distribution_tree_hrefs_to_include
|
160
386
|
end
|
161
|
-
|
162
|
-
def regenerate_applicability
|
163
|
-
# TODO
|
164
|
-
fail NotImplementedError
|
165
|
-
end
|
166
387
|
end
|
167
388
|
end
|
168
389
|
end
|