katello 3.16.0.rc3.1 → 3.16.0

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 (120) 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 +2 -2
  4. data/app/controllers/katello/api/v2/api_controller.rb +9 -4
  5. data/app/controllers/katello/api/v2/content_view_filters_controller.rb +5 -1
  6. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +3 -0
  7. data/app/controllers/katello/api/v2/content_views_controller.rb +7 -0
  8. data/app/controllers/katello/api/v2/subscriptions_controller.rb +1 -1
  9. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +13 -1
  10. data/app/controllers/katello/concerns/api/v2/associations_permission_check.rb +67 -0
  11. data/app/controllers/katello/concerns/hosts_controller_extensions.rb +11 -0
  12. data/app/helpers/katello/content_view_helper.rb +15 -0
  13. data/app/lib/actions/katello/capsule_content/refresh_repos.rb +4 -0
  14. data/app/lib/actions/katello/capsule_content/sync.rb +0 -4
  15. data/app/lib/actions/katello/capsule_content/sync_capsule.rb +16 -16
  16. data/app/lib/actions/katello/content_view/incremental_updates.rb +8 -1
  17. data/app/lib/actions/katello/content_view/presenters/incremental_updates_presenter.rb +2 -1
  18. data/app/lib/actions/katello/content_view/publish.rb +55 -16
  19. data/app/lib/actions/katello/content_view_version/incremental_update.rb +120 -26
  20. data/app/lib/actions/katello/host/attach_subscriptions.rb +5 -1
  21. data/app/lib/actions/katello/repository/multi_clone_contents.rb +66 -0
  22. data/app/lib/actions/katello/repository/multi_clone_to_version.rb +30 -0
  23. data/app/lib/actions/katello/sync_plan/run.rb +1 -1
  24. data/app/lib/actions/pulp/abstract_async_task.rb +1 -0
  25. data/app/lib/actions/pulp/consumer/sync_capsule.rb +8 -0
  26. data/app/lib/actions/pulp/repository/presenters/deb_presenter.rb +2 -2
  27. data/app/lib/actions/pulp3/abstract_async_task.rb +62 -58
  28. data/app/lib/actions/pulp3/content_migration.rb +4 -0
  29. data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +1 -2
  30. data/app/lib/actions/pulp3/orchestration/repository/multi_copy_all_units.rb +36 -0
  31. data/app/lib/actions/pulp3/repository/multi_copy_content.rb +28 -0
  32. data/app/lib/actions/pulp3/repository/multi_copy_units.rb +55 -0
  33. data/app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb +1 -1
  34. data/app/lib/actions/pulp3/repository/save_version.rb +11 -3
  35. data/app/lib/actions/pulp3/repository/save_versions.rb +73 -0
  36. data/app/lib/katello/concerns/base_template_scope_extensions.rb +0 -14
  37. data/app/lib/katello/errors.rb +26 -15
  38. data/app/lib/katello/resources/candlepin.rb +1 -1
  39. data/app/lib/katello/resources/candlepin/upstream_consumer.rb +6 -0
  40. data/app/models/katello/concerns/host_managed_extensions.rb +7 -0
  41. data/app/models/katello/concerns/organization_extensions.rb +14 -0
  42. data/app/models/katello/content_view.rb +18 -6
  43. data/app/models/katello/content_view_erratum_filter.rb +13 -0
  44. data/app/models/katello/content_view_filter.rb +4 -0
  45. data/app/models/katello/content_view_module_stream_filter.rb +30 -3
  46. data/app/models/katello/glue/pulp/repo.rb +1 -0
  47. data/app/models/katello/host/content_facet.rb +10 -5
  48. data/app/models/katello/module_stream.rb +1 -1
  49. data/app/models/katello/pulp3/content_guard.rb +1 -1
  50. data/app/models/katello/repository.rb +11 -0
  51. data/app/models/setting/content.rb +3 -1
  52. data/app/presenters/katello/sync_status_presenter.rb +4 -2
  53. data/app/services/katello/candlepin/message_handler.rb +2 -3
  54. data/app/services/katello/pulp/repository/yum.rb +2 -1
  55. data/app/services/katello/pulp3/api/core.rb +4 -0
  56. data/app/services/katello/pulp3/erratum.rb +3 -1
  57. data/app/services/katello/pulp3/migration.rb +9 -4
  58. data/app/services/katello/pulp3/migration_plan.rb +6 -6
  59. data/app/services/katello/pulp3/repository.rb +17 -1
  60. data/app/services/katello/pulp3/repository/yum.rb +187 -25
  61. data/app/services/katello/pulp3/task.rb +100 -0
  62. data/app/services/katello/pulp3/task_group.rb +79 -0
  63. data/app/services/katello/ui_notifications/subscriptions/manifest_expired_warning.rb +20 -8
  64. data/app/services/katello/upstream_connection_checker.rb +48 -0
  65. data/app/views/katello/api/v2/content_view_filters/base.json.rabl +4 -0
  66. data/app/views/katello/api/v2/srpms/backend.json.rabl +11 -0
  67. data/app/views/katello/api/v2/srpms/base.json.rabl +5 -0
  68. data/app/views/katello/api/v2/srpms/compare.json.rabl +10 -0
  69. data/app/views/katello/api/v2/srpms/index.json.rabl +1 -1
  70. data/app/views/katello/api/v2/srpms/show.json.rabl +3 -3
  71. data/config/routes/api/v2.rb +2 -0
  72. data/db/migrate/20200709021250_add_original_modules_to_content_view_module_stream_filter.rb +5 -0
  73. data/db/migrate/20200721142707_remove_duplicate_katello_pools_index.rb +5 -0
  74. data/db/seeds.d/109-katello-notification-blueprints.rb +1 -1
  75. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.routes.js +1 -13
  76. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/filter-details.controller.js +17 -4
  77. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/module-stream-filter-details.html +17 -0
  78. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/errata.routes.js +1 -1
  79. data/engines/bastion_katello/app/assets/stylesheets/bastion_katello/bastion_katello.scss +4 -0
  80. data/lib/katello/engine.rb +0 -1
  81. data/lib/katello/permission_creator.rb +1 -1
  82. data/lib/katello/plugin.rb +2 -0
  83. data/lib/katello/tasks/reports.rake +16 -0
  84. data/lib/katello/version.rb +1 -1
  85. data/package.json +3 -3
  86. data/webpack/components/Content/ContentTable.js +2 -0
  87. data/webpack/components/Content/Details/ContentDetails.js +3 -0
  88. data/webpack/redux/actions/RedHatRepositories/helpers.js +5 -5
  89. data/webpack/scenes/AnsibleCollections/Details/AnsibleCollectionDetails.js +3 -0
  90. data/webpack/scenes/ModuleStreams/Details/ModuleStreamDetails.js +3 -0
  91. data/webpack/scenes/RedHatRepositories/RedHatRepositoriesPage.js +2 -0
  92. data/webpack/scenes/RedHatRepositories/components/EnabledRepository/EnabledRepository.js +2 -0
  93. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js +2 -0
  94. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailAssociations.js +2 -0
  95. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailProductContent.js +2 -0
  96. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailProducts.js +2 -0
  97. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +2 -0
  98. data/webpack/scenes/Subscriptions/SubscriptionActions.js +8 -8
  99. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +3 -1
  100. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +15 -1
  101. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +54 -7
  102. data/webpack/scenes/Subscriptions/SubscriptionsSelectors.js +3 -0
  103. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js +15 -1
  104. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/{UpstreamSubscriptionsContstants.js → UpstreamSubscriptionsConstants.js} +3 -0
  105. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +2 -0
  106. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js +1 -1
  107. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js +1 -1
  108. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js +0 -13
  109. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +6 -1
  110. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +6 -4
  111. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsReducer.test.js.snap +26 -25
  112. data/webpack/scenes/Subscriptions/__tests__/subscriptions.fixtures.js +0 -58
  113. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTable.js +10 -4
  114. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.test.js +1 -0
  115. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +1 -68
  116. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Dialogs/UpdateDialog.js +1 -1
  117. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Dialogs/index.js +4 -4
  118. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Table.js +12 -10
  119. data/webpack/scenes/Subscriptions/index.js +6 -3
  120. metadata +44 -27
