katello 4.2.0.1 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/katello/api/v2/content_uploads_controller.rb +6 -3
- data/app/controllers/katello/api/v2/generic_content_units_controller.rb +26 -0
- data/app/controllers/katello/api/v2/repositories_controller.rb +16 -4
- data/app/lib/actions/katello/capsule_content/sync_capsule.rb +6 -47
- data/app/lib/actions/katello/content_view/promote_to_environment.rb +2 -7
- data/app/lib/actions/katello/content_view/publish.rb +4 -2
- data/app/lib/actions/katello/repository/filtered_index_content.rb +5 -0
- data/app/lib/actions/katello/repository/import_upload.rb +5 -1
- data/app/lib/actions/katello/repository/index_content.rb +2 -1
- data/app/lib/actions/katello/repository/remove_content.rb +5 -1
- data/app/lib/actions/katello/repository/upload_files.rb +6 -1
- data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +2 -4
- data/app/lib/actions/pulp3/orchestration/repository/upload_content.rb +2 -7
- data/app/lib/actions/pulp3/repository/save_artifact.rb +4 -1
- data/app/lib/katello/concerns/base_template_scope_extensions.rb +1 -1
- data/app/lib/katello/util/errata.rb +3 -1
- data/app/models/katello/concerns/host_managed_extensions.rb +19 -0
- data/app/models/katello/concerns/pulp_database_unit.rb +32 -11
- data/app/models/katello/concerns/smart_proxy_extensions.rb +39 -4
- data/app/models/katello/content_view.rb +13 -0
- data/app/models/katello/content_view_repository.rb +1 -1
- data/app/models/katello/docker_tag.rb +2 -2
- data/app/models/katello/erratum.rb +13 -0
- data/app/models/katello/generic_content_unit.rb +4 -1
- data/app/models/katello/repository.rb +15 -7
- data/app/models/katello/root_repository.rb +9 -2
- data/app/models/katello/yum_metadata_file.rb +2 -2
- data/app/services/katello/applicability/applicable_content_helper.rb +4 -3
- data/app/services/katello/pulp/content.rb +1 -1
- data/app/services/katello/pulp3/content.rb +6 -2
- data/app/services/katello/pulp3/erratum.rb +12 -4
- data/app/services/katello/pulp3/generic_content_unit.rb +1 -1
- data/app/services/katello/pulp3/pulp_content_unit.rb +26 -1
- data/app/services/katello/pulp3/repository/apt.rb +16 -0
- data/app/services/katello/pulp3/repository/yum.rb +18 -19
- data/app/services/katello/pulp3/repository_mirror.rb +9 -1
- data/app/services/katello/repository_type.rb +8 -6
- data/app/services/katello/repository_type_manager.rb +25 -22
- data/app/views/katello/api/v2/generic_content_units/base.json.rabl +7 -0
- data/app/views/katello/api/v2/generic_content_units/compare.json.rabl +10 -0
- data/app/views/katello/api/v2/generic_content_units/index.json.rabl +7 -0
- data/app/views/katello/api/v2/generic_content_units/show.json.rabl +3 -0
- data/app/views/katello/api/v2/repositories/show.json.rabl +2 -1
- data/config/initializers/filter_parameters.rb +1 -0
- data/config/routes/api/v2.rb +12 -1
- data/db/migrate/20210512192745_fix_red_hat_root_repository_arch.rb +1 -1
- data/db/migrate/20210831161843_add_upstream_auth_token_to_root_repository.rb +5 -0
- data/db/seeds.d/111-upgrade_tasks.rb +3 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +3 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +6 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +11 -0
- data/lib/katello/permission_creator.rb +2 -0
- data/lib/katello/repository_types/deb.rb +1 -1
- data/lib/katello/repository_types/docker.rb +1 -1
- data/lib/katello/repository_types/file.rb +1 -1
- data/lib/katello/repository_types/ostree.rb +1 -1
- data/lib/katello/repository_types/python.rb +4 -1
- data/lib/katello/repository_types/yum.rb +1 -1
- data/lib/katello/tasks/reset.rake +6 -5
- data/lib/katello/tasks/test.rake +1 -2
- data/lib/katello/tasks/upgrades/4.1/{update_content_import_export_perms.rake → reupdate_content_import_export_perms.rake} +24 -1
- data/lib/katello/tasks/upgrades/4.2/remove_checksum_values.rake +17 -0
- data/lib/katello/version.rb +1 -1
- data/webpack/components/extensions/RegistrationCommands/__tests__/__snapshots__/ActivationKeys.test.js.snap +1 -0
- data/webpack/components/extensions/RegistrationCommands/__tests__/__snapshots__/Force.test.js.snap +1 -0
- data/webpack/components/extensions/RegistrationCommands/__tests__/__snapshots__/IgnoreSubmanErrors.test.js.snap +1 -0
- data/webpack/scenes/RedHatRepositories/components/SearchBar.js +2 -4
- metadata +15 -7
|
@@ -84,6 +84,19 @@ module Katello
|
|
|
84
84
|
where("#{self.table_name}.id in (?) or #{self.table_name}.pulp_id in (?) or #{self.table_name}.errata_id in (?)", id_integers, ids, ids)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
def self.update_repo_association_records(new_ids, erratum_updated_ids, id_href_map_for_repository, repository)
|
|
88
|
+
if new_ids.any?
|
|
89
|
+
self.repository_association_class.import(db_columns_sync, db_values(new_ids, id_href_map_for_repository, repository), validate: false)
|
|
90
|
+
end
|
|
91
|
+
if erratum_updated_ids.present?
|
|
92
|
+
upserts = db_values(erratum_updated_ids, id_href_map_for_repository, repository).map do |upsert|
|
|
93
|
+
{ erratum_id: upsert[0], erratum_pulp3_href: upsert[1], repository_id: upsert[2], created_at: upsert[3], updated_at: upsert[4] }
|
|
94
|
+
end
|
|
95
|
+
# PostgreSQL refuses to insert and update in the same command: https://github.com/rails/rails/issues/35519
|
|
96
|
+
self.repository_association_class.upsert_all(upserts, unique_by: [:erratum_id, :repository_id])
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
87
100
|
def hosts_applicable(org_id = nil)
|
|
88
101
|
if org_id.present?
|
|
89
102
|
self.content_facets_applicable.joins(:host).where("#{::Host.table_name}.organization_id" => org_id)
|
|
@@ -3,7 +3,10 @@ module Katello
|
|
|
3
3
|
self.table_name = 'katello_generic_content_units'
|
|
4
4
|
include Concerns::PulpDatabaseUnit
|
|
5
5
|
|
|
6
|
-
CONTENT_TYPE = '
|
|
6
|
+
CONTENT_TYPE = 'generic'.freeze
|
|
7
|
+
|
|
8
|
+
scoped_search :on => :name, :complete_value => true
|
|
9
|
+
scoped_search :on => :id, :complete_value => true
|
|
7
10
|
|
|
8
11
|
def self.default_sort
|
|
9
12
|
order(:name)
|
|
@@ -177,10 +177,11 @@ module Katello
|
|
|
177
177
|
delegate :name, :created_at, :updated_at, :major, :minor, :gpg_key_id, :gpg_key, :arch, :label, :url, :unprotected,
|
|
178
178
|
:content_type, :product_id, :checksum_type, :docker_upstream_name, :mirror_on_sync, :"mirror_on_sync?",
|
|
179
179
|
:download_policy, :verify_ssl_on_sync, :"verify_ssl_on_sync?", :upstream_username, :upstream_password,
|
|
180
|
-
:ostree_upstream_sync_policy, :ostree_upstream_sync_depth, :deb_releases,
|
|
181
|
-
:
|
|
182
|
-
:ssl_client_key, :ignorable_content, :description, :docker_tags_whitelist,
|
|
183
|
-
:
|
|
180
|
+
:upstream_authentication_token, :ostree_upstream_sync_policy, :ostree_upstream_sync_depth, :deb_releases,
|
|
181
|
+
:deb_components, :deb_architectures, :ssl_ca_cert_id, :ssl_ca_cert, :ssl_client_cert, :ssl_client_cert_id,
|
|
182
|
+
:ssl_client_key_id, :os_versions, :ssl_client_key, :ignorable_content, :description, :docker_tags_whitelist,
|
|
183
|
+
:ansible_collection_requirements, :ansible_collection_auth_url, :ansible_collection_auth_token,
|
|
184
|
+
:http_proxy_policy, :http_proxy_id, :to => :root
|
|
184
185
|
|
|
185
186
|
delegate :content_id, to: :root, allow_nil: true
|
|
186
187
|
delegate :repository_type, to: :root
|
|
@@ -894,8 +895,15 @@ module Katello
|
|
|
894
895
|
end
|
|
895
896
|
|
|
896
897
|
def index_content(options = {})
|
|
898
|
+
# set full_index to true if you want to force fetch all data from pulp
|
|
899
|
+
# This is automatically done for library instance repos
|
|
900
|
+
# However for non-library instance as in those belonging to a version
|
|
901
|
+
# by default we fetch only ids and match them with the library instance
|
|
902
|
+
# some times we want to force fetch all data even for non-library repos.
|
|
903
|
+
# Use the full_index for those times
|
|
904
|
+
|
|
905
|
+
full_index = options.fetch(:full_index, false)
|
|
897
906
|
source_repository = options.fetch(:source_repository, nil)
|
|
898
|
-
|
|
899
907
|
if self.yum? && !self.primary?
|
|
900
908
|
index_linked_repo
|
|
901
909
|
elsif source_repository && !repository_type.unique_content_per_repo
|
|
@@ -904,9 +912,9 @@ module Katello
|
|
|
904
912
|
repository_type.content_types_to_index.each do |type|
|
|
905
913
|
Katello::Logging.time("CONTENT_INDEX", data: {type: type.model_class}) do
|
|
906
914
|
if self.generic?
|
|
907
|
-
type.model_class.import_for_repository(self, type.content_type)
|
|
915
|
+
type.model_class.import_for_repository(self, generic_content_type: type.content_type, full_index: full_index)
|
|
908
916
|
else
|
|
909
|
-
type.model_class.import_for_repository(self)
|
|
917
|
+
type.model_class.import_for_repository(self, full_index: full_index)
|
|
910
918
|
end
|
|
911
919
|
end
|
|
912
920
|
end
|
|
@@ -9,7 +9,7 @@ module Katello
|
|
|
9
9
|
include Ext::LabelFromName
|
|
10
10
|
include Encryptable
|
|
11
11
|
|
|
12
|
-
encrypts :upstream_password
|
|
12
|
+
encrypts :upstream_password, :upstream_authentication_token
|
|
13
13
|
|
|
14
14
|
IGNORABLE_CONTENT_UNIT_TYPES = %w(srpm).freeze
|
|
15
15
|
CHECKSUM_TYPES = %w(sha1 sha256).freeze
|
|
@@ -75,6 +75,7 @@ module Katello
|
|
|
75
75
|
validate :ensure_valid_os_versions
|
|
76
76
|
validate :ensure_content_attribute_restrictions
|
|
77
77
|
validate :ensure_valid_upstream_authorization
|
|
78
|
+
validate :ensure_valid_authentication_token, :if => :yum?
|
|
78
79
|
validate :ensure_no_checksum_on_demand
|
|
79
80
|
validates :url, presence: true, if: :ostree?
|
|
80
81
|
validates :checksum_type, :inclusion => {:in => CHECKSUM_TYPES}, :allow_blank => true
|
|
@@ -294,6 +295,12 @@ module Katello
|
|
|
294
295
|
end
|
|
295
296
|
end
|
|
296
297
|
|
|
298
|
+
def ensure_valid_authentication_token
|
|
299
|
+
if self.upstream_authentication_token.blank?
|
|
300
|
+
self.upstream_authentication_token = nil
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
297
304
|
def custom_content_path
|
|
298
305
|
parts = []
|
|
299
306
|
# We generate repo path only for custom product content. We add this
|
|
@@ -338,7 +345,7 @@ module Katello
|
|
|
338
345
|
end
|
|
339
346
|
|
|
340
347
|
def generic?
|
|
341
|
-
Katello::RepositoryTypeManager.generic_repository_types(
|
|
348
|
+
Katello::RepositoryTypeManager.generic_repository_types(false).values.map(&:id).map(&:to_s).flatten.include? self.content_type
|
|
342
349
|
end
|
|
343
350
|
|
|
344
351
|
def metadata_generate_needed?
|
|
@@ -5,9 +5,9 @@ module Katello
|
|
|
5
5
|
belongs_to :repository, :inverse_of => :yum_metadata_files, :class_name => "Katello::Repository"
|
|
6
6
|
CONTENT_TYPE = "yum_repo_metadata_file".freeze
|
|
7
7
|
|
|
8
|
-
def self.import_for_repository(repository)
|
|
8
|
+
def self.import_for_repository(repository, options = {})
|
|
9
9
|
::Katello::YumMetadataFile.where(:repository_id => repository).destroy_all
|
|
10
|
-
super(repository)
|
|
10
|
+
super(repository, options)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# yum metadata file only has one repo
|
|
@@ -136,9 +136,10 @@ module Katello
|
|
|
136
136
|
|
|
137
137
|
def insert(applicable_ids)
|
|
138
138
|
unless applicable_ids.empty?
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
upserts = applicable_ids.collect do |applicable_id|
|
|
140
|
+
{ content_unit_association_id => applicable_id, :content_facet_id => content_facet.id }
|
|
141
|
+
end
|
|
142
|
+
content_facet_association_class.upsert_all(upserts, unique_by: [content_unit_association_id, :content_facet_id])
|
|
142
143
|
end
|
|
143
144
|
end
|
|
144
145
|
|
|
@@ -3,7 +3,7 @@ module Katello
|
|
|
3
3
|
class Content
|
|
4
4
|
extend Katello::Abstract::Pulp::Content
|
|
5
5
|
class << self
|
|
6
|
-
def create_upload(_size = 0, _checksum = nil, _content_type = nil)
|
|
6
|
+
def create_upload(_size = 0, _checksum = nil, _content_type = nil, _repository = nil)
|
|
7
7
|
pulp_content.create_upload_request
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -4,11 +4,15 @@ module Katello
|
|
|
4
4
|
class Content
|
|
5
5
|
extend Katello::Abstract::Pulp::Content
|
|
6
6
|
class << self
|
|
7
|
-
def create_upload(size = 0, checksum = nil, content_type = nil)
|
|
7
|
+
def create_upload(size = 0, checksum = nil, content_type = nil, repository = nil)
|
|
8
8
|
content_unit_href = nil
|
|
9
9
|
if checksum
|
|
10
10
|
content_backend_service = SmartProxy.pulp_primary.content_service(content_type)
|
|
11
|
-
|
|
11
|
+
if repository&.generic?
|
|
12
|
+
content_list = content_backend_service.content_api(repository.repository_type, content_type).list("sha256": checksum)
|
|
13
|
+
else
|
|
14
|
+
content_list = content_backend_service.content_api.list("sha256": checksum)
|
|
15
|
+
end
|
|
12
16
|
content_unit_href = content_list.results.first.pulp_href unless content_list.results.empty?
|
|
13
17
|
return {"content_unit_href" => content_unit_href} if content_unit_href
|
|
14
18
|
end
|
|
@@ -25,7 +25,9 @@ module Katello
|
|
|
25
25
|
repo_content_list.map { |content| content.try(:pulp_href) }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# rubocop:disable Metrics/AbcSize
|
|
28
29
|
def update_model(model)
|
|
30
|
+
updated = false
|
|
29
31
|
keys = %w(title id severity issued_date type description reboot_suggested solution updated_date summary)
|
|
30
32
|
custom_json = backend_data.slice(*keys)
|
|
31
33
|
custom_json["issued"] = custom_json.delete("issued_date")
|
|
@@ -35,12 +37,15 @@ module Katello
|
|
|
35
37
|
custom_json["issued"] = convert_date_if_epoch(custom_json["issued"])
|
|
36
38
|
custom_json["updated"] = convert_date_if_epoch(custom_json["updated"]) unless custom_json["updated"].blank?
|
|
37
39
|
|
|
40
|
+
custom_json['errata_id'] = custom_json.delete('id')
|
|
41
|
+
custom_json['errata_type'] = custom_json.delete('type')
|
|
42
|
+
custom_json['issued'] = custom_json['issued'].to_datetime.strftime('%Y-%m-%d').to_datetime
|
|
43
|
+
custom_json['updated'] = custom_json['updated'].blank? ? custom_json['issued'] : custom_json['updated'].to_datetime.strftime('%Y-%m-%d').to_datetime
|
|
44
|
+
|
|
38
45
|
if model.updated.blank? ||
|
|
39
|
-
|
|
40
|
-
custom_json['errata_id'] = custom_json.delete('id')
|
|
41
|
-
custom_json['errata_type'] = custom_json.delete('type')
|
|
42
|
-
custom_json['updated'] = custom_json['updated'].blank? ? custom_json['issued'] : custom_json['updated']
|
|
46
|
+
model.attributes.excluding(model.attributes.keys - custom_json.keys) != custom_json
|
|
43
47
|
model.update!(custom_json)
|
|
48
|
+
updated = true
|
|
44
49
|
|
|
45
50
|
unless backend_data['references'].blank?
|
|
46
51
|
update_bugzillas(model, backend_data['references'])
|
|
@@ -49,7 +54,10 @@ module Katello
|
|
|
49
54
|
end
|
|
50
55
|
update_packages(model, backend_data['pkglist']) unless backend_data['pkglist'].blank?
|
|
51
56
|
update_modules(model, backend_data['pkglist']) unless backend_data['pkglist'].blank?
|
|
57
|
+
|
|
58
|
+
return model.id if updated
|
|
52
59
|
end
|
|
60
|
+
# rubocop:enable Metrics/AbcSize
|
|
53
61
|
|
|
54
62
|
def update_bugzillas(model, ref_list)
|
|
55
63
|
ref_list.select { |r| r[:type] == "bugzilla" }.each do |bugzilla|
|
|
@@ -2,7 +2,7 @@ module Katello
|
|
|
2
2
|
module Pulp3
|
|
3
3
|
class GenericContentUnit < PulpContentUnit
|
|
4
4
|
include LazyAccessor
|
|
5
|
-
CONTENT_TYPE = "
|
|
5
|
+
CONTENT_TYPE = "generic".freeze
|
|
6
6
|
|
|
7
7
|
def self.fetch_content_list(page_opts, repository_type, content_type)
|
|
8
8
|
content_unit_list page_opts, repository_type, content_type
|
|
@@ -13,7 +13,13 @@ module Katello
|
|
|
13
13
|
|
|
14
14
|
def self.content_api_create(opts = {})
|
|
15
15
|
relative_path = opts.delete(:relative_path)
|
|
16
|
-
|
|
16
|
+
if Katello::RepositoryTypeManager.generic_content_type?(opts[:content_type])
|
|
17
|
+
repository_type = Katello::Repository.find(opts[:repository_id]).repository_type
|
|
18
|
+
content_type = opts[:content_type]
|
|
19
|
+
self.content_api(repository_type, content_type).create(relative_path, opts)
|
|
20
|
+
else
|
|
21
|
+
self.content_api.create(relative_path, opts)
|
|
22
|
+
end
|
|
17
23
|
end
|
|
18
24
|
|
|
19
25
|
def self.create_content
|
|
@@ -109,6 +115,25 @@ module Katello
|
|
|
109
115
|
def self.fetch_content_list(page_opts)
|
|
110
116
|
content_unit_list page_opts
|
|
111
117
|
end
|
|
118
|
+
|
|
119
|
+
def self.find_duplicate_unit(repository, unit_type_id, file, checksum)
|
|
120
|
+
content_backend_service = SmartProxy.pulp_primary.content_service(unit_type_id)
|
|
121
|
+
duplicates_allowed = ::Katello::RepositoryTypeManager.find_content_type(unit_type_id).try(:duplicates_allowed)
|
|
122
|
+
if repository.generic? && duplicates_allowed
|
|
123
|
+
filename_key = ::Katello::RepositoryTypeManager.find_content_type(unit_type_id).filename_key
|
|
124
|
+
duplicate_sha_path_content_list = content_backend_service.content_api(repository.repository_type, unit_type_id).list(
|
|
125
|
+
"sha256": checksum,
|
|
126
|
+
filename_key => file[:filename])
|
|
127
|
+
elsif repository.generic?
|
|
128
|
+
duplicate_sha_path_content_list = content_backend_service.content_api(repository.repository_type, unit_type_id).list(
|
|
129
|
+
"sha256": checksum)
|
|
130
|
+
else
|
|
131
|
+
duplicate_sha_path_content_list = content_backend_service.content_api.list(
|
|
132
|
+
"sha256": checksum,
|
|
133
|
+
"relative_path": file[:filename])
|
|
134
|
+
end
|
|
135
|
+
duplicate_sha_path_content_list
|
|
136
|
+
end
|
|
112
137
|
end
|
|
113
138
|
end
|
|
114
139
|
end
|
|
@@ -22,6 +22,12 @@ module Katello
|
|
|
22
22
|
common_remote_options.merge(deb_remote_options)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
def mirror_remote_options
|
|
26
|
+
{
|
|
27
|
+
distributions: repo.deb_releases + "#{' default' unless repo.deb_releases.include? 'default'}"
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
def publication_options(repository_version)
|
|
26
32
|
ss = api.signing_services_api.list(name: SIGNING_SERVICE_NAME).results
|
|
27
33
|
popts = super(repository_version)
|
|
@@ -35,6 +41,16 @@ module Katello
|
|
|
35
41
|
popts
|
|
36
42
|
end
|
|
37
43
|
|
|
44
|
+
def mirror_publication_options
|
|
45
|
+
{
|
|
46
|
+
# Since we are synchronizing the "default" distribution from the simple publisher on the server,
|
|
47
|
+
# it will be included in the structured publish. Therefore, we MUST NOT use the simple publisher
|
|
48
|
+
# on the proxy, since this would collide!
|
|
49
|
+
#simple: true,
|
|
50
|
+
structured: true # publish real suites (e.g. 'stable')
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
38
54
|
def distribution_options(path)
|
|
39
55
|
{
|
|
40
56
|
base_path: path,
|
|
@@ -11,24 +11,18 @@ module Katello
|
|
|
11
11
|
UNIT_LIMIT = 10_000
|
|
12
12
|
|
|
13
13
|
def remote_options
|
|
14
|
-
url, sles_token = extract_sles_token
|
|
15
14
|
options = common_remote_options
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
uri = URI(root.url)
|
|
16
|
+
unless root.upstream_authentication_token.blank?
|
|
17
|
+
options.merge!(sles_auth_token: root.upstream_authentication_token)
|
|
18
|
+
end
|
|
19
|
+
options.merge!(url: uri.to_s, policy: root.download_policy)
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def specific_create_options
|
|
21
23
|
{ retain_package_versions: retain_package_versions_count }
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
def extract_sles_token
|
|
25
|
-
return [nil, nil] if root.url.blank?
|
|
26
|
-
uri = URI(root.url)
|
|
27
|
-
query = uri.query
|
|
28
|
-
uri.query = nil
|
|
29
|
-
[uri.to_s, query]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
26
|
def skip_types
|
|
33
27
|
skip_types = []
|
|
34
28
|
if root.ignorable_content.try(:include?, "srpm")
|
|
@@ -303,14 +297,15 @@ module Katello
|
|
|
303
297
|
blacklist_ids = filter_list_map[:blacklist_ids].flatten&.uniq
|
|
304
298
|
content_unit_hrefs = whitelist_ids - blacklist_ids
|
|
305
299
|
|
|
300
|
+
source_repo_ids.each do |source_repo_id|
|
|
301
|
+
content_unit_hrefs += ::Katello::Repository.find(source_repo_id).srpms.pluck(:pulp_id)
|
|
302
|
+
end
|
|
303
|
+
|
|
306
304
|
if content_unit_hrefs.any?
|
|
307
305
|
source_repo_ids.each do |source_repo_id|
|
|
308
306
|
content_unit_hrefs += additional_content_hrefs(::Katello::Repository.find(source_repo_id), content_unit_hrefs)
|
|
309
307
|
end
|
|
310
308
|
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
309
|
|
|
315
310
|
dest_repo_map[:content_unit_hrefs] = content_unit_hrefs.uniq.sort
|
|
316
311
|
end
|
|
@@ -348,10 +343,10 @@ module Katello
|
|
|
348
343
|
whitelist_ids += modular_packages(source_repository, inclusion_modular_filters) unless inclusion_modular_filters.empty?
|
|
349
344
|
blacklist_ids += modular_packages(source_repository, exclusion_modular_filters) unless exclusion_modular_filters.empty?
|
|
350
345
|
content_unit_hrefs = whitelist_ids - blacklist_ids
|
|
346
|
+
content_unit_hrefs += source_repository.srpms.pluck(:pulp_id)
|
|
351
347
|
if content_unit_hrefs.any?
|
|
352
348
|
content_unit_hrefs += additional_content_hrefs(source_repository, content_unit_hrefs)
|
|
353
349
|
end
|
|
354
|
-
content_unit_hrefs += source_repository.srpms.pluck(:pulp_id)
|
|
355
350
|
copy_units(source_repository, content_unit_hrefs.uniq, options[:remove_all])
|
|
356
351
|
end
|
|
357
352
|
|
|
@@ -368,18 +363,22 @@ module Katello
|
|
|
368
363
|
options = { :repository_version => source_repository.version_href }
|
|
369
364
|
|
|
370
365
|
errata_to_include = filter_errata_by_pulp_href(source_repository.errata, content_unit_hrefs,
|
|
371
|
-
source_repository.rpms.pluck(:filename)
|
|
372
|
-
|
|
366
|
+
source_repository.rpms.pluck(:filename) +
|
|
367
|
+
source_repository.srpms.pluck(:filename))
|
|
368
|
+
content_unit_hrefs += errata_to_include.collect do |erratum|
|
|
369
|
+
erratum.repository_errata.where(repository_id: source_repository.id).pluck(:erratum_pulp3_href)
|
|
370
|
+
end
|
|
371
|
+
content_unit_hrefs.flatten!
|
|
373
372
|
|
|
374
373
|
package_groups_to_include = filter_package_groups_by_pulp_href(source_repository.package_groups, content_unit_hrefs)
|
|
375
374
|
content_unit_hrefs += package_groups_to_include.pluck(:pulp_id)
|
|
376
375
|
|
|
377
376
|
metadata_file_hrefs_to_include = filter_metadatafiles_by_pulp_hrefs(
|
|
378
|
-
repo_service.metadatafiles(options)
|
|
377
|
+
repo_service.metadatafiles(options)&.results, content_unit_hrefs)
|
|
379
378
|
content_unit_hrefs += metadata_file_hrefs_to_include
|
|
380
379
|
|
|
381
380
|
distribution_tree_hrefs_to_include = filter_distribution_trees_by_pulp_hrefs(
|
|
382
|
-
repo_service.distributiontrees(options)
|
|
381
|
+
repo_service.distributiontrees(options)&.results, content_unit_hrefs)
|
|
383
382
|
content_unit_hrefs + distribution_tree_hrefs_to_include
|
|
384
383
|
end
|
|
385
384
|
end
|
|
@@ -143,9 +143,17 @@ module Katello
|
|
|
143
143
|
uri.to_s
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
+
def publication_options(repository_version)
|
|
147
|
+
popts = {repository_version: repository_version}
|
|
148
|
+
if (type_specific_options = repo_service.try(:mirror_publication_options))
|
|
149
|
+
popts.merge!(type_specific_options)
|
|
150
|
+
end
|
|
151
|
+
popts
|
|
152
|
+
end
|
|
153
|
+
|
|
146
154
|
def create_publication
|
|
147
155
|
if (href = version_href)
|
|
148
|
-
publication_data = api.class.publication_class.new(
|
|
156
|
+
publication_data = api.class.publication_class.new(publication_options(href))
|
|
149
157
|
api.publications_api.create(publication_data)
|
|
150
158
|
end
|
|
151
159
|
end
|
|
@@ -50,11 +50,11 @@ module Katello
|
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
def default_managed_content_type(
|
|
54
|
-
if
|
|
55
|
-
@
|
|
53
|
+
def default_managed_content_type(label = nil)
|
|
54
|
+
if label
|
|
55
|
+
@default_managed_content_type_label = label.to_s
|
|
56
56
|
else
|
|
57
|
-
@content_types.find { |content_type| content_type.
|
|
57
|
+
@content_types.find { |content_type| content_type.label == @default_managed_content_type_label }
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -122,7 +122,7 @@ module Katello
|
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
class GenericContentType < ContentType
|
|
125
|
-
attr_accessor :pulp3_api, :pulp3_model, :content_type
|
|
125
|
+
attr_accessor :pulp3_api, :pulp3_model, :content_type, :filename_key, :duplicates_allowed
|
|
126
126
|
|
|
127
127
|
def initialize(options)
|
|
128
128
|
self.model_class = options[:model_class]
|
|
@@ -135,10 +135,12 @@ module Katello
|
|
|
135
135
|
self.pulp3_api = options[:pulp3_api]
|
|
136
136
|
self.pulp3_model = options[:pulp3_model]
|
|
137
137
|
self.content_type = options[:content_type]
|
|
138
|
+
self.filename_key = options[:filename_key]
|
|
139
|
+
self.duplicates_allowed = options[:duplicates_allowed]
|
|
138
140
|
end
|
|
139
141
|
|
|
140
142
|
def label
|
|
141
|
-
self.
|
|
143
|
+
self.content_type
|
|
142
144
|
end
|
|
143
145
|
end
|
|
144
146
|
|
|
@@ -4,40 +4,37 @@ module Katello
|
|
|
4
4
|
|
|
5
5
|
@defined_repository_types = {}
|
|
6
6
|
@enabled_repository_types = {}
|
|
7
|
-
|
|
8
|
-
@pulp_primary = ::SmartProxy.unscoped.detect { |proxy| !proxy.setting(PULP3_FEATURE, 'mirror') }
|
|
9
|
-
rescue ActiveRecord::StatementInvalid
|
|
10
|
-
@pulp_primary = nil
|
|
11
|
-
end
|
|
7
|
+
|
|
12
8
|
class << self
|
|
13
9
|
private :new
|
|
14
10
|
attr_reader :defined_repository_types
|
|
15
11
|
|
|
12
|
+
def pulp_primary
|
|
13
|
+
::SmartProxy.pulp_primary
|
|
14
|
+
end
|
|
15
|
+
|
|
16
16
|
# Plugin constructor
|
|
17
17
|
def register(id, &block)
|
|
18
|
-
if @pulp_primary&.has_feature?(PULP3_FEATURE) && @pulp_primary&.capabilities(PULP3_FEATURE)&.empty?
|
|
19
|
-
fix_pulp3_capabilities
|
|
20
|
-
end
|
|
21
18
|
defined_repo_type = find_defined(id)
|
|
22
19
|
if defined_repo_type.blank?
|
|
23
20
|
defined_repo_type = ::Katello::RepositoryType.new(id)
|
|
24
21
|
defined_repo_type.instance_eval(&block) if block_given?
|
|
25
22
|
@defined_repository_types[id.to_s] = defined_repo_type
|
|
26
23
|
end
|
|
27
|
-
if find(id).blank? && defined_repo_type.present?
|
|
28
|
-
enabled_repository_types[id.to_s] = defined_repo_type if pulp3_plugin_installed?(id)
|
|
29
|
-
end
|
|
30
24
|
end
|
|
31
25
|
|
|
32
26
|
def fix_pulp3_capabilities
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if @pulp_primary&.capabilities(PULP3_FEATURE)&.empty?
|
|
27
|
+
pulp_primary&.refresh
|
|
28
|
+
if pulp_primary&.capabilities(PULP3_FEATURE)&.empty?
|
|
36
29
|
fail Katello::Errors::PulpcoreMissingCapabilities
|
|
37
30
|
end
|
|
38
31
|
end
|
|
39
32
|
|
|
40
33
|
def enabled_repository_types(update = true)
|
|
34
|
+
if update && pulp_primary&.has_feature?(PULP3_FEATURE) && pulp_primary&.capabilities(PULP3_FEATURE)&.empty?
|
|
35
|
+
fix_pulp3_capabilities
|
|
36
|
+
end
|
|
37
|
+
|
|
41
38
|
disabled_types = @defined_repository_types.keys - @enabled_repository_types.keys
|
|
42
39
|
if update && disabled_types.present?
|
|
43
40
|
disabled_types.each { |repo_type| update_enabled_repository_type(repo_type.to_s) }
|
|
@@ -60,8 +57,7 @@ module Katello
|
|
|
60
57
|
end
|
|
61
58
|
|
|
62
59
|
def pulp3_plugin_installed?(repository_type)
|
|
63
|
-
|
|
64
|
-
@pulp_primary&.capabilities(PULP3_FEATURE)&.include?(@defined_repository_types[repository_type].pulp3_plugin)
|
|
60
|
+
pulp_primary&.capabilities(PULP3_FEATURE)&.include?(@defined_repository_types[repository_type].pulp3_plugin)
|
|
65
61
|
end
|
|
66
62
|
|
|
67
63
|
def enabled_content_types(enabled_only = true)
|
|
@@ -79,6 +75,19 @@ module Katello
|
|
|
79
75
|
flatten
|
|
80
76
|
end
|
|
81
77
|
|
|
78
|
+
def generic_content_types(enabled_only = true)
|
|
79
|
+
repo_types = enabled_only ? enabled_repository_types : defined_repository_types
|
|
80
|
+
list = repo_types.values.map do |type|
|
|
81
|
+
type.content_types.select { |ct| ct.model_class::CONTENT_TYPE == Katello::GenericContentUnit::CONTENT_TYPE }
|
|
82
|
+
end
|
|
83
|
+
list.flatten.map(&:content_type)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def generic_content_type?(content_type, enabled_only = true)
|
|
87
|
+
types = generic_content_types(enabled_only)
|
|
88
|
+
types.include?(content_type)
|
|
89
|
+
end
|
|
90
|
+
|
|
82
91
|
def creatable_by_user?(repository_type, enabled_only = true)
|
|
83
92
|
type = enabled_only ? find(repository_type) : find_defined(repository_type)
|
|
84
93
|
return false unless type
|
|
@@ -181,12 +190,6 @@ module Katello
|
|
|
181
190
|
@enabled_repository_types[repository_type.to_s] = defined_repo_type
|
|
182
191
|
end
|
|
183
192
|
end
|
|
184
|
-
|
|
185
|
-
def save_pulp_primary
|
|
186
|
-
@pulp_primary = ::SmartProxy.unscoped.detect { |proxy| !proxy.setting(PULP3_FEATURE, 'mirror') }
|
|
187
|
-
rescue ActiveRecord::StatementInvalid
|
|
188
|
-
@pulp_primary = nil
|
|
189
|
-
end
|
|
190
193
|
end
|
|
191
194
|
end
|
|
192
195
|
end
|
|
@@ -80,7 +80,8 @@ node :upstream_password_exists do |repo|
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
node :upstream_auth_exists do |repo|
|
|
83
|
-
repo.upstream_username.present? && repo.upstream_password.present?
|
|
83
|
+
(repo.upstream_username.present? && repo.upstream_password.present?) ||
|
|
84
|
+
repo.upstream_authentication_token.present?
|
|
84
85
|
end
|
|
85
86
|
|
|
86
87
|
if @object && @object.library_instance_id.nil?
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Rails.application.config.filter_parameters += [:upstream_authentication_token]
|
data/config/routes/api/v2.rb
CHANGED
|
@@ -275,6 +275,15 @@ Katello::Engine.routes.draw do
|
|
|
275
275
|
end
|
|
276
276
|
end
|
|
277
277
|
|
|
278
|
+
Katello::RepositoryTypeManager.generic_content_types(false).each do |type|
|
|
279
|
+
api_resources type.pluralize.to_sym, :only => [:index, :show], :controller => 'generic_content_units', :content_type => type do
|
|
280
|
+
collection do
|
|
281
|
+
get :auto_complete_search
|
|
282
|
+
get :compare
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
|
|
278
287
|
match "/ping" => "katello_ping#index", :via => :get
|
|
279
288
|
match "/status" => "katello_ping#server_status", :via => :get
|
|
280
289
|
|
|
@@ -392,7 +401,9 @@ Katello::Engine.routes.draw do
|
|
|
392
401
|
api_resources :debs, :only => [:index, :show]
|
|
393
402
|
api_resources :module_streams, :only => [:index, :show]
|
|
394
403
|
api_resources :ansible_collections, :only => [:index, :show]
|
|
395
|
-
|
|
404
|
+
Katello::RepositoryTypeManager.generic_content_types(false).each do |type|
|
|
405
|
+
api_resources type.pluralize.to_sym, :only => [:index, :show], :controller => 'generic_content_units', :content_type => type
|
|
406
|
+
end
|
|
396
407
|
api_resources :ostree_branches, :only => [:index, :show]
|
|
397
408
|
|
|
398
409
|
api_resources :content_uploads, :controller => :content_uploads, :only => [:create, :destroy, :update]
|
|
@@ -2,7 +2,7 @@ class FixRedHatRootRepositoryArch < ActiveRecord::Migration[6.0]
|
|
|
2
2
|
def up
|
|
3
3
|
::Katello::RootRepository.
|
|
4
4
|
joins("INNER JOIN katello_contents ON katello_contents.cp_content_id = katello_root_repositories.content_id").
|
|
5
|
-
where.not(arch: 'noarch').where.not("katello_contents.content_url ILIKE '%$basearch%'").
|
|
5
|
+
where.not(arch: 'noarch').where.not("katello_contents.content_url ILIKE '%$basearch%'").update_all(arch: 'noarch')
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def down
|
|
@@ -4,6 +4,8 @@ UpgradeTask.define_tasks(:katello) do
|
|
|
4
4
|
{:name => 'katello:clean_backend_objects', :long_running => true, :skip_failure => true, :always_run => true},
|
|
5
5
|
{:name => 'katello:upgrades:4.0:remove_ostree_puppet_content'},
|
|
6
6
|
{:name => 'katello:upgrades:4.1:sync_noarch_content'},
|
|
7
|
-
{:name => 'katello:upgrades:4.1:fix_invalid_pools'}
|
|
7
|
+
{:name => 'katello:upgrades:4.1:fix_invalid_pools'},
|
|
8
|
+
{:name => 'katello:upgrades:4.1:reupdate_content_import_export_perms'},
|
|
9
|
+
{:name => 'katello:upgrades:4.2:remove_checksum_values'}
|
|
8
10
|
]
|
|
9
11
|
end
|