katello 3.18.0.rc2.1 → 3.18.2.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.

Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/katello/katello.scss +0 -72
  3. data/app/controllers/katello/api/v2/api_controller.rb +1 -2
  4. data/app/controllers/katello/api/v2/capsule_content_controller.rb +2 -2
  5. data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +98 -0
  6. data/app/controllers/katello/api/v2/content_exports_controller.rb +84 -0
  7. data/app/controllers/katello/api/v2/content_imports_controller.rb +59 -0
  8. data/app/controllers/katello/api/v2/content_view_filters_controller.rb +1 -1
  9. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +56 -94
  10. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +2 -1
  11. data/app/controllers/katello/api/v2/repositories_controller.rb +2 -0
  12. data/app/controllers/katello/concerns/api/v2/authorization.rb +14 -1
  13. data/app/lib/actions/katello/applicability/hosts/bulk_generate.rb +6 -2
  14. data/app/lib/actions/katello/capsule_content/sync.rb +1 -1
  15. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +7 -2
  16. data/app/lib/actions/katello/content_view/promote_to_environment.rb +1 -1
  17. data/app/lib/actions/katello/content_view/publish.rb +1 -1
  18. data/app/lib/actions/katello/content_view_version/import.rb +2 -1
  19. data/app/lib/actions/katello/content_view_version/import_library.rb +17 -0
  20. data/app/lib/actions/katello/content_view_version/incremental_update.rb +19 -3
  21. data/app/lib/actions/katello/host/update_system_purpose.rb +1 -1
  22. data/app/lib/actions/katello/repository/sync.rb +5 -1
  23. data/app/lib/actions/middleware/record_smart_proxy_sync_history.rb +24 -4
  24. data/app/lib/actions/pulp3/content_migration.rb +10 -0
  25. data/app/lib/actions/pulp3/content_migration_presenter.rb +59 -0
  26. data/app/lib/actions/pulp3/content_migration_reset.rb +22 -0
  27. data/app/lib/actions/pulp3/content_view/delete_repository_references.rb +1 -1
  28. data/app/lib/actions/pulp3/content_view_version/export.rb +3 -2
  29. data/app/lib/actions/pulp3/import_migration.rb +6 -1
  30. data/app/lib/actions/pulp3/orchestration/content_view_version/copy_version_units_to_library.rb +2 -1
  31. data/app/lib/actions/pulp3/orchestration/content_view_version/export.rb +17 -13
  32. data/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb +60 -0
  33. data/app/lib/actions/pulp3/orchestration/content_view_version/import.rb +0 -4
  34. data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +16 -3
  35. data/app/lib/actions/pulp3/repository/copy_content.rb +1 -1
  36. data/app/lib/actions/pulp3/repository/delete.rb +1 -1
  37. data/app/lib/actions/pulp3/repository/save_version.rb +1 -1
  38. data/app/lib/actions/pulp3/repository/upload_tag.rb +18 -0
  39. data/app/lib/katello/util/pulpcore_content_filters.rb +1 -1
  40. data/app/models/katello/authorization/content_view_version.rb +25 -2
  41. data/app/models/katello/authorization/content_view_version_export_history.rb +1 -1
  42. data/app/models/katello/authorization/organization.rb +8 -0
  43. data/app/models/katello/concerns/operatingsystem_extensions.rb +2 -0
  44. data/app/models/katello/concerns/pulp_database_unit.rb +19 -0
  45. data/app/models/katello/concerns/redhat_extensions.rb +2 -2
  46. data/app/models/katello/concerns/smart_proxy_extensions.rb +7 -5
  47. data/app/models/katello/content_migration_progress.rb +4 -0
  48. data/app/models/katello/content_view.rb +5 -0
  49. data/app/models/katello/content_view_history.rb +2 -1
  50. data/app/models/katello/content_view_package_filter.rb +1 -1
  51. data/app/models/katello/content_view_version_export_history.rb +6 -1
  52. data/app/models/katello/file_unit.rb +4 -0
  53. data/app/models/katello/host/content_facet.rb +9 -31
  54. data/app/models/katello/host/subscription_facet.rb +4 -0
  55. data/app/models/katello/ping.rb +35 -15
  56. data/app/models/katello/repository.rb +7 -0
  57. data/app/models/katello/subscription_status.rb +3 -2
  58. data/app/services/katello/applicability/applicable_content_helper.rb +44 -15
  59. data/app/services/katello/pulp3/api/docker.rb +4 -0
  60. data/app/services/katello/pulp3/content_view_version/export.rb +63 -5
  61. data/app/services/katello/pulp3/content_view_version/import.rb +40 -0
  62. data/app/services/katello/pulp3/content_view_version/import_export_common.rb +0 -16
  63. data/app/services/katello/pulp3/content_view_version/import_validator.rb +26 -49
  64. data/app/services/katello/pulp3/docker_manifest.rb +1 -0
  65. data/app/services/katello/pulp3/docker_tag.rb +1 -0
  66. data/app/services/katello/pulp3/erratum.rb +2 -1
  67. data/app/services/katello/pulp3/migration.rb +95 -12
  68. data/app/services/katello/pulp3/migration_plan.rb +2 -2
  69. data/app/services/katello/pulp3/migration_switchover.rb +23 -5
  70. data/app/services/katello/pulp3/repository.rb +10 -5
  71. data/app/services/katello/pulp3/repository/docker.rb +5 -0
  72. data/app/services/katello/pulp3/repository/yum.rb +23 -8
  73. data/app/services/katello/pulp3/rpm.rb +5 -1
  74. data/app/services/katello/pulp3/task.rb +4 -0
  75. data/app/services/katello/pulp3/task_group.rb +4 -0
  76. data/app/views/katello/api/v2/content_views/show.json.rabl +6 -0
  77. data/app/views/katello/layouts/react.html.erb +3 -2
  78. data/app/views/katello/sync_management/_products.html.erb +1 -1
  79. data/app/views/overrides/activation_keys/_host_tab_pane.html.erb +1 -5
  80. data/config/routes/api/v2.rb +23 -3
  81. data/db/migrate/20150930183738_migrate_content_hosts.rb +1 -1
  82. data/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb +5 -2
  83. data/db/migrate/20201119211133_pulp3_migration_progress.rb +9 -0
  84. data/db/migrate/20210201165835_add_migration_missing_content.rb +12 -0
  85. data/engines/bastion/app/assets/javascripts/bastion/auth/authorization.service.js +1 -1
  86. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/common/views/katello-agent-notice.html +1 -1
  87. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-system-purpose-modal.html +35 -40
  88. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/register-client.html +1 -1
  89. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/content-view-version-deletion-activation-keys.controller.js +8 -3
  90. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/content-view-version-deletion-content-hosts.controller.js +9 -3
  91. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details.html +1 -1
  92. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-publish.html +4 -0
  93. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +78 -7
  94. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/de.po +17 -20
  95. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/es.po +17 -24
  96. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/fr.po +1292 -1170
  97. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/it.po +17 -20
  98. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ja.po +858 -807
  99. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ko.po +18 -19
  100. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/pt_BR.po +17 -24
  101. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ru.po +17 -18
  102. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_CN.po +986 -971
  103. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_TW.po +19 -20
  104. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/translations.js +9 -9
  105. data/lib/katello/permission_creator.rb +23 -3
  106. data/lib/katello/tasks/delete_orphaned_content.rake +1 -3
  107. data/lib/katello/tasks/pulp3_content_switchover.rake +3 -1
  108. data/lib/katello/tasks/pulp3_migration.rake +29 -6
  109. data/lib/katello/tasks/pulp3_migration_abort.rake +7 -2
  110. data/lib/katello/tasks/pulp3_migration_approve_corrupted.rake +16 -0
  111. data/lib/katello/tasks/pulp3_migration_reset.rake +26 -0
  112. data/lib/katello/tasks/pulp3_migration_stats.rake +61 -8
  113. data/lib/katello/tasks/pulp3_post_migration_check.rake +1 -3
  114. data/lib/katello/tasks/receptor/extract_orgs.rake +1 -1
  115. data/lib/katello/tasks/reports.rake +4 -1
  116. data/lib/katello/tasks/repository.rake +3 -5
  117. data/lib/katello/version.rb +1 -1
  118. data/locale/action_names.rb +51 -51
  119. data/locale/bn/katello.po +136 -51
  120. data/locale/cs/katello.po +136 -49
  121. data/locale/de/katello.po +136 -48
  122. data/locale/en/katello.po +136 -48
  123. data/locale/es/katello.po +136 -48
  124. data/locale/fr/katello.po +136 -48
  125. data/locale/gu/katello.po +136 -51
  126. data/locale/hi/katello.po +136 -51
  127. data/locale/it/katello.po +136 -48
  128. data/locale/ja/katello.po +136 -48
  129. data/locale/katello.pot +941 -767
  130. data/locale/kn/katello.po +136 -51
  131. data/locale/ko/katello.po +136 -48
  132. data/locale/mr/katello.po +136 -51
  133. data/locale/or/katello.po +136 -51
  134. data/locale/pa/katello.po +136 -51
  135. data/locale/pt/katello.po +136 -51
  136. data/locale/pt_BR/katello.po +136 -48
  137. data/locale/ru/katello.po +136 -48
  138. data/locale/ta/katello.po +136 -51
  139. data/locale/te/katello.po +136 -51
  140. data/locale/zh_CN/katello.po +136 -48
  141. data/locale/zh_TW/katello.po +136 -48
  142. data/webpack/components/TypeAhead/TypeAhead.js +2 -1
  143. data/webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js +2 -1
  144. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +7 -2
  145. data/webpack/scenes/Subscriptions/Manifest/index.js +1 -0
  146. metadata +31 -19
  147. data/lib/katello/tasks/common.rake +0 -7