@@ -5,6 +5,7 @@ module Actions
5
5
  class IncrementalUpdatesPresenter < Helpers::Presenter::Base
6
6
  HUMANIZED_TYPES = {
7
7
  ::Katello::Erratum::CONTENT_TYPE => "Errata",
8
+ ::Katello::ModuleStream::CONTENT_TYPE => "Module Streams",
8
9
  ::Katello::Rpm::CONTENT_TYPE => "Packages",
9
10
  ::Katello::PuppetModule::CONTENT_TYPE => "Puppet Modules"
10
11
  }.freeze
@@ -25,7 +26,7 @@ module Actions
25
26
  if cvv
26
27
  humanized_lines << "Content View: #{cvv.content_view.name} version #{cvv.version}"
27
28
  humanized_lines << _("Added Content:")
28
- [::Katello::Erratum, ::Katello::Rpm, ::Katello::PuppetModule].each do |content_type|
29
+ [::Katello::Erratum, ::Katello::ModuleStream, ::Katello::Rpm, ::Katello::PuppetModule].each do |content_type|
29
30
  unless output[:added_units][content_type::CONTENT_TYPE].blank?
30
31
  humanized_lines << " #{HUMANIZED_TYPES[content_type::CONTENT_TYPE]}:"
31
32
  humanized_lines += output[:added_units][content_type::CONTENT_TYPE].sort.map { |unit| " #{unit}" }
