katello 3.16.0.rc5.1 → 3.16.2

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 (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +39 -23
  3. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +1 -1
  4. data/app/controllers/katello/api/v2/host_tracer_controller.rb +8 -33
  5. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +11 -1
  6. data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +15 -0
  7. data/app/controllers/katello/api/v2/repositories_controller.rb +10 -1
  8. data/app/controllers/katello/concerns/hosts_controller_extensions.rb +11 -5
  9. data/app/helpers/katello/content_view_helper.rb +15 -0
  10. data/app/lib/actions/katello/applicability/hosts/bulk_generate.rb +6 -2
  11. data/app/lib/actions/katello/capsule_content/refresh_repos.rb +1 -1
  12. data/app/lib/actions/katello/capsule_content/sync.rb +3 -2
  13. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +17 -3
  14. data/app/lib/actions/katello/content_view/incremental_updates.rb +3 -1
  15. data/app/lib/actions/katello/content_view/publish.rb +55 -16
  16. data/app/lib/actions/katello/content_view_version/incremental_update.rb +84 -53
  17. data/app/lib/actions/katello/product/destroy.rb +25 -4
  18. data/app/lib/actions/katello/repository/destroy.rb +5 -1
  19. data/app/lib/actions/katello/repository/multi_clone_contents.rb +64 -0
  20. data/app/lib/actions/katello/repository/multi_clone_to_version.rb +30 -0
  21. data/app/lib/actions/katello/repository/sync.rb +35 -25
  22. data/app/lib/actions/katello/repository/update.rb +11 -16
  23. data/app/lib/actions/katello/repository/verify_checksum.rb +28 -0
  24. data/app/lib/actions/pulp/orchestration/repository/sync.rb +2 -1
  25. data/app/lib/actions/pulp/repository/sync.rb +2 -1
  26. data/app/lib/actions/pulp3/abstract_async_task.rb +63 -58
  27. data/app/lib/actions/pulp3/capsule_content/refresh_content_guard.rb +17 -0
  28. data/app/lib/actions/pulp3/capsule_content/sync.rb +3 -1
  29. data/app/lib/actions/pulp3/{ContentGuard → content_guard}/refresh.rb +0 -0
  30. data/app/lib/actions/pulp3/content_migration.rb +4 -0
  31. data/app/lib/actions/pulp3/content_view/delete_repository_references.rb +1 -1
  32. data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +2 -4
  33. data/app/lib/actions/pulp3/orchestration/repository/multi_copy_all_units.rb +36 -0
  34. data/app/lib/actions/pulp3/orchestration/repository/sync.rb +3 -1
  35. data/app/lib/actions/pulp3/orchestration/repository/trigger_update_repo_cert_guard.rb +22 -0
  36. data/app/lib/actions/pulp3/repository/copy_content.rb +0 -1
  37. data/app/lib/actions/pulp3/repository/delete.rb +1 -1
  38. data/app/lib/actions/pulp3/repository/multi_copy_content.rb +28 -0
  39. data/app/lib/actions/pulp3/repository/multi_copy_units.rb +14 -7
  40. data/app/lib/actions/pulp3/repository/presenters/repair_presenter.rb +85 -0
  41. data/app/lib/actions/pulp3/repository/repair.rb +29 -0
  42. data/app/lib/actions/pulp3/repository/save_version.rb +20 -8
  43. data/app/lib/actions/pulp3/repository/save_versions.rb +47 -13
  44. data/app/lib/actions/pulp3/repository/sync.rb +1 -1
  45. data/app/lib/actions/pulp3/repository/update_cv_repository_cert_guard.rb +6 -2
  46. data/app/lib/actions/pulp3/repository/upload_file.rb +1 -1
  47. data/app/lib/katello/concerns/base_template_scope_extensions.rb +4 -0
  48. data/app/lib/katello/errors.rb +1 -15
  49. data/app/lib/katello/resources/cdn.rb +3 -2
  50. data/app/lib/katello/util/cdn_var_substitutor.rb +9 -6
  51. data/app/models/katello/concerns/smart_proxy_extensions.rb +14 -3
  52. data/app/models/katello/content_view.rb +18 -6
  53. data/app/models/katello/content_view_erratum_filter.rb +13 -0
  54. data/app/models/katello/content_view_module_stream_filter.rb +19 -0
  55. data/app/models/katello/content_view_package_filter.rb +1 -1
  56. data/app/models/katello/glue/pulp/repo.rb +1 -1
  57. data/app/models/katello/host/content_facet.rb +1 -0
  58. data/app/models/katello/module_stream.rb +1 -1
  59. data/app/models/katello/ping.rb +1 -3
  60. data/app/models/katello/repository.rb +5 -0
  61. data/app/models/katello/root_repository.rb +5 -1
  62. data/app/models/setting/content.rb +1 -1
  63. data/app/services/cert/certs.rb +10 -2
  64. data/app/services/katello/host_trace_manager.rb +38 -0
  65. data/app/services/katello/pulp3/api/core.rb +4 -0
  66. data/app/services/katello/pulp3/erratum.rb +3 -1
  67. data/app/services/katello/pulp3/migration.rb +4 -3
  68. data/app/services/katello/pulp3/migration_plan.rb +6 -6
  69. data/app/services/katello/pulp3/repository.rb +16 -8
  70. data/app/services/katello/pulp3/repository/yum.rb +234 -35
  71. data/app/services/katello/pulp3/repository_mirror.rb +7 -2
  72. data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +1 -1
  73. data/app/services/katello/pulp3/task.rb +100 -0
  74. data/app/services/katello/pulp3/task_group.rb +85 -0
  75. data/app/services/katello/smart_proxy_helper.rb +13 -16
  76. data/config/routes/api/rhsm.rb +1 -0
  77. data/config/routes/api/v2.rb +2 -6
  78. data/config/routes/overrides.rb +4 -0
  79. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-traces-modal.controller.js +3 -4
  80. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-bulk-action.factory.js +2 -1
  81. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/product-bulk-action.factory.js +1 -0
  82. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details.controller.js +6 -0
  83. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-details.html +7 -1
  84. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +1 -1
  85. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +2 -2
  86. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/repository.factory.js +1 -0
  87. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +15 -0
  88. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/views/products.html +6 -0
  89. data/lib/katello/permission_creator.rb +2 -2
  90. data/lib/katello/permissions/host_permissions.rb +1 -0
  91. data/lib/katello/plugin.rb +0 -1
  92. data/lib/katello/tasks/pulp3_post_migration_check.rake +2 -1
  93. data/lib/katello/tasks/reimport.rake +1 -1
  94. data/lib/katello/version.rb +1 -1
  95. data/webpack/redux/actions/RedHatRepositories/helpers.js +6 -6
  96. metadata +30 -13
  97. data/app/lib/actions/katello/repository/update_cv_repo_cert_guard.rb +0 -17
  98. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-traces-resolve.factory.js +0 -18
@@ -1,7 +1,9 @@
1
1
  module Actions
2
2
  module Katello
3
3
  module ContentViewVersion
4
+ # rubocop:disable Metrics/ClassLength
4
5
  class IncrementalUpdate < Actions::EntryAction
6
+ include ::Katello::ContentViewHelper
5
7
  attr_accessor :new_content_view_version
6
8
 
7
9
  HUMANIZED_TYPES = {
@@ -30,6 +32,19 @@ module Actions
30
32
  validate_environments(environments, old_version)
31
33
 
32
34
  new_minor = old_version.content_view.versions.where(:major => old_version.major).maximum(:minor) + 1
35
+ if SmartProxy.pulp_master.pulp3_repository_type_support?("yum") && is_composite
36
+ sequence do
37
+ publish_action = plan_action(::Actions::Katello::ContentView::Publish, old_version.content_view, description,
38
+ :major => old_version.major, :minor => new_minor,
39
+ :override_components => new_components, :skip_promotion => true)
40
+ if old_version.environments.present?
41
+ plan_action(::Actions::Katello::ContentView::Promote, publish_action.version,
42
+ old_version.environments, true, description)
43
+ end
44
+ end
45
+ return
46
+ end
47
+
33
48
  self.new_content_view_version = old_version.content_view.create_new_version(old_version.major, new_minor, all_components)
34
49
  history = ::Katello::ContentViewHistory.create!(:content_view_version => new_content_view_version, :user => ::User.current.login,
35
50
  :action => ::Katello::ContentViewHistory.actions[:publish],
@@ -41,6 +56,7 @@ module Actions
41
56
 
42
57
  sequence do
43
58
  repository_mapping = plan_action(ContentViewVersion::CreateRepos, new_content_view_version, repos_to_clone).repository_mapping
59
+ separated_repo_map = separated_repo_mapping(repository_mapping)
44
60
 
45
61
  repos_to_clone.each do |source_repos|
46
62
  plan_action(Repository::CloneToVersion,
@@ -51,18 +67,24 @@ module Actions
51
67
  end
52
68
 
53
69
  concurrence do
54
- if SmartProxy.pulp_master.pulp3_support?(repos_to_clone.first.first)
55
- extended_repo_mapping = pulp3_repo_mapping(repository_mapping, old_version)
70
+ if separated_repo_map[:pulp3_yum].keys.flatten.present?
71
+ extended_repo_mapping = pulp3_repo_mapping(separated_repo_map[:pulp3_yum], old_version)
56
72
  unit_map = pulp3_content_mapping(content)
57
73
 
58
- copy_action_outputs << plan_action(Pulp3::Repository::MultiCopyUnits, extended_repo_mapping, unit_map,
59
- dependency_solving: true).output
60
- else
74
+ unless extended_repo_mapping.empty? || unit_map.values.flatten.empty?
75
+ copy_action_outputs << plan_action(Pulp3::Repository::MultiCopyUnits, extended_repo_mapping, unit_map,
76
+ dependency_solving: true).output
77
+ end
78
+ end
79
+
80
+ if separated_repo_map[:other].keys.flatten.present?
61
81
  repos_to_clone.each do |source_repos|
62
- copy_action_outputs += copy_repos(repository_mapping[source_repos],
63
- new_content_view_version,
64
- content,
65
- dep_solve)
82
+ if separated_repo_map[:other].keys.include?(source_repos)
83
+ copy_action_outputs += copy_repos(repository_mapping[source_repos],
84
+ new_content_view_version,
85
+ content,
86
+ dep_solve)
87
+ end
66
88
  end
67
89
  end
68
90
 
@@ -98,11 +120,21 @@ module Actions
98
120
 
99
121
  def pulp3_repo_mapping(repo_mapping, old_version)
100
122
  pulp3_repo_mapping = {}
101
- repo_mapping.each do |source_repo, dest_repo|
102
- source_repo = source_repo.first.library_instance? ? source_repo : [source_repo.first.library_instance]
103
- pulp3_repo_mapping[source_repo.first.id] = { dest_repo: dest_repo.id,
104
- base_version: pulp3_dest_base_version(
105
- ::Katello::ContentViewVersion.find(old_version.id), dest_repo) }
123
+ repo_mapping.each do |source_repos, dest_repo|
124
+ old_version_repo = old_version.repositories.archived.find_by(root_id: dest_repo.root_id)
125
+
126
+ next if old_version_repo.version_href == old_version_repo.library_instance.version_href
127
+
128
+ source_library_repo = source_repos.first.library_instance? ? source_repos.first : source_repos.first.library_instance
129
+
130
+ source_repos = [source_library_repo]
131
+ if old_version_repo.version_href
132
+ base_version = old_version_repo.version_href.split("/")[-1].to_i
133
+ else
134
+ base_version = 0
135
+ end
136
+
137
+ pulp3_repo_mapping[source_repos.map(&:id)] = { dest_repo: dest_repo.id, base_version: base_version }
106
138
  end
107
139
  pulp3_repo_mapping
108
140
  end
@@ -179,42 +211,44 @@ module Actions
179
211
  base_repos = ::Katello::ContentViewVersion.find(input[:old_version]).repositories
180
212
  new_repos = ::Katello::ContentViewVersion.find(input[:new_content_view_version_id]).repositories
181
213
 
182
- if input[:copy_action_outputs].last[:pulp_tasks].last[:pulp_href]&.include?("/pulp/api/v3/")
183
- new_repos.each do |new_repo|
184
- matched_old_repo = base_repos.where(root_id: new_repo.root_id).first
214
+ if input[:copy_action_outputs].present? && input[:copy_action_outputs].last[:pulp_tasks].present?
215
+ if input[:copy_action_outputs].last[:pulp_tasks].last[:pulp_href]&.include?("/pulp/api/v3/")
216
+ new_repos.each do |new_repo|
217
+ matched_old_repo = base_repos.where(root_id: new_repo.root_id).first
185
218
 
186
- new_errata = new_repo.errata - matched_old_repo.errata
187
- new_module_streams = new_repo.module_streams - matched_old_repo.module_streams
188
- new_rpms = new_repo.rpms - matched_old_repo.rpms
219
+ new_errata = new_repo.errata - matched_old_repo.errata
220
+ new_module_streams = new_repo.module_streams - matched_old_repo.module_streams
221
+ new_rpms = new_repo.rpms - matched_old_repo.rpms
189
222
 
190
- new_errata.each do |erratum|
191
- content[::Katello::Erratum::CONTENT_TYPE] << erratum.errata_id
192
- end
193
- new_module_streams.each do |module_stream|
194
- content[::Katello::ModuleStream::CONTENT_TYPE] <<
195
- "#{module_stream.name}:#{module_stream.stream}:#{module_stream.version}"
196
- end
197
- new_rpms.each do |rpm|
198
- content[::Katello::Rpm::CONTENT_TYPE] << rpm.nvra
223
+ new_errata.each do |erratum|
224
+ content[::Katello::Erratum::CONTENT_TYPE] << erratum.errata_id
225
+ end
226
+ new_module_streams.each do |module_stream|
227
+ content[::Katello::ModuleStream::CONTENT_TYPE] <<
228
+ "#{module_stream.name}:#{module_stream.stream}:#{module_stream.version}"
229
+ end
230
+ new_rpms.each do |rpm|
231
+ content[::Katello::Rpm::CONTENT_TYPE] << rpm.nvra
232
+ end
199
233
  end
200
- end
201
- else
202
- input[:copy_action_outputs].each do |copy_output|
203
- copy_output[:pulp_tasks].each do |pulp_task|
204
- pulp_task[:result][:units_successful].each do |unit|
205
- type = unit['type_id']
206
- unit = unit['unit_key']
207
- case type
208
- when ::Katello::Erratum::CONTENT_TYPE
209
- content[::Katello::Erratum::CONTENT_TYPE] << unit['id']
210
- when ::Katello::ModuleStream::CONTENT_TYPE
211
- content[::Katello::ModuleStream::CONTENT_TYPE] << "#{unit['name']}:#{unit['stream']}:#{unit['version']}"
212
- when ::Katello::Rpm::CONTENT_TYPE
213
- content[::Katello::Rpm::CONTENT_TYPE] << ::Katello::Util::Package.build_nvra(unit)
214
- when ::Katello::Deb::CONTENT_TYPE
215
- content[::Katello::Deb::CONTENT_TYPE] << "#{unit['name']}_#{unit['version']}_#{unit['architecture']}"
216
- when ::Katello::PuppetModule::CONTENT_TYPE
217
- content[::Katello::PuppetModule::CONTENT_TYPE] << "#{unit['author']}-#{unit['name']}-#{unit['version']}"
234
+ else
235
+ input[:copy_action_outputs].each do |copy_output|
236
+ copy_output[:pulp_tasks].each do |pulp_task|
237
+ pulp_task[:result][:units_successful].each do |unit|
238
+ type = unit['type_id']
239
+ unit = unit['unit_key']
240
+ case type
241
+ when ::Katello::Erratum::CONTENT_TYPE
242
+ content[::Katello::Erratum::CONTENT_TYPE] << unit['id']
243
+ when ::Katello::ModuleStream::CONTENT_TYPE
244
+ content[::Katello::ModuleStream::CONTENT_TYPE] << "#{unit['name']}:#{unit['stream']}:#{unit['version']}"
245
+ when ::Katello::Rpm::CONTENT_TYPE
246
+ content[::Katello::Rpm::CONTENT_TYPE] << ::Katello::Util::Package.build_nvra(unit)
247
+ when ::Katello::Deb::CONTENT_TYPE
248
+ content[::Katello::Deb::CONTENT_TYPE] << "#{unit['name']}_#{unit['version']}_#{unit['architecture']}"
249
+ when ::Katello::PuppetModule::CONTENT_TYPE
250
+ content[::Katello::PuppetModule::CONTENT_TYPE] << "#{unit['author']}-#{unit['name']}-#{unit['version']}"
251
+ end
218
252
  end
219
253
  end
220
254
  end
@@ -232,8 +266,9 @@ module Actions
232
266
  history.status = ::Katello::ContentViewHistory::SUCCESSFUL
233
267
  history.save!
234
268
 
235
- unless SmartProxy.pulp_master.pulp3_support?(version.repositories.first)
236
- version.repositories.each do |repo|
269
+ cvv_yum_repos = version.repositories.yum_type
270
+ unless cvv_yum_repos.empty? || SmartProxy.pulp_master.pulp3_support?(cvv_yum_repos.first)
271
+ cvv_yum_repos.each do |repo|
237
272
  SmartProxy.pulp_master.pulp_api.extensions.send(:module_default).
238
273
  copy(repo.library_instance.pulp_id,
239
274
  repo.pulp_id)
@@ -315,10 +350,6 @@ module Actions
315
350
  copy_outputs
316
351
  end
317
352
 
318
- def pulp3_dest_base_version(old_cvv, new_repo)
319
- old_cvv.repositories.archived.find_by(root_id: new_repo.root_id).version_href.split("/")[-1].to_i
320
- end
321
-
322
353
  def copy_yum_content(new_repo, dep_solve, package_ids, errata_ids)
323
354
  copy_outputs = []
324
355
  if new_repo.content_type == ::Katello::Repository::YUM_TYPE
@@ -5,6 +5,8 @@ module Actions
5
5
  # rubocop:disable Metrics/MethodLength
6
6
  def plan(product, options = {})
7
7
  organization_destroy = options.fetch(:organization_destroy, false)
8
+ skip_environment_update = options.fetch(:skip_environment_update, false) ||
9
+ options.fetch(:organization_destroy, false)
8
10
 
9
11
  unless organization_destroy || product.user_deletable?
10
12
  if product.redhat?
@@ -24,11 +26,13 @@ module Actions
24
26
 
25
27
  sequence do
26
28
  unless organization_destroy
29
+ sequence do
30
+ # ContentDestroy must be called sequentially due to Candlepin's
31
+ # issues with running multiple remove_content calls at the same time.
32
+ plan_content_destruction(product, skip_environment_update)
33
+ end
27
34
  concurrence do
28
- product.repositories.in_default_view.each do |repo|
29
- repo_options = options.clone
30
- plan_action(Katello::Repository::Destroy, repo, repo_options)
31
- end
35
+ plan_repo_destruction(product, options)
32
36
  end
33
37
  plan_action(Candlepin::Product::DeletePools,
34
38
  cp_id: product.cp_id, organization_label: product.organization.label)
@@ -65,6 +69,23 @@ module Actions
65
69
  product.pool_products.delete_all
66
70
  end
67
71
 
72
+ def plan_content_destruction(product, skip_environment_update)
73
+ product.repositories.in_default_view.each do |repo|
74
+ if repo.root.repositories.where.not(id: repo.id).empty? &&
75
+ !repo.redhat? &&
76
+ !skip_environment_update
77
+ plan_action(::Actions::Katello::Product::ContentDestroy, repo.root)
78
+ end
79
+ end
80
+ end
81
+
82
+ def plan_repo_destruction(product, options)
83
+ product.repositories.in_default_view.each do |repo|
84
+ repo_options = options.clone
85
+ plan_action(Katello::Repository::Destroy, repo, repo_options.merge(destroy_content: false))
86
+ end
87
+ end
88
+
68
89
  def view_versions(product)
69
90
  cvvs = product.published_content_view_versions.uniq
70
91
  views = cvvs.inject({}) do |result, version|
@@ -7,9 +7,11 @@ module Actions
7
7
 
8
8
  # options:
9
9
  # skip_environment_update - defaults to false. skips updating the CP environment
10
+ # destroy_content - can be disabled to skip Candlepin remove_content
10
11
  def plan(repository, options = {})
11
12
  skip_environment_update = options.fetch(:skip_environment_update, false) ||
12
13
  options.fetch(:organization_destroy, false)
14
+ destroy_content = options.fetch(:destroy_content, true)
13
15
  action_subject(repository)
14
16
 
15
17
  unless repository.destroyable?
@@ -29,7 +31,9 @@ module Actions
29
31
  if repository.redhat?
30
32
  handle_redhat_content(repository) unless skip_environment_update
31
33
  else
32
- handle_custom_content(repository) unless skip_environment_update
34
+ if destroy_content && !skip_environment_update
35
+ handle_custom_content(repository)
36
+ end
33
37
  end
34
38
  end
35
39
  end
@@ -0,0 +1,64 @@
1
+ module Actions
2
+ module Katello
3
+ module Repository
4
+ class MultiCloneContents < Actions::Base
5
+ include Actions::Katello::PulpSelector
6
+ def plan(extended_repo_mapping, options)
7
+ generate_metadata = options.fetch(:generate_metadata, true)
8
+ copy_contents = options.fetch(:copy_contents, true)
9
+ solve_dependencies = options.fetch(:solve_dependencies, false)
10
+
11
+ sequence do
12
+ if copy_contents
13
+ plan_action(Pulp3::Orchestration::Repository::MultiCopyAllUnits,
14
+ extended_repo_mapping,
15
+ SmartProxy.pulp_master,
16
+ solve_dependencies: solve_dependencies)
17
+ end
18
+
19
+ concurrence do
20
+ extended_repo_mapping.each do |source_repos, dest_repo_map|
21
+ if generate_metadata
22
+ metadata_generate(source_repos, dest_repo_map[:dest_repo], dest_repo_map[:filters])
23
+ end
24
+ end
25
+
26
+ extended_repo_mapping.values.each do |dest_repo_map|
27
+ plan_action(Katello::Repository::IndexContent, id: dest_repo_map[:dest_repo].id)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ def metadata_generate(source_repositories, new_repository, filters)
34
+ metadata_options = {}
35
+
36
+ if source_repositories.count == 1 && filters.empty?
37
+ metadata_options[:source_repository] = source_repositories.first
38
+ end
39
+
40
+ check_matching_content = ::Katello::RepositoryTypeManager.find(new_repository.content_type).metadata_publish_matching_check
41
+ if new_repository.environment && source_repositories.count == 1 && check_matching_content
42
+ match_check_output = plan_action(Katello::Repository::CheckMatchingContent,
43
+ :source_repo_id => source_repositories.first.id,
44
+ :target_repo_id => new_repository.id).output
45
+
46
+ metadata_options[:matching_content] = match_check_output[:matching_content]
47
+ end
48
+
49
+ plan_action(Katello::Repository::MetadataGenerate, new_repository, metadata_options)
50
+ unless source_repositories.first.saved_checksum_type == new_repository.saved_checksum_type
51
+ plan_self(:source_checksum_type => source_repositories.first.saved_checksum_type,
52
+ :target_repo_id => new_repository.id)
53
+ end
54
+ end
55
+
56
+ def finalize
57
+ repository = ::Katello::Repository.find(input[:target_repo_id])
58
+ source_checksum_type = input[:source_checksum_type]
59
+ repository.update!(saved_checksum_type: source_checksum_type) if (repository && source_checksum_type)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,30 @@
1
+ module Actions
2
+ module Katello
3
+ module Repository
4
+ class MultiCloneToVersion < Actions::Base
5
+ def plan(repository_mapping, content_view_version, options = {})
6
+ incremental = options.fetch(:incremental, false)
7
+ content_view = content_view_version.content_view
8
+ extended_repo_map = extended_repo_mapping(repository_mapping, content_view, incremental)
9
+ sequence do
10
+ plan_action(::Actions::Katello::Repository::MultiCloneContents, extended_repo_map,
11
+ copy_contents: true,
12
+ solve_dependencies: content_view.solve_dependencies,
13
+ metadata_generate: !incremental)
14
+ end
15
+ end
16
+
17
+ def extended_repo_mapping(repo_map, content_view, incremental)
18
+ # Example: {[source_repos] => {dest_repo: dest_repo, filters: filters}}
19
+ extended_repo_map = {}
20
+ repo_map.each do |source_repos, dest_repo|
21
+ filters = incremental ? [] : content_view.filters.applicable(source_repos.first)
22
+ extended_repo_map[source_repos] = { :dest_repo => dest_repo,
23
+ :filters => filters }
24
+ end
25
+ extended_repo_map
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -34,38 +34,47 @@ module Actions
34
34
 
35
35
  pulp_sync_options = {}
36
36
  pulp_sync_options[:download_policy] = ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND if validate_contents && repo.yum?
37
+
38
+ #pulp2 options
37
39
  pulp_sync_options[:force_full] = true if skip_metadata_check && repo.yum?
38
40
  pulp_sync_options[:repair_sync] = true if validate_contents && repo.deb?
39
41
  pulp_sync_options[:remove_missing] = false if incremental
42
+ pulp_sync_options[:source_url] = source_url
43
+
44
+ #pulp3 options
45
+ pulp_sync_options[:optimize] = false if skip_metadata_check && repo.yum?
40
46
 
41
47
  sequence do
42
- plan_action(Pulp::Repository::RemoveUnits, :repo_id => repo.id, :content_unit_type => ::Katello::YumMetadataFile::CONTENT_TYPE) if validate_contents && repo.yum?
43
- sync_args = {:smart_proxy_id => SmartProxy.pulp_master.id, :repo_id => repo.id, :source_url => source_url, :options => pulp_sync_options}
44
- sync_action = plan_pulp_action([Actions::Pulp::Orchestration::Repository::Sync,
45
- Actions::Pulp3::Orchestration::Repository::Sync],
46
- repo,
47
- SmartProxy.pulp_master,
48
- sync_args)
49
- output = sync_action.output
50
-
51
- contents_changed = skip_metadata_check || output[:contents_changed]
52
-
53
- plan_action(Katello::Repository::IndexContent, :id => repo.id, :contents_changed => contents_changed)
54
- plan_action(Katello::Foreman::ContentUpdate, repo.environment, repo.content_view, repo)
55
- plan_action(Katello::Repository::FetchPxeFiles, :id => repo.id)
56
- plan_action(Katello::Repository::CorrectChecksum, repo)
57
- concurrence do
58
- plan_action(Pulp::Repository::Download, :pulp_id => repo.pulp_id, :options => {:verify_all_units => true}) if validate_contents && repo.yum?
59
- plan_action(Katello::Repository::MetadataGenerate, repo, :force => true) if skip_metadata_check && repo.yum?
60
- plan_action(Katello::Repository::ErrataMail, repo, nil, contents_changed)
61
- if generate_applicability
62
- regenerate_applicability(repo, contents_changed)
48
+ if SmartProxy.pulp_master.pulp3_support?(repo) && validate_contents
49
+ plan_action(Katello::Repository::VerifyChecksum, repo)
50
+ else
51
+ plan_action(Pulp::Repository::RemoveUnits, :repo_id => repo.id, :content_unit_type => ::Katello::YumMetadataFile::CONTENT_TYPE) if validate_contents && repo.yum?
52
+ sync_action = plan_pulp_action([Actions::Pulp::Orchestration::Repository::Sync,
53
+ Actions::Pulp3::Orchestration::Repository::Sync],
54
+ repo,
55
+ SmartProxy.pulp_master,
56
+ pulp_sync_options)
57
+ output = sync_action.output
58
+
59
+ contents_changed = skip_metadata_check || output[:contents_changed]
60
+
61
+ plan_action(Katello::Repository::IndexContent, :id => repo.id, :contents_changed => contents_changed)
62
+ plan_action(Katello::Foreman::ContentUpdate, repo.environment, repo.content_view, repo)
63
+ plan_action(Katello::Repository::FetchPxeFiles, :id => repo.id)
64
+ plan_action(Katello::Repository::CorrectChecksum, repo)
65
+ concurrence do
66
+ plan_action(Pulp::Repository::Download, :pulp_id => repo.pulp_id, :options => {:verify_all_units => true}) if validate_contents && repo.yum?
67
+ plan_action(Katello::Repository::MetadataGenerate, repo, :force => true) if skip_metadata_check && repo.yum?
68
+ plan_action(Katello::Repository::ErrataMail, repo, nil, contents_changed)
69
+ if generate_applicability
70
+ regenerate_applicability(repo, contents_changed)
71
+ end
63
72
  end
73
+ plan_self(:id => repo.id, :sync_result => output, :skip_metadata_check => skip_metadata_check, :validate_contents => validate_contents,
74
+ :contents_changed => contents_changed)
75
+ plan_action(Katello::Repository::ImportApplicability, :repo_id => repo.id, :contents_changed => contents_changed) if generate_applicability
76
+ plan_action(Katello::Repository::SyncHook, :id => repo.id)
64
77
  end
65
- plan_self(:id => repo.id, :sync_result => output, :skip_metadata_check => skip_metadata_check, :validate_contents => validate_contents,
66
- :contents_changed => contents_changed)
67
- plan_action(Katello::Repository::ImportApplicability, :repo_id => repo.id, :contents_changed => contents_changed) if generate_applicability
68
- plan_action(Katello::Repository::SyncHook, :id => repo.id)
69
78
  end
70
79
  end
71
80
 
@@ -91,6 +100,7 @@ module Actions
91
100
  def presenter
92
101
  found = all_planned_actions(Pulp::Repository::Sync)
93
102
  found = all_planned_actions(Pulp3::Repository::Sync) if found.empty?
103
+ found = all_planned_actions(Pulp3::Repository::Repair) if found.empty?
94
104
  Helpers::Presenter::Delegated.new(self, found)
95
105
  end
96
106
 
@@ -10,8 +10,7 @@ module Actions
10
10
  action_subject root.library_instance
11
11
 
12
12
  repo_params[:url] = nil if repo_params[:url] == ''
13
- update_cv_cert_protected = (repo_params[:unprotected] != repository.unprotected)
14
-
13
+ update_cv_cert_protected = repo_params.key?(:unprotected) && (repo_params[:unprotected] != repository.unprotected)
15
14
  root.update!(repo_params)
16
15
 
17
16
  if root.download_policy == ::Runcible::Models::YumImporter::DOWNLOAD_BACKGROUND
@@ -42,28 +41,24 @@ module Actions
42
41
  gpg_url: repository.yum_gpg_key_url)
43
42
  end
44
43
  if root.pulp_update_needed?
45
- plan_pulp_action([::Actions::Pulp::Orchestration::Repository::Refresh,
46
- ::Actions::Pulp3::Orchestration::Repository::Update],
47
- repository,
48
- SmartProxy.pulp_master)
49
- plan_self(:repository_id => root.library_instance.id, :update_cv_cert_protected => update_cv_cert_protected)
44
+ sequence do
45
+ plan_pulp_action([::Actions::Pulp::Orchestration::Repository::Refresh,
46
+ ::Actions::Pulp3::Orchestration::Repository::Update],
47
+ repository,
48
+ SmartProxy.pulp_master)
49
+ plan_self(:repository_id => root.library_instance.id)
50
+ if update_cv_cert_protected
51
+ plan_optional_pulp_action([::Actions::Pulp3::Orchestration::Repository::TriggerUpdateRepoCertGuard], repository, ::SmartProxy.pulp_master)
52
+ end
53
+ end
50
54
  end
51
55
  end
52
56
 
53
57
  def run
54
58
  repository = ::Katello::Repository.find(input[:repository_id])
55
- output[:repository_id] = input[:repository_id]
56
- output[:update_cv_cert_protected] = input[:update_cv_cert_protected]
57
59
  ForemanTasks.async_task(Katello::Repository::MetadataGenerate, repository)
58
60
  end
59
61
 
60
- def finalize
61
- repository = ::Katello::Repository.find(output[:repository_id])
62
- if output[:update_cv_cert_protected]
63
- ForemanTasks.async_task(::Actions::Katello::Repository::UpdateCVRepoCertGuard, repository, SmartProxy.pulp_master)
64
- end
65
- end
66
-
67
62
  private
68
63
 
69
64
  def update_content?(repository)