@@ -2,6 +2,7 @@ module Katello
2
2
  module Pulp3
3
3
  class DockerManifest < PulpContentUnit
4
4
  include LazyAccessor
5
+ CONTENT_TYPE = "docker_manifest".freeze
5
6
 
6
7
  def self.content_api
7
8
  PulpContainerClient::ContentManifestsApi.new(Katello::Pulp3::Api::Docker.new(SmartProxy.pulp_primary!).api_client)
@@ -2,6 +2,7 @@ module Katello
2
2
  module Pulp3
3
3
  class DockerTag < PulpContentUnit
4
4
  include LazyAccessor
5
+ CONTENT_TYPE = "docker_tag".freeze
5
6
 
6
7
  def self.content_api
7
8
  PulpContainerClient::ContentTagsApi.new(Katello::Pulp3::Api::Docker.new(SmartProxy.pulp_primary!).api_client)
@@ -35,7 +35,8 @@ module Katello
35
35
  custom_json["issued"] = convert_date_if_epoch(custom_json["issued"])
36
36
  custom_json["updated"] = convert_date_if_epoch(custom_json["updated"]) unless custom_json["updated"].blank?
37
37
 
38
- if model.updated.blank? || (custom_json['updated'].to_datetime != model.updated.to_datetime)
38
+ if model.updated.blank? ||
39
+ (custom_json['updated'] && (custom_json['updated'].to_datetime != model.updated.to_datetime))
39
40
  custom_json['errata_id'] = custom_json.delete('id')