@@ -3,6 +3,8 @@ module Actions
3
3
  module Katello
4
4
  module ContentView
5
5
  class Publish < Actions::EntryAction
6
+ include ::Katello::ContentViewHelper
7
+ attr_accessor :version
6
8
  # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
7
9
  def plan(content_view, description = "", options = {})
8
10
  action_subject(content_view)
@@ -21,7 +23,11 @@ module Actions
21
23
  end
22
24
  end
23
25
 
26
+ # Add non-override components back in
27
+ options[:override_components] = include_other_components(options[:override_components], content_view)
28
+
24
29
  version = version_for_publish(content_view, options)
30
+ self.version = version
25
31
  library = content_view.organization.library
26
32
  history = ::Katello::ContentViewHistory.create!(:content_view_version => version,
27
33
  :user => ::User.current.login,
@@ -32,20 +38,30 @@ module Actions
32
38
  :triggered_by => options[:triggered_by]
33
39
  )
34
40
  source_repositories = []
35
- content_view.publish_repositories do |repositories|
41
+ content_view.publish_repositories(options[:override_cvvs]) do |repositories|
36
42
  source_repositories += [repositories]
37
43
  end
38
44
 
39
45
  sequence do
40
- plan_action(ContentView::AddToEnvironment, version, library)
46
+ plan_action(ContentView::AddToEnvironment, version, library) unless options[:skip_promotion]
41
47
  repository_mapping = plan_action(ContentViewVersion::CreateRepos, version, source_repositories).repository_mapping
42
48
 
49
+ # Split Pulp 3 Yum repos out of the repository_mapping. Only Pulp 3 RPM plugin has multi repo copy support.
50
+ separated_repo_map = separated_repo_mapping(repository_mapping)
51
+
52
+ if separated_repo_map[:pulp3_yum].keys.flatten.present? &&
53
+ SmartProxy.pulp_master.pulp3_support?(separated_repo_map[:pulp3_yum].keys.flatten.first)
54
+ plan_action(Repository::MultiCloneToVersion, separated_repo_map[:pulp3_yum], version)
55
+ end
56
+
43
57
  concurrence do
44
58
  source_repositories.each do |repositories|
45
59
  sequence do
46
- plan_action(Repository::CloneToVersion, repositories, version, repository_mapping[repositories],
47
- :repos_units => options[:repos_units])
48
- plan_action(Repository::CloneToEnvironment, repository_mapping[repositories], library)
60
+ if repositories.present? && separated_repo_map[:other].keys.include?(repositories)
61
+ plan_action(Repository::CloneToVersion, repositories, version, repository_mapping[repositories],
62
+ :repos_units => options[:repos_units])
63
+ end
64
+ plan_action(Repository::CloneToEnvironment, repository_mapping[repositories], library) unless options[:skip_promotion]
49
65
  end
50
66
  end
