katello 3.18.0 → 3.18.3

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.

Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/katello/katello.scss +0 -72
  3. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +2 -2
  4. data/app/controllers/katello/api/v2/api_controller.rb +1 -2
  5. data/app/controllers/katello/api/v2/content_view_filters_controller.rb +1 -1
  6. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +2 -1
  7. data/app/controllers/katello/concerns/api/v2/authorization.rb +14 -1
  8. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +7 -2
  9. data/app/lib/actions/katello/content_view_version/incremental_update.rb +19 -3
  10. data/app/lib/actions/katello/host/update_system_purpose.rb +1 -1
  11. data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +1 -1
  12. data/app/lib/actions/katello/repository/sync.rb +5 -1
  13. data/app/lib/actions/middleware/record_smart_proxy_sync_history.rb +24 -4
  14. data/app/lib/actions/pulp3/content_migration_reset.rb +22 -0
  15. data/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +4 -2
  16. data/app/lib/actions/pulp3/orchestration/content_view_version/import.rb +0 -4
  17. data/app/lib/katello/util/pulpcore_content_filters.rb +1 -1
  18. data/app/models/katello/concerns/hostgroup_extensions.rb +1 -1
  19. data/app/models/katello/concerns/pulp_database_unit.rb +19 -0
  20. data/app/models/katello/concerns/redhat_extensions.rb +2 -2
  21. data/app/models/katello/concerns/smart_proxy_extensions.rb +3 -1
  22. data/app/models/katello/file_unit.rb +4 -0
  23. data/app/models/katello/host/content_facet.rb +9 -31
  24. data/app/models/katello/host/subscription_facet.rb +4 -0
  25. data/app/models/katello/ping.rb +35 -15
  26. data/app/models/katello/subscription_status.rb +3 -2
  27. data/app/services/katello/applicability/applicable_content_helper.rb +52 -21
  28. data/app/services/katello/pulp3/api/core.rb +14 -0
  29. data/app/services/katello/pulp3/content_view_version/import_validator.rb +0 -30
  30. data/app/services/katello/pulp3/erratum.rb +2 -1
  31. data/app/services/katello/pulp3/migration.rb +63 -7
  32. data/app/services/katello/pulp3/migration_plan.rb +2 -2
  33. data/app/services/katello/pulp3/migration_switchover.rb +36 -5
  34. data/app/services/katello/pulp3/repository.rb +40 -10
  35. data/app/services/katello/pulp3/repository/apt.rb +1 -2
  36. data/app/services/katello/pulp3/repository/yum.rb +10 -1
  37. data/app/services/katello/pulp3/rpm.rb +5 -1
  38. data/app/services/katello/pulp3/task.rb +8 -5
  39. data/app/services/katello/pulp3/task_group.rb +13 -5
  40. data/app/views/katello/api/v2/content_views/show.json.rabl +6 -0
  41. data/app/views/katello/sync_management/_products.html.erb +1 -1
  42. data/db/migrate/20150930183738_migrate_content_hosts.rb +1 -1
  43. data/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb +5 -2
  44. data/db/migrate/20210201165835_add_migration_missing_content.rb +12 -0
  45. data/db/migrate/20210420140050_add_pulp3_hrefs_to_content_types_deb.rb +5 -0
  46. data/engines/bastion/app/assets/javascripts/bastion/auth/authorization.service.js +1 -1
  47. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/common/views/katello-agent-notice.html +1 -1
  48. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-system-purpose-modal.html +35 -40
  49. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register-client.html +1 -1
  50. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/content-view-version-deletion-activation-keys.controller.js +8 -3
  51. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/content-view-version-deletion-content-hosts.controller.js +9 -3
  52. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details.html +1 -1
  53. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-publish.html +4 -0
  54. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +1 -1
  55. data/lib/katello/engine.rb +1 -1
  56. data/lib/katello/tasks/check_config.rake +18 -0
  57. data/lib/katello/tasks/delete_orphaned_content.rake +1 -3
  58. data/lib/katello/tasks/pulp3_content_switchover.rake +7 -3
  59. data/lib/katello/tasks/pulp3_migration.rake +12 -3
  60. data/lib/katello/tasks/pulp3_migration_abort.rake +1 -1
  61. data/lib/katello/tasks/pulp3_migration_approve_corrupted.rake +16 -0
  62. data/lib/katello/tasks/pulp3_migration_reset.rake +26 -0
  63. data/lib/katello/tasks/pulp3_migration_stats.rake +37 -3
  64. data/lib/katello/tasks/pulp3_post_migration_check.rake +1 -3
  65. data/lib/katello/tasks/reimport.rake +1 -1
  66. data/lib/katello/tasks/reports.rake +4 -1
  67. data/lib/katello/tasks/repository.rake +3 -5
  68. data/lib/katello/version.rb +1 -1
  69. data/webpack/components/TypeAhead/TypeAhead.js +2 -1
  70. data/webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js +2 -1
  71. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +7 -2
  72. data/webpack/scenes/Subscriptions/Manifest/index.js +1 -0
  73. metadata +22 -17
  74. data/lib/katello/tasks/common.rake +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbd0716cd63dcfb9f135e084f2dcd07401019b45f4a0c6c4f61ddf0953fbb00b