40
41
  custom_json['errata_type'] = custom_json.delete('type')
41
42
  custom_json['updated'] = custom_json['updated'].blank? ? custom_json['issued'] : custom_json['updated']
@@ -3,7 +3,7 @@ require 'pulp_2to3_migration_client'
3
3
  module Katello
4
4
  module Pulp3
5
5
  class Migration
6
- attr_accessor :smart_proxy, :reimport_all
6
+ attr_accessor :smart_proxy, :reimport_all, :task_id
7
7
  GET_QUERY_ID_LENGTH = 90
8
8
 
9
9
  MUTABLE_CONTENT_TYPES = [
@@ -15,14 +15,20 @@ module Katello
15
15
  Katello::Erratum
16
16
  ].freeze
17
17
 
18
+ CORRUPTABLE_CONTENT_TYPES = [
19
+ Katello::Rpm, Katello::FileUnit
20
+ ].freeze
21
+
18
22
  def self.repository_types_for_migration
19
23
  #we can migrate types that pulp3 supports, but are overridden to pulp2. These are in 'migration mode'
20
24
  overridden = (SETTINGS[:katello][:use_pulp_2_for_content_type] || {}).keys.select { |key| SETTINGS[:katello][:use_pulp_2_for_content_type][key] }
21
25
  overridden.select { |type| SmartProxy.pulp_primary.pulp3_repository_type_support?(type.to_s, false) }.map { |t| t.to_s }
