katello 4.2.0.rc1 → 4.2.0.rc2
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/rhsm/candlepin_dynflow_proxy_controller.rb +20 -2
- data/app/controllers/katello/api/v2/content_uploads_controller.rb +2 -1
- data/app/controllers/katello/api/v2/repositories_controller.rb +1 -0
- data/app/lib/actions/katello/content_view_version/create_repos.rb +1 -1
- data/app/lib/actions/katello/host/upload_package_profile.rb +7 -21
- data/app/lib/actions/katello/host/upload_profiles.rb +6 -52
- data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +2 -0
- data/app/lib/actions/katello/repository/clone_to_environment.rb +1 -1
- data/app/lib/actions/katello/repository/create.rb +8 -4
- data/app/lib/actions/katello/repository/create_root.rb +1 -1
- data/app/lib/actions/katello/repository/import_upload.rb +6 -1
- data/app/lib/actions/katello/repository/upload_files.rb +6 -8
- data/app/lib/actions/katello/repository_set/enable_repository.rb +1 -1
- data/app/lib/actions/pulp3/orchestration/repository/create.rb +2 -2
- data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +25 -4
- data/app/lib/actions/pulp3/orchestration/repository/upload_content.rb +17 -5
- data/app/lib/actions/pulp3/repository/commit_upload.rb +25 -2
- data/app/lib/actions/pulp3/repository/create.rb +4 -3
- data/app/lib/actions/pulp3/repository/refresh_distribution.rb +5 -2
- data/app/lib/actions/pulp3/repository/save_artifact.rb +8 -1
- data/app/lib/actions/pulp3/repository/update_remote.rb +7 -4
- data/app/lib/actions/pulp3/repository/upload_file.rb +29 -3
- data/app/models/katello/concerns/host_managed_extensions.rb +14 -1
- data/app/models/katello/content_view.rb +1 -1
- data/app/models/katello/content_view_repository.rb +3 -2
- data/app/models/katello/content_view_version.rb +5 -3
- data/app/models/katello/erratum.rb +2 -2
- data/app/models/katello/host/content_facet.rb +7 -2
- data/app/models/katello/repository.rb +1 -1
- data/app/models/katello/root_repository.rb +10 -6
- data/app/models/setting/content.rb +3 -1
- data/app/services/katello/applicability/applicable_content_helper.rb +2 -1
- data/app/services/katello/host/package_profile_uploader.rb +41 -0
- data/app/services/katello/host/profiles_uploader.rb +74 -0
- data/app/services/katello/pulp3/api/core.rb +4 -0
- data/app/services/katello/pulp3/repository/ansible_collection.rb +5 -9
- data/app/services/katello/pulp3/repository/yum.rb +17 -4
- data/app/services/katello/pulp3/repository.rb +42 -8
- data/app/services/katello/pulp3/repository_mirror.rb +1 -1
- data/app/views/katello/api/v2/repositories/show.json.rabl +1 -0
- data/app/views/smart_proxies/plugins/_pulpcore.html.erb +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/apply-errata-confirm.html +1 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +7 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +6 -0
- data/lib/katello/tasks/repository.rake +4 -3
- data/lib/katello/version.rb +1 -1
- data/locale/bn/katello.po +1 -1
- data/locale/bn/katello.po.time_stamp +0 -0
- data/locale/cs/katello.po +1 -1
- data/locale/cs/katello.po.time_stamp +0 -0
- data/locale/de/katello.po +1 -1
- data/locale/de/katello.po.time_stamp +0 -0
- data/locale/en/katello.po +1 -1
- data/locale/en/katello.po.time_stamp +0 -0
- data/locale/es/katello.po +1 -1
- data/locale/es/katello.po.time_stamp +0 -0
- data/locale/fr/katello.po +1 -1
- data/locale/fr/katello.po.time_stamp +0 -0
- data/locale/gu/katello.po +1 -1
- data/locale/gu/katello.po.time_stamp +0 -0
- data/locale/hi/katello.po +1 -1
- data/locale/hi/katello.po.time_stamp +0 -0
- data/locale/it/katello.po +1 -1
- data/locale/it/katello.po.time_stamp +0 -0
- data/locale/ja/katello.po +1 -1
- data/locale/ja/katello.po.time_stamp +0 -0
- data/locale/katello.pot +1 -1
- data/locale/kn/katello.po +1 -1
- data/locale/kn/katello.po.time_stamp +0 -0
- data/locale/ko/katello.po +1 -1
- data/locale/ko/katello.po.time_stamp +0 -0
- data/locale/mr/katello.po +1 -1
- data/locale/mr/katello.po.time_stamp +0 -0
- data/locale/or/katello.po +1 -1
- data/locale/or/katello.po.time_stamp +0 -0
- data/locale/pa/katello.po +1 -1
- data/locale/pa/katello.po.time_stamp +0 -0
- data/locale/pt/katello.po +1 -1
- data/locale/pt/katello.po.time_stamp +0 -0
- data/locale/pt_BR/katello.po +1 -1
- data/locale/pt_BR/katello.po.time_stamp +0 -0
- data/locale/ru/katello.po +1 -1
- data/locale/ru/katello.po.time_stamp +0 -0
- data/locale/ta/katello.po +1 -1
- data/locale/ta/katello.po.time_stamp +0 -0
- data/locale/te/katello.po +1 -1
- data/locale/te/katello.po.time_stamp +0 -0
- data/locale/zh_CN/katello.po +1 -1
- data/locale/zh_CN/katello.po.time_stamp +0 -0
- data/locale/zh_TW/katello.po +1 -1
- data/locale/zh_TW/katello.po.time_stamp +0 -0
- data/webpack/components/AddedStatusLabel.js +5 -0
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js +1 -1
- data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +1 -1
- metadata +26 -2
@@ -4,15 +4,22 @@ module Actions
|
|
4
4
|
class SaveArtifact < Pulp3::AbstractAsyncTask
|
5
5
|
def plan(file, repository, smart_proxy, tasks, unit_type_id, options = {})
|
6
6
|
options[:file_name] = file[:filename]
|
7
|
+
options[:sha256] = file[:sha256] || Digest::SHA256.hexdigest(File.read(file[:path]))
|
7
8
|
plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :tasks => tasks, :unit_type_id => unit_type_id, :options => options)
|
8
9
|
end
|
9
10
|
|
10
11
|
def invoke_external_task
|
11
|
-
artifact_href = input[:
|
12
|
+
artifact_href = input[:options][:artifact_href] || fetch_artifact_href
|
13
|
+
fail _("Content not uploaded to pulp") unless artifact_href
|
12
14
|
content_type = input[:unit_type_id]
|
13
15
|
content_backend_service = SmartProxy.pulp_primary.content_service(content_type)
|
14
16
|
output[:pulp_tasks] = [content_backend_service.content_api_create(relative_path: input[:options][:file_name], artifact: artifact_href)]
|
15
17
|
end
|
18
|
+
|
19
|
+
def fetch_artifact_href
|
20
|
+
sha_artifact_list = ::Katello::Pulp3::Api::Core.new(smart_proxy).artifacts_api.list("sha256": input[:options][:sha256])
|
21
|
+
sha_artifact_list&.results&.first&.pulp_href
|
22
|
+
end
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
@@ -1,14 +1,17 @@
|
|
1
1
|
module Actions
|
2
2
|
module Pulp3
|
3
3
|
module Repository
|
4
|
-
class UpdateRemote < Pulp3::
|
4
|
+
class UpdateRemote < Pulp3::AbstractAsyncTask
|
5
5
|
def plan(repository, smart_proxy)
|
6
|
-
|
6
|
+
if repository.root.url
|
7
|
+
repository.backend_service(smart_proxy).create_test_remote if smart_proxy.pulp_primary?
|
8
|
+
plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id)
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
|
-
def
|
12
|
+
def invoke_external_task
|
10
13
|
repo = ::Katello::Repository.find(input[:repository_id])
|
11
|
-
|
14
|
+
repo.backend_service(smart_proxy).update_remote
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -6,6 +6,7 @@ module Actions
|
|
6
6
|
plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :file => file)
|
7
7
|
end
|
8
8
|
|
9
|
+
# rubocop:disable Metrics/MethodLength
|
9
10
|
def invoke_external_task
|
10
11
|
repo = ::Katello::Repository.find(input[:repository_id])
|
11
12
|
repo_backend_service = repo.backend_service(smart_proxy)
|
@@ -34,10 +35,21 @@ module Actions
|
|
34
35
|
|
35
36
|
if response
|
36
37
|
upload_href = response.pulp_href
|
37
|
-
|
38
|
+
#Check for any duplicate artifacts created in parallel subtasks
|
39
|
+
duplicate_sha_artifact_list = ::Katello::Pulp3::Api::Core.new(smart_proxy).artifacts_api.list("sha256": sha256)
|
40
|
+
duplicate_sha_artifact_href = duplicate_sha_artifact_list&.results&.first&.pulp_href
|
41
|
+
if duplicate_sha_artifact_href
|
42
|
+
uploads_api.delete(upload_href)
|
43
|
+
output[:artifact_href] = duplicate_sha_artifact_href
|
44
|
+
output[:pulp_tasks] = nil
|
45
|
+
else
|
46
|
+
output[:artifact_href] = nil
|
47
|
+
output[:pulp_tasks] = [uploads_api.commit(upload_href, sha256: sha256)]
|
48
|
+
end
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
52
|
+
# rubocop:enable Metrics/MethodLength
|
41
53
|
|
42
54
|
def external_task=(tasks)
|
43
55
|
super
|
@@ -50,8 +62,18 @@ module Actions
|
|
50
62
|
def check_error_details
|
51
63
|
output[:pulp_tasks].each do |pulp_task|
|
52
64
|
error_details = pulp_task.try(:[], "error")
|
53
|
-
if error_details && !error_details.nil?
|
54
|
-
fail _("An error occurred during
|
65
|
+
if error_details && !error_details.nil? && !unique_error(error_details)
|
66
|
+
fail _("An error occurred during upload \n%{error_message}") % {:error_message => error_details}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def check_for_errors
|
72
|
+
combined_tasks.each do |task|
|
73
|
+
if unique_error task.error
|
74
|
+
warn _("Duplicate artifact detected")
|
75
|
+
else
|
76
|
+
super
|
55
77
|
end
|
56
78
|
end
|
57
79
|
end
|
@@ -70,6 +92,10 @@ module Actions
|
|
70
92
|
finish = finish > total ? total : finish
|
71
93
|
"bytes #{start}-#{finish}/#{total}"
|
72
94
|
end
|
95
|
+
|
96
|
+
def unique_error(message)
|
97
|
+
message&.include?("code='unique'")
|
98
|
+
end
|
73
99
|
end
|
74
100
|
end
|
75
101
|
end
|
@@ -214,10 +214,15 @@ module Katello
|
|
214
214
|
new_ids = new_available_module_streams.keys - old_associated_ids
|
215
215
|
new_ids.each do |new_id|
|
216
216
|
module_stream = new_available_module_streams[new_id]
|
217
|
+
status = module_stream["status"]
|
218
|
+
# Set status to "unknown" only if the active field is in use and set to false and the module is enabled
|
219
|
+
if enabled_module_stream_inactive?(module_stream)
|
220
|
+
status = "unknown"
|
221
|
+
end
|
217
222
|
self.host_available_module_streams.create!(host_id: self.id,
|
218
223
|
available_module_stream_id: new_id,
|
219
224
|
installed_profiles: module_stream["installed_profiles"],
|
220
|
-
status:
|
225
|
+
status: status)
|
221
226
|
end
|
222
227
|
|
223
228
|
upgradable_streams.each do |hams|
|
@@ -227,6 +232,10 @@ module Katello
|
|
227
232
|
if hams.attributes.slice(*shared_keys) != module_stream_data
|
228
233
|
hams.update!(module_stream_data)
|
229
234
|
end
|
235
|
+
# Set status to "unknown" only if the active field is in use and set to false and the module is enabled
|
236
|
+
if enabled_module_stream_inactive?(module_stream)
|
237
|
+
hams.update!(status: "unknown")
|
238
|
+
end
|
230
239
|
end
|
231
240
|
end
|
232
241
|
|
@@ -346,6 +355,10 @@ module Katello
|
|
346
355
|
self.get_status(::Katello::TraceStatus).refresh!
|
347
356
|
self.refresh_global_status!
|
348
357
|
end
|
358
|
+
|
359
|
+
def enabled_module_stream_inactive?(module_stream)
|
360
|
+
!module_stream["active"].nil? && module_stream["active"] == false && module_stream["status"] == "enabled"
|
361
|
+
end
|
349
362
|
end
|
350
363
|
end
|
351
364
|
end
|
@@ -270,7 +270,7 @@ module Katello
|
|
270
270
|
|
271
271
|
def last_task
|
272
272
|
last_task_id = history.order(:created_at)&.last&.task_id
|
273
|
-
last_task_id ? ForemanTasks::Task.
|
273
|
+
last_task_id ? ForemanTasks::Task.find_by(id: last_task_id) : nil
|
274
274
|
end
|
275
275
|
|
276
276
|
def history
|
@@ -5,8 +5,9 @@ module Katello
|
|
5
5
|
Repository::OSTREE_TYPE,
|
6
6
|
Repository::FILE_TYPE,
|
7
7
|
Repository::DEB_TYPE,
|
8
|
-
Repository::ANSIBLE_COLLECTION_TYPE
|
9
|
-
|
8
|
+
Repository::ANSIBLE_COLLECTION_TYPE,
|
9
|
+
Katello::RepositoryTypeManager.generic_repository_types(enabled_only: false).keys.flatten
|
10
|
+
].flatten.freeze
|
10
11
|
|
11
12
|
ALLOWED_IMPORT_REPOSITORY_TYPES = Repository::EXPORTABLE_TYPES
|
12
13
|
|
@@ -311,11 +311,13 @@ module Katello
|
|
311
311
|
|
312
312
|
def update_content_counts!
|
313
313
|
self.content_counts = {}
|
314
|
-
RepositoryTypeManager.indexable_content_types.
|
315
|
-
if content_type::CONTENT_TYPE == DockerTag::CONTENT_TYPE
|
314
|
+
RepositoryTypeManager.indexable_content_types.each do |content_type|
|
315
|
+
if content_type&.model_class::CONTENT_TYPE == DockerTag::CONTENT_TYPE
|
316
316
|
content_counts[DockerTag::CONTENT_TYPE] = docker_tags.count
|
317
|
+
elsif content_type&.model_class::CONTENT_TYPE == GenericContentUnit::CONTENT_TYPE
|
318
|
+
content_counts[content_type.content_type] = content_type&.model_class&.in_repositories(self.repositories.archived)&.where(:content_type => content_type.content_type)&.count
|
317
319
|
else
|
318
|
-
content_counts[content_type::CONTENT_TYPE] = content_type
|
320
|
+
content_counts[content_type&.model_class::CONTENT_TYPE] = content_type&.model_class&.in_repositories(self.repositories.archived)&.count
|
319
321
|
end
|
320
322
|
end
|
321
323
|
save!
|
@@ -106,7 +106,7 @@ module Katello
|
|
106
106
|
query_clauses = clauses.map do |clause|
|
107
107
|
"(#{clause.to_sql})"
|
108
108
|
end
|
109
|
-
statement = query_clauses.join("
|
109
|
+
statement = query_clauses.join(" AND ")
|
110
110
|
|
111
111
|
Katello::ErratumPackage.joins(:erratum => :repository_errata).
|
112
112
|
where("#{RepositoryErratum.table_name}.repository_id" => repo.id).
|
@@ -117,7 +117,7 @@ module Katello
|
|
117
117
|
query_clauses = clauses.map do |clause|
|
118
118
|
"(#{clause.to_sql})"
|
119
119
|
end
|
120
|
-
statement = query_clauses.join("
|
120
|
+
statement = query_clauses.join(" AND ")
|
121
121
|
ModuleStream.where(:id => ModuleStreamErratumPackage.joins(:erratum_package => {:erratum => :repository_errata}).
|
122
122
|
where("#{RepositoryErratum.table_name}.repository_id" => repo.id).
|
123
123
|
where(statement).select("#{ModuleStreamErratumPackage.table_name}.module_stream_id"))
|
@@ -6,6 +6,7 @@ module Katello
|
|
6
6
|
include Facets::Base
|
7
7
|
|
8
8
|
HOST_TOOLS_PACKAGE_NAME = 'katello-host-tools'.freeze
|
9
|
+
HOST_TOOLS_TRACER_PACKAGE_NAME = 'katello-host-tools-tracer'.freeze
|
9
10
|
SUBSCRIPTION_MANAGER_PACKAGE_NAME = 'subscription-manager'.freeze
|
10
11
|
|
11
12
|
belongs_to :kickstart_repository, :class_name => "::Katello::Repository", :foreign_key => :kickstart_repository_id, :inverse_of => :kickstart_content_facets
|
@@ -196,11 +197,15 @@ module Katello
|
|
196
197
|
end
|
197
198
|
|
198
199
|
def tracer_installed?
|
199
|
-
self.host.installed_packages.where("#{Katello::InstalledPackage.table_name}.name" =>
|
200
|
+
self.host.installed_packages.where("#{Katello::InstalledPackage.table_name}.name" => [ "python-#{HOST_TOOLS_TRACER_PACKAGE_NAME}",
|
201
|
+
"python3-#{HOST_TOOLS_TRACER_PACKAGE_NAME}",
|
202
|
+
HOST_TOOLS_TRACER_PACKAGE_NAME ]).any?
|
200
203
|
end
|
201
204
|
|
202
205
|
def host_tools_installed?
|
203
|
-
host.installed_packages.where("#{Katello::InstalledPackage.table_name}.name" => HOST_TOOLS_PACKAGE_NAME
|
206
|
+
host.installed_packages.where("#{Katello::InstalledPackage.table_name}.name" => [ "python-#{HOST_TOOLS_PACKAGE_NAME}",
|
207
|
+
"python3-#{HOST_TOOLS_PACKAGE_NAME}",
|
208
|
+
HOST_TOOLS_PACKAGE_NAME ]).any?
|
204
209
|
end
|
205
210
|
|
206
211
|
def update_errata_status
|
@@ -413,7 +413,7 @@ module Katello
|
|
413
413
|
elsif ostree?
|
414
414
|
"#{scheme}://#{pulp_uri.host.downcase}/pulp/content/web/#{relative_path}"
|
415
415
|
elsif ansible_collection?
|
416
|
-
"#{scheme}://#{pulp_uri.host.downcase}/pulp_ansible/galaxy/#{relative_path}/api"
|
416
|
+
"#{scheme}://#{pulp_uri.host.downcase}/pulp_ansible/galaxy/#{relative_path}/api/"
|
417
417
|
else
|
418
418
|
"#{scheme}://#{pulp_uri.host.downcase}/pulp/content/#{relative_path}/"
|
419
419
|
end
|
@@ -187,10 +187,16 @@ module Katello
|
|
187
187
|
|
188
188
|
def ensure_valid_collection_attributes
|
189
189
|
errors.add(:base, _("URL needs to have a trailing /")) if !url.blank? && url[-1] != '/'
|
190
|
+
return unless ansible_collection_requirements
|
190
191
|
begin
|
191
|
-
YAML.safe_load(ansible_collection_requirements)
|
192
|
+
requirements = YAML.safe_load(ansible_collection_requirements)
|
193
|
+
if requirements.is_a?(Hash)
|
194
|
+
errors.add(:base, _("Requirements yaml should have a 'collections' key")) unless requirements.key?('collections')
|
195
|
+
else
|
196
|
+
errors.add(:base, _('Requirements yaml should be a key-value pair structure.'))
|
197
|
+
end
|
192
198
|
rescue
|
193
|
-
errors.add(:base, _('Requirements
|
199
|
+
errors.add(:base, _('Requirements is not valid yaml.'))
|
194
200
|
end
|
195
201
|
end
|
196
202
|
|
@@ -283,9 +289,7 @@ module Katello
|
|
283
289
|
return
|
284
290
|
end
|
285
291
|
|
286
|
-
if self.ansible_collection_auth_url.blank?
|
287
|
-
errors.add(:base, N_("Auth token requires Auth URL be set."))
|
288
|
-
elsif !self.ansible_collection_auth_token
|
292
|
+
if !self.ansible_collection_auth_url.blank? && self.ansible_collection_auth_token.blank?
|
289
293
|
errors.add(:base, N_("Auth URL requires Auth token be set."))
|
290
294
|
end
|
291
295
|
end
|
@@ -351,7 +355,7 @@ module Katello
|
|
351
355
|
ssl_ca_cert_id ssl_client_cert_id ssl_client_key_id http_proxy_policy http_proxy_id download_concurrency)
|
352
356
|
changeable_attributes += %w(name container_repository_name docker_tags_whitelist) if docker?
|
353
357
|
changeable_attributes += %w(deb_releases deb_components deb_architectures gpg_key_id) if deb?
|
354
|
-
changeable_attributes += %w(ansible_collection_requirements) if ansible_collection?
|
358
|
+
changeable_attributes += %w(ansible_collection_requirements ansible_collection_auth_url ansible_collection_auth_token) if ansible_collection?
|
355
359
|
changeable_attributes.any? { |key| previous_changes.key?(key) }
|
356
360
|
end
|
357
361
|
|
@@ -157,7 +157,9 @@ class Setting::Content < Setting
|
|
157
157
|
self.set('autosearch_delay', N_('If Autosearch is enabled, delay in milliseconds before executing searches while typing.'),
|
158
158
|
500, N_('Autosearch delay')),
|
159
159
|
self.set('bulk_load_size', N_('The number of items fetched from a single paged Pulp API call.'), 2000,
|
160
|
-
N_('Pulp bulk load size'))
|
160
|
+
N_('Pulp bulk load size')),
|
161
|
+
self.set('upload_profiles_without_dynflow', N_('Allow Katello to update host installed packages, enabled repos, and module inventory directly instead of wrapped in Dynflow tasks (try turning off if Puma processes are using too much memory)'), true,
|
162
|
+
N_('Upload profiles without Dynflow'))
|
161
163
|
]
|
162
164
|
end
|
163
165
|
|
@@ -92,7 +92,8 @@ module Katello
|
|
92
92
|
::Katello::ModuleStream.
|
93
93
|
joins("inner join katello_available_module_streams on
|
94
94
|
katello_module_streams.name = katello_available_module_streams.name and
|
95
|
-
katello_module_streams.stream = katello_available_module_streams.stream
|
95
|
+
katello_module_streams.stream = katello_available_module_streams.stream and
|
96
|
+
katello_module_streams.context = katello_available_module_streams.context").
|
96
97
|
joins("inner join katello_host_available_module_streams on
|
97
98
|
katello_available_module_streams.id = katello_host_available_module_streams.available_module_stream_id").
|
98
99
|
where("katello_host_available_module_streams.host_id = :content_facet_id and
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Katello
|
2
|
+
module Host
|
3
|
+
class PackageProfileUploader
|
4
|
+
def initialize(profile_string:, host: nil)
|
5
|
+
@profile_string = profile_string
|
6
|
+
@host = host
|
7
|
+
end
|
8
|
+
|
9
|
+
def upload
|
10
|
+
profile = JSON.parse(@profile_string)
|
11
|
+
#free the huge string from the memory
|
12
|
+
@profile_string = 'TRIMMED'.freeze
|
13
|
+
import_package_profile(profile)
|
14
|
+
end
|
15
|
+
|
16
|
+
def import_package_profile(profile)
|
17
|
+
self.class.import_package_profile_for_host(@host&.id, profile)
|
18
|
+
end
|
19
|
+
|
20
|
+
def trigger_applicability_generation
|
21
|
+
::Katello::Host::ContentFacet.trigger_applicability_generation(@host&.id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.import_package_profile_for_host(host_id, profile)
|
25
|
+
host = ::Host.find_by(:id => host_id)
|
26
|
+
if host.nil?
|
27
|
+
Rails.logger.warn("Host with ID %s not found; continuing" % host_id)
|
28
|
+
elsif host.content_facet.nil? || host.content_facet.uuid.nil?
|
29
|
+
Rails.logger.warn("Host with ID %s has no content facet; continuing" % host_id)
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
simple_packages = profile.map { |item| ::Katello::Pulp::SimplePackage.new(item) }
|
33
|
+
host.import_package_profile(simple_packages)
|
34
|
+
rescue ActiveRecord::InvalidForeignKey # this happens if the host gets deleted in between the "find_by" and "import_package_profile"
|
35
|
+
Rails.logger.warn("Host installed package list with ID %s was not able to be written to the DB (host likely is deleted); continuing" % host_id)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end # of class
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Katello
|
2
|
+
module Host
|
3
|
+
class ProfilesUploader
|
4
|
+
def initialize(profile_string:, host: nil)
|
5
|
+
@profile_string = profile_string
|
6
|
+
@host = host
|
7
|
+
end
|
8
|
+
|
9
|
+
def upload
|
10
|
+
profiles = JSON.parse(@profile_string)
|
11
|
+
#free the huge string from the memory
|
12
|
+
@profile_string = 'TRIMMED'.freeze
|
13
|
+
if @host.nil?
|
14
|
+
Rails.logger.warn("Host was not specified; continuing")
|
15
|
+
elsif @host.content_facet.nil? || @host.content_facet.uuid.nil?
|
16
|
+
Rails.logger.warn("Host with ID %s has no content facet; continuing" % @host.id)
|
17
|
+
elsif profiles.try(:has_key?, "deb_package_profile")
|
18
|
+
# remove this when deb_package_profile API is removed
|
19
|
+
payload = profiles.dig("deb_package_profile", "deb_packages") || []
|
20
|
+
import_deb_package_profile(payload)
|
21
|
+
else
|
22
|
+
module_streams = []
|
23
|
+
profiles.each do |profile|
|
24
|
+
payload = profile["profile"]
|
25
|
+
case profile["content_type"]
|
26
|
+
when "rpm"
|
27
|
+
PackageProfileUploader.import_package_profile_for_host(@host.id, payload)
|
28
|
+
when "deb"
|
29
|
+
import_deb_package_profile(payload)
|
30
|
+
when "enabled_repos"
|
31
|
+
@host.import_enabled_repositories(payload)
|
32
|
+
else
|
33
|
+
module_streams << payload
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module_streams.each do |module_stream_payload|
|
38
|
+
import_module_streams(module_stream_payload)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def trigger_applicability_generation
|
45
|
+
if @host.nil?
|
46
|
+
Rails.logger.warn "Host was not specified; can't trigger applicability generation"
|
47
|
+
return
|
48
|
+
end
|
49
|
+
::Katello::Host::ContentFacet.trigger_applicability_generation(@host.id)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def import_module_streams(payload)
|
55
|
+
enabled_payload = payload.map do |profile|
|
56
|
+
profile.slice("name", "stream", "version", "context", "arch").with_indifferent_access if profile["status"] == "enabled"
|
57
|
+
end
|
58
|
+
enabled_payload.compact!
|
59
|
+
|
60
|
+
@host.import_module_streams(payload)
|
61
|
+
end
|
62
|
+
|
63
|
+
def import_deb_package_profile(profile)
|
64
|
+
installed_deb_ids = profile.map do |item|
|
65
|
+
::Katello::InstalledDeb.find_or_create_by(name: item['name'], architecture: item['architecture'], version: item['version']).id
|
66
|
+
end
|
67
|
+
@host.installed_deb_ids = installed_deb_ids
|
68
|
+
@host.save!
|
69
|
+
rescue ActiveRecord::InvalidForeignKey # this happens if the host gets deleted in between the "find_by" and "import_package_profile"
|
70
|
+
Rails.logger.warn("Host installed package list with ID %s was not able to be written to the DB (host likely is deleted); continuing" % @host.id)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -100,6 +100,10 @@ module Katello
|
|
100
100
|
PulpcoreClient::OrphansApi.new(core_api_client)
|
101
101
|
end
|
102
102
|
|
103
|
+
def artifacts_api
|
104
|
+
PulpcoreClient::ArtifactsApi.new(core_api_client)
|
105
|
+
end
|
106
|
+
|
103
107
|
def core_api_client
|
104
108
|
client = PulpcoreClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpcoreClient::Configuration))
|
105
109
|
api_client_class(client)
|
@@ -5,15 +5,11 @@ module Katello
|
|
5
5
|
class Repository
|
6
6
|
class AnsibleCollection < ::Katello::Pulp3::Repository
|
7
7
|
def remote_options
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
auth_url: root.ansible_collection_auth_url,
|
14
|
-
token: root.ansible_collection_auth_token,
|
15
|
-
tls_validation: root.verify_ssl_on_sync)
|
16
|
-
end
|
8
|
+
common_remote_options.merge(url: root.url.chomp('/').concat('/'),
|
9
|
+
requirements_file: root.ansible_collection_requirements.blank? ? nil : root.ansible_collection_requirements,
|
10
|
+
auth_url: root.ansible_collection_auth_url,
|
11
|
+
token: root.ansible_collection_auth_token,
|
12
|
+
tls_validation: root.verify_ssl_on_sync)
|
17
13
|
end
|
18
14
|
|
19
15
|
def distribution_options(path)
|