4
- data.tar.gz: d7ae76869fc68b2046637b8eb116f9f23048b0f5dce7042b3c65d77556d9d7c4
3
+ metadata.gz: a81840cf9dd6dd5b365f58ff15fcb56479a8a4d28222aaacd1c62f8601684a9a
4
+ data.tar.gz: f11313470e9660b9a88f0e992cb9f7ea85545b48f7b7148bcf29c4a1e40a7cd7
5
5
  SHA512:
6
- metadata.gz: b86b93fe297e88ea9c5bac35ae1dbc746ffd2ddcbfdd06046552cef774153182ab5938483ff6663d6d382613603066ede7a0cccc99386d3def6c63db46194f2b
7
- data.tar.gz: 3813c0ec50e517fbe18575d033322e0ee7df5f63b5aad7abe514e62eda523339e6f3d9a54c1734e5fdc07031217fff59ece0dc17b4d02f1e28b86db93dbb13dd
6
+ metadata.gz: 48801531bfad55800f818b0cd7570dc9710bfa9853d87850936aadc95f01d538bc2235681785a8a7d6744143fc6365d4750afc37754d486f8cfe92f231b66051
7
+ data.tar.gz: 8fa055b8365689b7781c63b9c115a28bcccd858c274e1ded11b7c226f58efe3d2a787daf7eb754483c379d9e82bfa8028b23d917e7f8ad6ac77a07ba6eb6c44d
@@ -163,78 +163,6 @@ input:focus {
163
163
  @extend .status_exclamation_icon;
164
164
  }
165
165
 