22
26
  end
23
27
 
24
- def initialize(smart_proxy, repository_types = Migration.repository_types_for_migration, options = {})
25
- self.reimport_all = options.fetch(:reimport, false)
28
+ def initialize(smart_proxy, options = {})
29
+ self.task_id = options.fetch(:task_id, nil)
30
+ self.reimport_all = options.fetch(:reimport_all, false)
31
+ repository_types = options.fetch(:repository_types, Migration.repository_types_for_migration)
26
32
 
27
33
  if (repository_types - smart_proxy.supported_pulp_types[:pulp3][:overriden_to_pulp2]).any?
28
34
  fail ::Katello::Errors::Pulp3MigrationError, _("Pulp 3 migration cannot run. Types %s have already been migrated.") %
@@ -62,6 +68,15 @@ module Katello
62
68
  [YumMetadataFile]
63
69
  end
64
70
 
71
+ def last_successful_migration_time
72
+ task = ForemanTasks::Task.where(:label => Actions::Pulp3::ContentMigration.to_s, :result => 'success').order("started_at desc").first
73
+ if reimport_all || task.nil?
74
+ 0
75
+ else
76
+ task.started_at.to_i
77
+ end
78
+ end
79
+
65
80
  def content_types_for_migration
66
81
  content_types = @repository_types.collect do |repository_type_label|
67
82
  Katello::RepositoryTypeManager.repository_types[repository_type_label].content_types_to_index
@@ -70,7 +85,20 @@ module Katello
70
85
  content_types.flatten - Migration.ignorable_content_types
71
86
  end
72
87
 
88
+ def update_import_status(message, index = nil)
89
+ #reduce output updating, only update every 20 items
90
+ if (index.nil? || index % 20 == 0) && self.task_id
91
+ progress = Katello::ContentMigrationProgress.find_or_create_by(:task_id => self.task_id)
92
+ progress.update(:progress_message => message)
93
+ progress.save!
94
+
95
+ fail Katello::Errors::Pulp3MigrationError, "Cancelled by user." if progress.canceled?
96
+ end
97
+ end
98
+
73
99
  def import_pulp3_content
100
+ update_import_status("Starting katello import phase.")
101
+
74
102
  Katello::Logging.time("CONTENT_MIGRATION - Total Import Process") do
75
103
  @repository_types.each do |repository_type_label|
76
104
  Katello::Logging.time("CONTENT_MIGRATION - Importing Repository", data: {type: repository_type_label}) do
@@ -78,8 +106,9 @@ module Katello
78
106
  end
79
107
 
80
108
  Katello::RepositoryTypeManager.repository_types[repository_type_label].content_types_to_index.each do |content_type|
81
- Katello::Logging.time("CONTENT_MIGRATION - Importing Content", data: {type: content_type}) do
109
+ Katello::Logging.time("CONTENT_MIGRATION - Importing Content", data: {type: content_type.label}) do
82
110
  import_content_type(content_type)
111
+ mark_missing_content(content_type)
83
112
  end
84
113
  end
85
114
  end
@@ -90,6 +119,44 @@ module Katello
90
119
  Katello::Pulp3::MigrationPlan.new(@repository_types).generate.as_json
91
120
  end
92
121
 