51
67
 
@@ -55,16 +71,18 @@ module Actions
55
71
  end
56
72
  has_modules = content_view.publish_puppet_environment?
57
73
  plan_action(ContentViewPuppetEnvironment::CreateForVersion, version)
58
- plan_action(ContentViewPuppetEnvironment::Clone, version, :environment => library,
59
- :puppet_modules_present => has_modules)
60
- plan_action(Candlepin::Environment::SetContent, content_view, library, content_view.content_view_environment(library))
61
- plan_action(Katello::Foreman::ContentUpdate, library, content_view)
62
- plan_action(ContentView::ErrataMail, content_view, library)
74
+ unless options[:skip_promotion]
75
+ plan_action(ContentViewPuppetEnvironment::Clone, version, :environment => library,
76
+ :puppet_modules_present => has_modules)
77
+ end
78
+ plan_action(Candlepin::Environment::SetContent, content_view, library, content_view.content_view_environment(library)) unless options[:skip_promotion]
79
+ plan_action(Katello::Foreman::ContentUpdate, library, content_view) unless options[:skip_promotion]
80
+ plan_action(ContentView::ErrataMail, content_view, library) unless options[:skip_promotion]
63
81
  plan_self(history_id: history.id, content_view_id: content_view.id,
64
82
  auto_publish_composite_ids: auto_publish_composite_ids(content_view),
65
83
  content_view_version_name: version.name,
66
84
  content_view_version_id: version.id,
67
- environment_id: library.id, user_id: ::User.current.id)
85
+ environment_id: library.id, user_id: ::User.current.id, skip_promotion: options[:skip_promotion])
68
86
  end
69
87
  end
70
88
 
@@ -85,6 +103,7 @@ module Actions
85
103
 
86
104
  output[:content_view_id] = input[:content_view_id]
87
105
  output[:content_view_version_id] = input[:content_view_version_id]
106
+ output[:skip_promotion] = input[:skip_promotion]
88
107
  end
89
108
 
90
109
  def rescue_strategy_for_self
@@ -95,9 +114,11 @@ module Actions
95
114
  version = ::Katello::ContentViewVersion.find(input[:content_view_version_id])
96
115
  version.update_content_counts!
97
116
  # update errata applicability counts for all hosts in the CV & Library
98
- ::Katello::Host::ContentFacet.where(:content_view_id => input[:content_view_id],
99
- :lifecycle_environment_id => input[:environment_id]).each do |facet|
100
- facet.update_applicability_counts
117
+ unless input[:skip_promotion]
118
+ ::Katello::Host::ContentFacet.where(:content_view_id => input[:content_view_id],
119
+ :lifecycle_environment_id => input[:environment_id]).each do |facet|
120
+ facet.update_applicability_counts
121
+ end
101
122
  end
102
123
 
103
124
  history = ::Katello::ContentViewHistory.find(input[:history_id])
@@ -105,7 +126,7 @@ module Actions
105
126
  history.save!
106
127
  environment = ::Katello::KTEnvironment.find(input[:environment_id])
107
128
  view = ::Katello::ContentView.find(input[:content_view_id])
108
- if SmartProxy.sync_needed?(environment) && Setting[:foreman_proxy_content_auto_sync]
129
+ if SmartProxy.sync_needed?(environment) && Setting[:foreman_proxy_content_auto_sync] && !input[:skip_promotion]
109
130
  ForemanTasks.async_task(ContentView::CapsuleSync,
110
131
  view,
111
132
  environment)
@@ -115,6 +136,20 @@ module Actions
115
136
 
116
137
  private
117
138
 
139
+ def include_other_components(override_components, content_view)
140
+ if override_components.present?
141
+ content_view.components.each do |component|
142
+ component_has_override = override_components.detect do |override_component|
143
+ component.content_view_id == override_component.content_view_id
144
+ end
145
+ unless component_has_override
146
+ override_components << component
147
+ end
148
+ end
149
+ override_components
150
+ end
151
+ end
152
+
118
153
  def repos_to_delete(content_view)
119
154
  if content_view.composite?
120
155
  library_instances = content_view.repositories_to_publish.map(&:library_instance_id)
@@ -132,7 +167,11 @@ module Actions
132
167
 