166
- /* BUTTONS */
167
- input[type='submit'], button, .button {
168
- font-size: 10px;
169
- display: inline-block;
170
- vertical-align: bottom;
171
- background: -moz-linear-gradient(top, #f9f9f9, #f0f0f0, #e5e5e5, #e9e9e9);
172
- background: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), color-stop(0.9, #e5e5e5), to(#e9e9e9));
173
- box-shadow: none;
174
- border: 1px solid darken($stroke_color, 20%);
175
- color: #221e1f;
176
- cursor: pointer;
177
- padding: 4px 8px;
178
- border-radius: 5px;
179
- text-shadow: 0 1px 0 rgba($white_color, 1);
180
- min-height: 14px;
181
- .nomargin {
182
- margin: 0;
183
- }
184
- &:hover {
185
- background: -moz-linear-gradient(top, $white_color, $white_color, #cfcfcf);
186
- background: -webkit-gradient(linear, left top, left bottom, from($white_color), color-stop(0.6, $white_color), to(#cfcfcf));
187
- box-shadow: 0 1px 2px rgba(0,0,0,0.5);
188
- text-decoration: none;
189
- color: black;
190
- }
191
- &:active {
192
- background: -moz-linear-gradient(top, #c2c3c0, #e4e5e4);
193
- background: -webkit-gradient(linear, left top, left bottom, from(#c2c3c0), to(#e4e5e4));
194
- box-shadow: none;
195
- text-decoration: none;
196
- }
197
- &:focus {
198
- text-decoration: none;
199
- color: #000;
200
- border-width: 2px;
201
- }
202
- &.dialogbutton {
203
- float: right;
204
- margin-left: 3px;
205
- margin: 40px 4px 4px;
206
- }
207
- &.formbutton {
208
- display: inline-block;
209
- margin-left: 3px;
210
- margin: 40px 4px 4px;
211
- }
212
- &.actionlink {
213
- margin: 40px 0 0;
214
- }
215
- &.disabled, &[disabled] {
216
- cursor: default;
217
- background: transparent;
218
- opacity: 0.4;
219
-
220
- &:hover {
221
- background: transparent;
222
- box-shadow: none;
223
- }
224
- }
225
- &.iconbutton {
226
- display: inline-block;
227
- }
228
- &.tiny {
229
- padding: 4px;
230
- margin: 0;
231
- &:active, &:focus {
232
- margin: 0;
233
- padding: 3px;
234
- }
235
- }
236
- }
237
-
238
166
  table {
239
167
  border-collapse: collapse;
240
168
  border: 1px solid $stroke_color;
@@ -184,8 +184,8 @@ module Katello
184
184
  'application/vnd.docker.distribution.manifest.v1+prettyjws'
185
185
  end
186
186
  end
187
-
188
- render json: manifest_response, content_type: media_type
187
+ response.headers['Content-Type'] = media_type
188
+ render json: manifest_response
189
189
  end
190
190
  end
191
191
 
@@ -39,8 +39,7 @@ module Katello
39
39
  end
40
40
 
41
41
  def deprecate_katello_agent
42
- ::Foreman::Deprecation.api_deprecation_warning("Remote actions using katello-agent are deprecated and will be removed in Katello 4.0. " \
43
- "You may consider switching to Remote Execution.")
42
+ ::Foreman::Deprecation.api_deprecation_warning("Katello-agent is deprecated and will be removed in a future release.")
44
43
  end
45
44
 
46
45
  def full_result_response(collection)
@@ -73,7 +73,7 @@ module Katello
73
73
  respond :resource => @filter
74
74
  end
75
75
 
76
- api :delefind_filterte, "/content_views/:content_view_id/filters/:id", N_("delete a filter")
76
+ api :delete, "/content_views/:content_view_id/filters/:id", N_("delete a filter")
77
77
  api :delete, "/content_view_filters/:id", N_("delete a filter")
78
78
  param :content_view_id, :number, :desc => N_("content view identifier")
79
79
  param :id, :number, :desc => N_("filter identifier"), :required => true
@@ -267,8 +267,9 @@ module Katello
267
267
  api :POST, "/hosts/bulk/available_incremental_updates", N_("Given a set of hosts and errata, lists the content view versions" \
268
268
  " and environments that need updating.")
269
269
  param_group :bulk_params
270
- param :errata_ids, Array, :desc => N_("List of Errata ids")
270
+ param :errata_ids, Array, :desc => N_("List of Errata ids"), :required => true
271
271
  def available_incremental_updates
272
+ fail HttpErrors::BadRequest, _("errata_ids is a required parameter") if params[:errata_ids].empty?
272
273
  version_environments = {}
273
274
  content_facets = Katello::Host::ContentFacet.with_non_installable_errata(@errata, @hosts)
274
275
 
@@ -39,7 +39,20 @@ module Katello
39
39
  end
40
40
 
41
41
  def throw_resource_not_found(name: resource_name, id: params[:id])
42
- fail HttpErrors::NotFound, _("Could not find %{name} resource with id %{id}") % {id: id, name: name}
42
+ perms_message = "Potential missing permissions: " +
43
+ missing_permissions.map(&:name).join(', ')
44
+ fail HttpErrors::NotFound, _("Could not find %{name} resource with id %{id}. %{perms_message}") % {id: id, name: name, perms_message: perms_message}
45
+ end
46
+
47
+ def missing_permissions
48
+ missing_perms = ::Foreman::AccessControl.permissions_for_controller_action(path_to_authenticate)
49
+
50
+ # promote_or_remove_content_views_to_environments has a special relationship to promote_or_remove_content_views
51
+ if path_to_authenticate["controller"] == "katello/api/v2/content_view_versions" &&
52
+ path_to_authenticate["action"].in?(["promote", "remove_from_environment", "remove", "republish_repositories"])
53
+ missing_perms << ::Permission.find_by(name: "promote_or_remove_content_views_to_environments")
54
+ end
55
+ missing_perms
43
56
  end
44
57
 
45
58
  def throw_resources_not_found(name:, expected_ids: [])
@@ -19,9 +19,14 @@ module Actions
19
19
  Actions::Pulp3::CapsuleContent::Sync],
20
20
  repo, smart_proxy,
21
21
  skip_metadata_check: skip_metadata_check)
22
+ end
23
+ end
24
+
25
+ concurrence do
26
+ repo_batch.each do |repo|
22
27
  if repo.is_a?(::Katello::Repository) &&
23
- repo.distribution_bootable? &&
24
- repo.download_policy == ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND
28
+ repo.distribution_bootable? &&
29
+ repo.download_policy == ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND
25
30
  plan_action(Katello::Repository::FetchPxeFiles,
26
31
  id: repo.id,
27
32
  capsule_id: smart_proxy.id)
@@ -352,20 +352,36 @@ module Actions
352
352
  end
353
353
 
354
354
  def copy_yum_content(new_repo, dep_solve, package_ids, errata_ids)
355
+ return [] unless new_repo.content_type == ::Katello::Repository::YUM_TYPE
356
+
355
357
  copy_outputs = []
356
- if new_repo.content_type == ::Katello::Repository::YUM_TYPE
357
- unless errata_ids.blank?
358
+
359
+ unless errata_ids.blank?
360
+ content_present_in_this_repo = new_repo
361
+ .library_instance
362
+ .errata
363
+ .with_identifiers(errata_ids)
364
+ .exists?
365
+ if content_present_in_this_repo
358
366
  copy_outputs << plan_action(Pulp::Repository::CopyUnits, new_repo.library_instance, new_repo,
359
367
  ::Katello::Erratum.with_identifiers(errata_ids),
360
368
  incremental_update: dep_solve).output
361
369
  end
370
+ end
362
371
 
363
- unless package_ids.blank?
372
+ unless package_ids.blank?
373
+ content_present_in_this_repo = new_repo
374
+ .library_instance
375
+ .rpms
376
+ .with_identifiers(package_ids)
377
+ .exists?
378
+ if content_present_in_this_repo
364
379
  copy_outputs << plan_action(Pulp::Repository::CopyUnits, new_repo.library_instance, new_repo,
365
380
  ::Katello::Rpm.with_identifiers(package_ids),
366
381
  incremental_update: dep_solve).output
367
382
  end
368
383
  end
384
+
369
385
  copy_outputs
370
386
  end
371
387
 
@@ -14,7 +14,7 @@ module Actions
14
14
  host.subscription_facet.purpose_addons = purpose_addon_objects
15
15
  end
16
16
 
17
- host.subscription_facet.save!
17
+ host.save!
18
18
  plan_self(:hostname => host.name)
19
19
  end
20
20
 
@@ -8,7 +8,7 @@ module Actions
8
8
  def plan(proxy)
9
9
  sequence do
10
10
  plan_action(Actions::Pulp::Orchestration::OrphanCleanup::RemoveOrphans, proxy)
11
- if proxy.pulp3_enabled?
11
+ if proxy.pulp3_enabled? && ::Katello::Ping.pulpcore_enabled
12
12
  plan_action(
13
13
  Actions::Pulp3::Orchestration::OrphanCleanup::RemoveOrphans,
14
14
  proxy)
@@ -72,7 +72,11 @@ module Actions
72
72
  end
73
73
  plan_self(:id => repo.id, :sync_result => output, :skip_metadata_check => skip_metadata_check, :validate_contents => validate_contents,
74
74
  :contents_changed => contents_changed)
75
- plan_action(Katello::Repository::ImportApplicability, :repo_id => repo.id, :contents_changed => contents_changed) if generate_applicability
75
+
76
+ if generate_applicability && !SETTINGS[:katello][:katello_applicability]
77
+ plan_action(Katello::Repository::ImportApplicability, :repo_id => repo.id, :contents_changed => contents_changed)
78
+ end
79
+
76
80
  plan_action(Katello::Repository::SyncHook, :id => repo.id)
77
81
  end
78
82
  end
@@ -1,12 +1,32 @@
1
1
  module Actions
2
2
  module Middleware
3
3
  class RecordSmartProxySyncHistory < Dynflow::Middleware
4
- def run(*args)
4
+ def save_smart_proxy_sync_history
5
5
  if (action.input[:repository_id] && (action.input[:smart_proxy_id] || action.input[:capsule_id]) && !self.action.output[:smart_proxy_history_id])
6
- repo = ::Katello::Repository.find(action.input[:repository_id])
6
+ repo_id = action.input[:repository_id]
7
+ repo = ::Katello::Repository.find_by(id: repo_id)
7
8
  smart_proxy_id = action.input[:smart_proxy_id] || action.input[:capsule_id]
8
- smart_proxy = ::SmartProxy.find(smart_proxy_id)
9
- self.action.output[:smart_proxy_history_id] = repo.create_smart_proxy_sync_history(smart_proxy)
9
+ smart_proxy = ::SmartProxy.find_by(id: smart_proxy_id)
10
+
11
+ #skip pulp2 puppet syncs
12
+ if (repo_pulp_id = action.input[:repo_pulp_id])
13
+ return if ::Katello::ContentViewPuppetEnvironment.find_by(pulp_id: repo_pulp_id)
14
+ end
15
+
16
+ if repo && smart_proxy
17
+ self.action.output[:smart_proxy_history_id] = repo.create_smart_proxy_sync_history(smart_proxy)
18
+ else
19
+ fail "Smart Proxy could not be found with id #{smart_proxy_id}" if smart_proxy.nil?
20
+ fail "Repository could not be found with id #{repo_id}" if repo.nil?
21
+ end
22
+ end
23
+ end
24
+
25
+ def run(*args)
26
+ begin
27
+ save_smart_proxy_sync_history
28
+ rescue => error
29
+ Rails.logger.error("Error saving smart proxy history: #{error.message}")
10
30
  end
11
31
  pass(*args)
12
32
  end
@@ -0,0 +1,22 @@
1
+ module Actions
2
+ module Pulp3
3
+ class ContentMigrationReset < Pulp3::AbstractAsyncTask
4
+ def plan(smart_proxy)
5
+ plan_self(smart_proxy_id: smart_proxy.id)
6
+ end
7
+
8
+ def invoke_external_task
9
+ migration_service = ::Katello::Pulp3::Migration.new(smart_proxy)
10
+ migration_service.reset
11
+ end
12
+
13
+ def humanized_name
14
+ _("Content Migration Reset")
15
+ end
16
+
17
+ def rescue_strategy
18
+ Dynflow::Action::Rescue::Skip
19
+ end
20
+ end
21
+ end
22
+ end
@@ -76,8 +76,10 @@ module Actions
76
76
  content_view_version: cvv,
77
77
  smart_proxy: smart_proxy,
78
78
  from_content_view_version: from_cvv).generate_metadata
79
- toc = Dir.glob("#{path}/*toc.json").first
80
- export_metadata[:toc] = File.basename(toc) if toc
79
+
80
+ toc_path_info = output[:exported_file_checksum].find { |item| item.first.end_with?("toc.json") }
81
+ export_metadata[:toc] = File.basename(toc_path_info.first)
82
+
81
83
  history = ::Katello::ContentViewVersionExportHistory.create!(
82
84
  content_view_version_id: input[:content_view_version_id],
83
85
  destination_server: input[:destination_server],
@@ -36,10 +36,6 @@ module Actions
36
36
  def humanized_name
37
37
  _("Import")
38
38
  end
39
-
40
- def rescue_strategy
41
- Dynflow::Action::Rescue::Skip
42
- end
43
39
  end
44
40
  end
45
41
  end
@@ -8,7 +8,7 @@ module Katello
8
8
  def filter_package_groups_by_pulp_href(package_groups, package_pulp_hrefs)
9
9
  rpms = Katello::Rpm.where(:pulp_id => package_pulp_hrefs)
10
10
  package_groups.reject do |package_group|
11
- (package_group.package_names & rpms.pluck(:name)).empty?
11
+ (package_group.package_names - rpms.pluck(:name)).any?
12
12
  end
13
13
  end
14
14
 
@@ -126,7 +126,7 @@ module Katello
126
126
  facet_model = Facets.registered_facets[facet].hostgroup_configuration.model
127
127
  value = facet_model.where.not(attribute => nil).joins(:hostgroup).merge(
128
128
  ::Hostgroup.where(id: self.ancestor_ids).reorder(ancestry: :desc)
129
- ).limit(1).pluck(attribute)
129
+ ).limit(1).pluck(attribute).first
130
130
  end
131
131
  value
132
132
  end
@@ -91,6 +91,13 @@ module Katello
91
91
  service_class.pulp_units_batch_all(pulp_ids).each do |units|
92
92
  units.each do |unit|
93
93
  unit = unit.with_indifferent_access
94
+ if content_type == 'rpm' && repository
95
+ rpms_to_disassociate = ::Katello::Rpm.where(name: unit[:name], version: unit[:version], release: unit[:release],
96
+ epoch: unit[:epoch], arch: unit[:arch]).select(:id)
97
+ if rpms_to_disassociate.any?
98
+ ::Katello::RepositoryRpm.where(rpm_id: rpms_to_disassociate, repository_id: repository.id).destroy_all
99
+ end
100
+ end
94
101
  model = Katello::Util::Support.active_record_retry do
95
102
  self.where(:pulp_id => unit[service_class.unit_identifier]).first_or_create
96
103
  end
@@ -211,6 +218,18 @@ module Katello
211
218
  def db_values(new_ids, pulp_id_href_map, repository)
212
219
  new_ids.map { |unit_id| [unit_id.to_i, pulp_id_href_map.dig(unit_id), repository.id.to_i, Time.now.utc.to_s(:db), Time.now.utc.to_s(:db)].compact }
213
220
  end
221
+
222
+ def unmigrated_content
223
+ self.where(migrated_pulp3_href: nil, ignore_missing_from_migration: false)
224
+ end
225
+
226
+ def missing_migrated_content #missing or corrupted content that could not be migrated
227
+ self.where(migrated_pulp3_href: nil, missing_from_migration: true, ignore_missing_from_migration: false)
228
+ end
229
+
230
+ def ignored_missing_migrated_content
231
+ self.where(migrated_pulp3_href: nil, missing_from_migration: true, ignore_missing_from_migration: true)
232
+ end
214
233
  end
215
234
  end
216
235
  end
@@ -44,8 +44,8 @@ module Katello
44
44
 
45
45
  def kickstart_repos(host)
46
46
  distros = distribution_repositories(host).where(distribution_bootable: true)
47
- if distros && host.content_source
48
- distros.map { |distro| distro.to_hash(host.content_source) }
47
+ if distros && host&.content_facet&.content_source
48
+ distros.map { |distro| distro.to_hash(host.content_facet.content_source) }
49
49
  else
50
50
  []
51
51
  end
@@ -179,7 +179,9 @@ module Katello
179
179
  end
180
180
 
181
181
  def fix_pulp3_capabilities(type)
182
- if missing_pulp3_capabilities? && !pulp2_preferred_for_type?(type)
182
+ repository_type_obj = type.is_a?(String) || type.is_a?(Symbol) ? Katello::RepositoryTypeManager.repository_types[type] : type
183
+
184
+ if missing_pulp3_capabilities? && repository_type_obj.pulp3_plugin && !pulp2_preferred_for_type?(repository_type_obj.id)
183
185
  self.refresh
184
186
  if self.capabilities(::SmartProxy::PULP3_FEATURE).empty?
185
187
  fail Katello::Errors::PulpcoreMissingCapabilities
@@ -13,6 +13,10 @@ module Katello
13
13
  order(:name)
14
14
  end
15
15
 
16
+ def filename
17
+ path
18
+ end
19
+
16
20
  def self.total_for_repositories(repos)
17
21
  self.in_repositories(repos).count
18
22
  end
@@ -31,43 +31,21 @@ module Katello
31
31
  validates :host, :presence => true, :allow_blank => false
32
32
  validates_with Validators::ContentViewEnvironmentValidator
33
33
 
34
- def bindable_types
35
- [
36
- {
37
- type: Repository::DEB_TYPE,
38
- matcher: '/pulp/deb/',
39
- paths: []
40
- },
41
- {
42
- type: Repository::YUM_TYPE,
43
- matcher: '/pulp/repos/',
44
- paths: []
45
- }
46
- ]
47
- end
48
-
49
34
  def update_repositories_by_paths(paths)
50
- bindable_paths = bindable_types
35
+ prefixes = %w(/pulp/deb/ /pulp/repos/ /pulp/content/)
51
36
  relative_paths = []
52
37
 
53
- # paths == ["/pulp/repos/Default_Organization/Library/custom/Test_product/test2",
54
- # "/pulp/repos/Default_Organization/Library/custom/Test_product/My_repo"]
55
- paths.each do |absolute_path|
56
- bindable_paths.each do |supported|
57
- relative_path = absolute_path.gsub(supported[:matcher], '') # remove e.g. '/pulp/repos/' from beginning of string
58
- relative_paths << relative_path unless relative_path == absolute_path
59
- if absolute_path.starts_with?(supported[:matcher])
60
- supported[:paths] << relative_path
61
- break
62
- end
38
+ # paths == ["/pulp/repos/Default_Organization/Library/custom/Test_product/test2"]
39
+ paths.each do |path|
40
+ if (prefix = prefixes.find { |pre| path.start_with?(pre) })
41
+ relative_paths << path.gsub(prefix, '')
42
+ else
43
+ Rails.logger.warn("System #{self.host.name} (#{self.host.id}) requested binding to repo with unknown prefix. #{path}")
63
44
  end
64
45
  end
65
46
 
66
- repos = bindable_paths.flat_map do |supported|
67
- repos = Repository.joins(:root).where(RootRepository.table_name => {content_type: supported[:type]}, relative_path: supported[:paths])
68
- relative_paths -= repos.pluck(:relative_path) # remove relative paths that match our repos
69
- repos
70
- end
47
+ repos = Repository.where(relative_path: relative_paths)
48
+ relative_paths -= repos.pluck(:relative_path) # remove relative paths that match our repos
71
49
 
72
50
  # Any leftover relative paths do not match the repos we've just retrieved from the db,
73
51
  # so we should log warnings about them.