122
+ def reset
123
+ if @repository_types.empty?
124
+ fail ::Katello::Errors::Pulp3MigrationError, 'There are no Pulp 3 content types to reset'
125
+ end
126
+
127
+ plugins = @repository_types.sort.map do |repository_type|
128
+ {
129
+ type: ::Katello::Pulp3::MigrationPlan.pulp2_repository_type(repository_type)
130
+ }
131
+ end
132
+ plan = { plugins: plugins }
133
+
134
+ # TODO: Don't provide the plan as a string once this is resolved: https://pulp.plan.io/issues/8211
135
+ migration_plan_api.reset(migration_plan_api.create(plan: plan).pulp_href, plan.to_json)
136
+
137
+ content_types_for_migration.each do |content_type|
138
+ if content_type.model_class == ::Katello::Erratum
139
+ ::Katello::RepositoryErratum.update_all(erratum_pulp3_href: nil)
140
+ else
141
+ content_type.model_class.update_all(migrated_pulp3_href: nil)
142
+ end
143
+ end
144
+
145
+ @repository_types.each do |repo_type|
146
+ if repo_type == "file"
147
+ ::Katello::Repository.file_type.update(remote_href: nil, publication_href: nil, version_href: nil)
148
+ elsif repo_type == "docker"
149
+ ::Katello::Repository.docker_type.update(remote_href: nil, publication_href: nil, version_href: nil)
150
+ elsif repo_type == "yum"
151
+ ::Katello::Repository.yum_type.update(remote_href: nil, publication_href: nil, version_href: nil)
152
+ end
153
+ end
154
+
155
+ ::Katello::Pulp3::RepositoryReference.destroy_all
156
+ ::Katello::Pulp3::DistributionReference.destroy_all
157
+ ::Katello::Pulp3::ContentGuard.destroy_all
158
+ end
159
+
93
160
  def create_migrations
94
161
  plan = migration_plan
95
162
  Rails.logger.info("Migration Plan: #{plan}")
@@ -103,7 +170,7 @@ module Katello
103
170
  end
104
171
 
105
172
  def start_migration(plan_href)
106
- migration_plan_api.run(plan_href, dry_run: false, validate: true)
173
+ migration_plan_api.run(plan_href, dry_run: false, validate: true, skip_corrupted: true)
107
174
  end
108
175
 
109
176
  def import_repositories(repository_type_label)
@@ -114,7 +181,9 @@ module Katello
114
181
  if repository_type_label == 'yum'
115
182
  import_yum_repos(imported, katello_repos)
116
183
  else
117
- katello_repos.each do |repo|
184
+ repo_count = katello_repos.count
185
+ katello_repos.each_with_index do |repo, index|
186
+ update_import_status("Importing migrated content units #{repository_type_label}: #{index + 1}/#{repo_count}", index)
118
187
  found = imported.find { |migrated_repo| migrated_repo.pulp2_repo_id == repo.pulp_id }
119
188
  import_repo(repo, found) if found
120
189
  end
@@ -122,7 +191,9 @@ module Katello
122
191
  end
123
192
 
124
193
  def import_yum_repos(migrated_repo_items, repos)
125
- repos.each do |yum_repo|
194
+ repo_count = repos.count
195
+ repos.each_with_index do |yum_repo, index|
196
+ update_import_status("Importing migrated yum repositories: #{index + 1}/#{repo_count}", index)
126
197
  to_find = nil
127
198
  if yum_repo.content_view.composite?
128
199
  if yum_repo.link?
@@ -195,14 +266,16 @@ module Katello
195
266
  end
196
267
 
197
268
  def operate_on_errata
269
+ last_migration_time = last_successful_migration_time
198
270
  offset = 0
199
- limit = 300
200
- response = pulp2_content_api.list(pulp2_content_type_id: 'erratum', offset: offset, limit: limit)
271
+ limit = SETTINGS[:katello][:pulp][:bulk_load_size]
272
+ response = pulp2_content_api.list(pulp2_content_type_id: 'erratum', offset: offset, limit: limit, pulp2_last_updated__gt: last_migration_time)
201
273
  total_count = response.count