133
168
  def version_for_publish(content_view, options)
134
169
  if options[:minor] && options[:major]
135
- content_view.create_new_version(options[:major], options[:minor])
170
+ if options[:override_components]
171
+ content_view.create_new_version(options[:major], options[:minor], options[:override_components])
172
+ else
173
+ content_view.create_new_version(options[:major], options[:minor])
174
+ end
136
175
  else
137
176
  content_view.create_new_version
138
177
  end
@@ -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,11 +67,25 @@ module Actions
51
67
  end
52
68
 
53
69
  concurrence do
54
- repos_to_clone.each do |source_repos|
55
- copy_action_outputs += copy_repos(repository_mapping[source_repos],
56
- new_content_view_version,
57
- content,
58
- dep_solve)
70
+ if separated_repo_map[:pulp3_yum].keys.flatten.present?
71
+ extended_repo_mapping = pulp3_repo_mapping(separated_repo_map[:pulp3_yum], old_version)
72
+ unit_map = pulp3_content_mapping(content)
73
+
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?
81
+ repos_to_clone.each do |source_repos|
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
88
+ end
59
89
  end
60
90
 
61
91
  sequence do
@@ -68,11 +98,47 @@ module Actions
68
98
  plan_self(:content_view_id => old_version.content_view.id,
69
99
  :new_content_view_version_id => self.new_content_view_version.id,
70
100
  :environment_ids => environments.map(&:id), :user_id => ::User.current.id,
71
- :history_id => history.id, :copy_action_outputs => copy_action_outputs)
101
+ :history_id => history.id, :copy_action_outputs => copy_action_outputs,
102
+ :old_version => old_version.id)
72
103
  promote(new_content_view_version, environments)
73
104
  end
74
105
  end
75
106
 
107
+ def pulp3_content_mapping(content)
108
+ units = ::Katello::Erratum.with_identifiers(content[:errata_ids]) +
109
+ ::Katello::Rpm.with_identifiers(content[:package_ids])
110
+ unit_map = { :errata => [], :rpms => [] }
111
+ units.each do |unit|
112
+ if unit.class.name == "Katello::Erratum"
113
+ unit_map[:errata] << unit.id
114
+ elsif unit.class.name == "Katello::Rpm"
115
+ unit_map[:rpms] << unit.id
116
+ end
117
+ end
118
+ unit_map
119
+ end
120
+
121
+ def pulp3_repo_mapping(repo_mapping, old_version)
122
+ pulp3_repo_mapping = {}
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 }
138
+ end
139
+ pulp3_repo_mapping
140
+ end
141
+
76
142
  def repos_to_copy(old_version, new_components)
77
143
  old_version.archived_repos.map do |source_repo|
78
144
  components_repo_instances(source_repo, new_components)
@@ -142,22 +208,48 @@ module Actions
142
208
  ::Katello::PuppetModule::CONTENT_TYPE => []
143
209
  }
144
210
 
145
- input[:copy_action_outputs].each do |copy_output|
146
- copy_output[:pulp_tasks].each do |pulp_task|
147
- pulp_task[:result][:units_successful].each do |unit|
148
- type = unit['type_id']
149
- unit = unit['unit_key']
150
- case type
151
- when ::Katello::Erratum::CONTENT_TYPE
152
- content[::Katello::Erratum::CONTENT_TYPE] << unit['id']
153
- when ::Katello::ModuleStream::CONTENT_TYPE
154
- content[::Katello::ModuleStream::CONTENT_TYPE] << "#{unit['name']}:#{unit['stream']}:#{unit['version']}"
155
- when ::Katello::Rpm::CONTENT_TYPE
156
- content[::Katello::Rpm::CONTENT_TYPE] << ::Katello::Util::Package.build_nvra(unit)
157
- when ::Katello::Deb::CONTENT_TYPE
158
- content[::Katello::Deb::CONTENT_TYPE] << "#{unit['name']}_#{unit['version']}_#{unit['architecture']}"
159
- when ::Katello::PuppetModule::CONTENT_TYPE
160
- content[::Katello::PuppetModule::CONTENT_TYPE] << "#{unit['author']}-#{unit['name']}-#{unit['version']}"
211
+ base_repos = ::Katello::ContentViewVersion.find(input[:old_version]).repositories
212
+ new_repos = ::Katello::ContentViewVersion.find(input[:new_content_view_version_id]).repositories
213
+
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
218
+
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
222
+
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
233
+ end
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
252
+ end
161
253
  end