202
274
  yield(response.results)
203
275
  until (offset + limit > total_count)
204
276
  offset += limit
205
- response = pulp2_content_api.list(pulp2_content_type_id: 'erratum', offset: offset, limit: limit)
277
+ response = pulp2_content_api.list(pulp2_content_type_id: 'erratum', offset: offset, limit: limit, pulp2_last_updated__gt: last_migration_time)
278
+ update_import_status("Importing migrated content type erratum: #{offset + limit}/#{total_count}")
206
279
  yield(response.results)
207
280
  end
208
281
  end
@@ -231,6 +304,12 @@ module Katello
231
304
  on_duplicate_key_update: {conflict_target: [:erratum_id, :repository_id], columns: [:erratum_pulp3_href]})
232
305
  end
233
306
 
307
+ def mark_missing_content(content_type)
308
+ unless [Katello::DockerTag, Katello::DockerManifest, Katello::Erratum].include?(content_type.model_class)
309
+ content_type.model_class.where(:migrated_pulp3_href => nil).update_all(:missing_from_migration => true)
310
+ end
311
+ end
312
+
234
313
  def import_content_type(content_type)
235
314
  if content_type.model_class == Katello::Erratum
236
315
  import_errata
@@ -242,11 +321,15 @@ module Katello
242
321
  unmigrated_units = unmigrated_units.where(:migrated_pulp3_href => nil)
243
322
  end
244
323
 
324
+ total_count = unmigrated_units.count
325
+ current_count = 0
326
+
245
327
  unmigrated_units.select(:id, :pulp_id).find_in_batches(batch_size: GET_QUERY_ID_LENGTH) do |needing_hrefs|
328
+ current_count += needing_hrefs.count
329
+ update_import_status("Importing migrated content type #{content_type.label}: #{current_count}/#{total_count}")
246
330
  migrated_units = pulp2_content_api.list(pulp2_id__in: needing_hrefs.map { |unit| unit.pulp_id }.join(','))
247
331
  migrated_units.results.each do |migrated_unit|
248
- matching_record = needing_hrefs.find { |db_unit| db_unit.pulp_id == migrated_unit.pulp2_id }
249
- matching_record&.update_column(:migrated_pulp3_href, migrated_unit.pulp3_content)
332
+ content_type.model_class.where(pulp_id: migrated_unit.pulp2_id).update_all(migrated_pulp3_href: migrated_unit.pulp3_content)
250
333
  end
251
334
  end
252
335
  end
@@ -21,13 +21,13 @@ module Katello
21
21
  def generate_plugins
22
22
  @repository_types.sort.map do |repository_type|
23
23
  {
24
- type: pulp2_repository_type(repository_type),
24
+ type: self.class.pulp2_repository_type(repository_type),
25
25
  repositories: repository_migrations(repository_type)
26
26
  }
27
27
  end
28
28
  end
29
29
 
30
- def pulp2_repository_type(repository_type)
30
+ def self.pulp2_repository_type(repository_type)
31
31
  if repository_type == 'yum'
32
32
  return 'rpm' #migration plugin uses rpm
33
33
  else
@@ -21,6 +21,7 @@ module Katello
21
21
  Katello::Logging.time("CONTENT_SWITCHOVER - combine_duplicate_content_types") { combine_duplicate_content_types }
22
22
  Katello::Logging.time("CONTENT_SWITCHOVER - combine_duplicate_docker_tags") { combine_duplicate_docker_tags } if docker_migration?
23
23
  Katello::Logging.time("CONTENT_SWITCHOVER - migrate_pulp3_hrefs") { migrate_pulp3_hrefs }
24
+ Katello::Logging.time("CONTENT_SWITCHOVER - remove_missing_content") { remove_missing_content }
24
25
  end
25
26
  end
26
27
 
@@ -106,12 +107,29 @@ module Katello
106
107
  end
107
108
  end
108
109
 
109
- def migrated_content_type_check
110
+ def remove_missing_content
110
111
  content_types.each do |content_type|
111
- if content_type.model_class == Katello::Erratum
112
- migrated_errata_check
113
- elsif content_type.model_class.where(migrated_pulp3_href: nil).any?
114
- fail SwitchOverError, "ERROR: at least one #{content_type.model_class.table_name} record has migrated_pulp3_href NULL value\n"
112
+ if Migration::CORRUPTABLE_CONTENT_TYPES.include?(content_type.model_class)
113
+ content_type.model_class.ignored_missing_migrated_content.destroy_all
114
+ elsif content_type.model_class == Katello::Erratum
115
+ Katello::RepositoryErratum.where(:erratum_pulp3_href => nil).delete_all
116
+ else
117
+ content_type.model_class.unmigrated_content.destroy_all
118
+ end
119
+ end
120
+ end
121
+
122
+ def migrated_content_type_check
123
+ content_classes = content_types.map(&:model_class)
124
+ migrated_errata_check if content_classes.include?(Katello::Erratum)
125
+
126
+ (content_classes & Migration::CORRUPTABLE_CONTENT_TYPES).each do |content_type|
127
+ if content_type.missing_migrated_content.any?
128
+ fail SwitchOverError, "ERROR: at least one #{content_type.table_name} record has been detected as corrupt or missing. Run 'foreman-rake katello:pulp3_migration_stats' for more information.\n"
129
+ end
130
+
131
+ if content_type.unmigrated_content.any?
132
+ fail SwitchOverError, "ERROR: at least one #{content_type.table_name} record was not able to be migrated\n"
115
133
  end
116
134
  end
117
135
  end
@@ -1,7 +1,7 @@
1
1
  require "pulpcore_client"
2
-
3
2
  module Katello
4
3
  module Pulp3
4
+ # rubocop:disable Metrics/ClassLength
5
5
  class Repository
6
6
  include Katello::Util::HttpProxy
7
7
  attr_accessor :repo
@@ -188,8 +188,9 @@ module Katello
188
188
  api.repositories_api.read(repository_reference.try(:repository_href))
189
189
  end
190
190
 
191
- def delete(href = repository_reference.try(:repository_href))
192
- repository_reference.try(:destroy)
191
+ def delete_repository(repo_reference = repository_reference)
192
+ href = repo_reference.try(:repository_href)
193
+ repo_reference.try(:destroy)
193
194
  ignore_404_exception { api.repositories_api.delete(href) } if href
194
195
  end
195
196
 
@@ -257,8 +258,12 @@ module Katello
257
258
  create_version(:base_version => from_repository.version_href)
258
259
  end
259
260
 
261
+ def version_zero?
262
+ repo.version_href.ends_with?('/versions/0/')
263
+ end
264
+
260
265
  def delete_version
261
- ignore_404_exception { api.repository_versions_api.delete(repo.version_href) }
266
+ ignore_404_exception { api.repository_versions_api.delete(repo.version_href) } unless version_zero?
262
267
  end
263
268
 
264
269
  def create_version(options = {})
@@ -300,7 +305,7 @@ module Katello
300
305
  }
301
306
  remote_options[:url] = root.url unless root.url.blank?
302
307
  remote_options[:download_concurrency] = root.download_concurrency unless root.download_concurrency.blank?
303
- if root.upstream_username && root.upstream_password
308
+ if !root.upstream_username.blank? && !root.upstream_password.blank?
304
309
  remote_options.merge!(username: root.upstream_username,
305
310
  password: root.upstream_password)
306
311
  end
@@ -52,6 +52,11 @@ module Katello
52
52
  api.class.recursive_manage_class.new(content_units: options[:remove_content_units]))
53
53
  end
54
54
 
55
+ def tag_manifest(name, digest)
56
+ api.repositories_api.tag(repository_reference.repository_href,
57
+ api.class.tag_image_class.new(tag: name, digest: digest))
58
+ end
59
+
55
60
  def add_content(content_unit_href)
56
61
  content_unit_href = [content_unit_href] unless content_unit_href.is_a?(Array)
57
62
  api.repositories_api.add(repository_reference.repository_href, content_units: content_unit_href)