162
254
  end
163
255
  end
@@ -174,10 +266,12 @@ module Actions
174
266
  history.status = ::Katello::ContentViewHistory::SUCCESSFUL
175
267
  history.save!
176
268
 
177
- version.repositories.each do |repo|
178
- SmartProxy.pulp_master.pulp_api.extensions.send(:module_default).
179
- copy(repo.library_instance.pulp_id,
180
- repo.pulp_id)
269
+ unless SmartProxy.pulp_master.pulp3_support?(version.repositories.first)
270
+ version.repositories.each do |repo|
271
+ SmartProxy.pulp_master.pulp_api.extensions.send(:module_default).
272
+ copy(repo.library_instance.pulp_id,
273
+ repo.pulp_id)
274
+ end
181
275
  end
182
276
  end
183
277
 
@@ -8,12 +8,16 @@ module Actions
8
8
 
9
9
  def plan(host, pools_with_quantities_params)
10
10
  action_subject(host)
11
+
12
+ subscription_facet = host.subscription_facet
13
+ fail _("Register host '%s' before attaching subscriptions") % host.name unless subscription_facet
14
+
11
15
  sequence do
12
16
  pool_ids = []
13
17
  pools_with_quantities = pools_with_quantities_params.map do |pool_with_quantity|
14
18
  ::Katello::PoolWithQuantities.fetch(pool_with_quantity)
15
19
  end
16
- existing_pool_ids = host.subscription_facet.candlepin_consumer.pool_ids
20
+ existing_pool_ids = subscription_facet.candlepin_consumer.pool_ids
17
21
  pools_with_quantities.each do |pool_with_quantities|
18
22
  unless existing_pool_ids.include?(pool_with_quantities.pool.cp_id.to_s)
19
23
  pool_ids << pool_with_quantities.pool.id
@@ -0,0 +1,66 @@
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
+ extended_repo_mapping.each do |source_repos, dest_repo_map|
20
+ if generate_metadata
21
+ metadata_generate(source_repos, dest_repo_map[:dest_repo], dest_repo_map[:filters])
22
+ end
23
+ end
24
+
25
+ extended_repo_mapping.values.each do |dest_repo_map|
26
+ plan_action(Katello::Repository::IndexContent, id: dest_repo_map[:dest_repo].id)
27
+ end
28
+ end
29
+ end
30
+
31
+ def metadata_generate(source_repositories, new_repository, filters)
32
+ metadata_options = {}
33
+
34
+ if source_repositories.count == 1 && filters.empty?
35
+ metadata_options[:source_repository] = source_repositories.first
36
+ end
37
+
38
+ check_matching_content = ::Katello::RepositoryTypeManager.find(new_repository.content_type).metadata_publish_matching_check
39
+ if new_repository.environment && source_repositories.count == 1 && check_matching_content
40
+ match_check_output = plan_action(Katello::Repository::CheckMatchingContent,
41
+ :source_repo_id => source_repositories.first.id,
42
+ :target_repo_id => new_repository.id).output
43
+
44
+ metadata_options[:matching_content] = match_check_output[:matching_content]
45
+ end
46
+
47
+ plan_action(Katello::Repository::MetadataGenerate, new_repository, metadata_options)
48
+ unless source_repositories.first.saved_checksum_type == new_repository.saved_checksum_type
49
+ checksum_mapping = {}
50
+ repository_mapping.each do |source_repos, dest_repo|
51
+ checksum_mapping[dest_repo.id] = source_repos.first.saved_checksum_type
52
+ end
53
+ plan_self(:checksum_mapping => checksum_mapping)
54
+ end
55
+ end
56
+
57
+ def finalize
58
+ input[:checksum_mapping].each do |repo_id, checksum_type|
59
+ repository = ::Katello::Repository.find(repo_id)
60
+ repository.update!(saved_checksum_type: checksum_type) if (repository && checksum_type)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ 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