@@ -14,7 +14,16 @@ module Katello
14
14
  url, sles_token = extract_sles_token
15
15
  options = common_remote_options
16
16
  options.merge!(sles_auth_token: sles_token) if sles_token
17
- options.merge!(url: url, policy: root.download_policy)
17
+
18
+ options.merge!(url: url, policy: translated_download_policy)
19
+ end
20
+
21
+ def translated_download_policy
22
+ if root.download_policy == ::Runcible::Models::YumImporter::DOWNLOAD_BACKGROUND
23
+ ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE
24
+ else
25
+ root.download_policy
26
+ end
18
27
  end
19
28
 
20
29
  def extract_sles_token
@@ -207,14 +216,20 @@ module Katello
207
216
  tasks
208
217
  end
209
218
 
210
- def copy_all(source_repository)
211
- data = PulpRpmClient::Copy.new
212
- data.config = [{
213
- source_repo_version: source_repository.version_href,
214
- dest_repo: repository_reference.repository_href
215
- }]
219
+ def copy_all(source_repository, mirror: false)
220
+ if mirror
221
+ data = PulpRpmClient::RepositoryAddRemoveContent.new(
222
+ base_version: source_repository.version_href)
216
223
 
217
- [api.copy_api.copy_content(data)]
224
+ [api.repositories_api.modify(repository_reference.repository_href, data)]
225
+ else
226
+ data = PulpRpmClient::Copy.new
227
+ data.config = [{
228
+ source_repo_version: source_repository.version_href,
229
+ dest_repo: repository_reference.repository_href
230
+ }]
231
+ [api.copy_api.copy_content(data)]
232
+ end
218
233
  end
219
234
 
220
235
  def remove_all_content_from_repo(repo_href)
@@ -111,6 +111,10 @@ module Katello
111
111
  backend_data['rpm_license']
112
112
  end
113
113
 
114
+ def parse_filename(path)
115
+ File.split(path).last unless path.blank?
116
+ end
117
+
114
118
  def update_model(model)
115
119
  custom_json = {}
116
120
  custom_json['modular'] = backend_data['is_modular']
@@ -119,7 +123,7 @@ module Katello
119
123
  each { |field| custom_json[field] = backend_data[field] }
120
124
  custom_json['release_sortable'] = Util::Package.sortable_version(backend_data['release'])
121
125
  custom_json['version_sortable'] = Util::Package.sortable_version(backend_data['version'])
122
- custom_json['filename'] = backend_data['location_href']
126
+ custom_json['filename'] = parse_filename(backend_data['location_href']) #location_href is the relative path of the rpm in the upstream repo
123
127
  custom_json['checksum'] = backend_data['pkgId']
124
128
  custom_json['sourcerpm'] = backend_data['rpm_sourcerpm']
125
129
  model.assign_attributes(custom_json)
@@ -68,6 +68,10 @@ module Katello
68
68
  task_data[:finish_time] || FINISHED_STATES.include?(task_data[:state])
69
69
  end
70
70
 
71
+ def progress_reports
72
+ task_data['progress_reports']
73
+ end
74
+
71
75
  def poll
72
76
  task_data(true)
73
77
  self
@@ -53,6 +53,10 @@ module Katello
53
53
  task_group_data['all_tasks_dispatched'] == true && IN_PROGRESS_STATES.all? { |state| task_group_data[state] == 0 }
54
54
  end
55
55
 
56
+ def group_progress_reports
57
+ task_group_data['group_progress_reports']
58
+ end
59
+
56
60
  def poll
57
61
  clear_task_group_data
58
62
  task_group_data
@@ -4,6 +4,12 @@ extends "katello/api/v2/content_views/base"
4
4
 
5
5
  attributes :content_host_count
6
6
 
7
+ node :errors do
8
+ unless @resource.valid?
9
+ attribute :messages => @resource.errors.full_messages
10
+ end
11
+ end
12
+
7
13
  child :duplicate_repositories_to_publish => :duplicate_repositories_to_publish do
8
14
  attributes :id, :name
9
15
  node :components do |repo|