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
@@ -26,8 +26,10 @@ module Katello
26
26
  end
27
27
 
28
28
  def update_model(model)
29
- keys = %w(title id severity issued type description reboot_suggested solution updated summary)
29
+ keys = %w(title id severity issued_date type description reboot_suggested solution updated_date summary)
30
30
  custom_json = backend_data.slice(*keys)
31
+ custom_json["issued"] = custom_json.delete("issued_date")
32
+ custom_json["updated"] = custom_json.delete("updated_date")
31
33
 
32
34
  # handle SUSE epoch dates
33
35
  custom_json["issued"] = convert_date_if_epoch(custom_json["issued"])
@@ -35,11 +35,15 @@ module Katello
35
35
  end
36
36
 
37
37
  def pulp2_content_api
38
- Pulp2to3MigrationClient::Pulp2contentApi.new(api_client)
38
+ Pulp2to3MigrationClient::Pulp2ContentApi.new(api_client)
39
+ rescue NameError
40
+ Pulp2to3MigrationClient::Pulp2contentApi.new(api_client) #backwards compatible
39
41
  end
40
42
 
41
43
  def pulp2_repositories_api
42
- Pulp2to3MigrationClient::Pulp2repositoriesApi.new(api_client)
44
+ Pulp2to3MigrationClient::Pulp2RepositoriesApi.new(api_client)
45
+ rescue NameError
46
+ Pulp2to3MigrationClient::Pulp2repositoriesApi.new(api_client) #backwards compatible
43
47
  end
44
48
 
45
49
  def create_and_run_migrations
@@ -64,8 +68,9 @@ module Katello
64
68
  end
65
69
 
66
70
  def create_migrations
67
- migration_plans = @repository_types.map { |label| Katello::Pulp3::MigrationPlan.new(label) }
68
- migration_plans.map { |plan| migration_plan_api.create(plan: plan.generate.as_json).pulp_href }
71
+ plan = Katello::Pulp3::MigrationPlan.new(@repository_types)
72
+ Rails.logger.info(plan)
73
+ [migration_plan_api.create(plan: plan.generate.as_json).pulp_href]
69
74
  end
70
75
 
71
76
  def start_migration(plan_href)
@@ -1,8 +1,8 @@
1
1
  module Katello
2
2
  module Pulp3
3
3
  class MigrationPlan
4
- def initialize(repository_type_label)
5
- @repository_type = repository_type_label
4
+ def initialize(repository_type_labels)
5
+ @repository_types = repository_type_labels
6
6
  end
7
7
 
8
8
  def master_proxy
@@ -17,12 +17,12 @@ module Katello
17
17
  end
18
18
 
19
19
  def generate_plugins
20
- [
20
+ @repository_types.map do |repository_type|
21
21
  {
22
- type: pulp2_repository_type(@repository_type),
23
- repositories: repository_migrations(@repository_type)
22
+ type: pulp2_repository_type(repository_type),
23
+ repositories: repository_migrations(repository_type)
24
24
  }
25
- ]
25
+ end
26
26
  end
27
27
 
28
28
  def pulp2_repository_type(repository_type)
@@ -48,6 +48,10 @@ module Katello
48
48
  nil
49
49
  end
50
50
 
51
+ def skip_types
52
+ nil
53
+ end
54
+
51
55
  def content_service
52
56
  Katello::Pulp3::Content
53
57
  end
@@ -189,8 +193,15 @@ module Katello
189
193
  ignore_404_exception { api.repositories_api.delete(href) } if href
190
194
  end
191
195
 
196
+ def sync_params
197
+ {remote: repo.remote_href, mirror: repo.root.mirror_on_sync}
198
+ end
199
+
192
200
  def sync
193
- repository_sync_url_data = api.class.repository_sync_url_class.new(remote: repo.remote_href, mirror: repo.root.mirror_on_sync)
201
+ sync_url_params = sync_params
202
+ skip_type_param = skip_types
203
+ sync_url_params[:skip_types] = skip_type_param if skip_type_param
204
+ repository_sync_url_data = api.class.repository_sync_url_class.new(sync_url_params)
194
205
  [api.repositories_api.sync(repository_reference.repository_href, repository_sync_url_data)]
195
206
  end
196
207
 
@@ -345,6 +356,11 @@ module Katello
345
356
  api.repositories_api.modify(repository_reference.repository_href, add_content_units: content_unit_href)
346
357
  end
347
358
 
359
+ def add_content_for_repo(repository_href, content_unit_href)
360
+ content_unit_href = [content_unit_href] unless content_unit_href.is_a?(Array)
361
+ api.repositories_api.modify(repository_href, add_content_units: content_unit_href)
362
+ end
363
+
348
364
  def unit_keys(uploads)
349
365
  uploads.map do |upload|
350
366
  upload.except('id')
@@ -15,6 +15,14 @@ module Katello
15
15
  end
16
16
  end
17
17
 
18
+ def skip_types
19
+ skip_types = []
20
+ if root.ignorable_content.try(:include?, "srpm")
21
+ skip_types << "srpm"
22
+ end
23
+ skip_types
24
+ end
25
+
18
26
  def distribution_options(path)
19
27
  {
20
28
  base_path: path,
@@ -23,6 +31,10 @@ module Katello
23
31
  }
24
32
  end
25
33
 
34
+ def sync_params
35
+ {remote: repo.remote_href, mirror: repo.root.mirror_on_sync, optimize: false}
36
+ end
37
+
26
38
  def mirror_remote_options
27
39
  policy = smart_proxy.download_policy
28
40
 
@@ -62,30 +74,87 @@ module Katello
62
74
  "/pulp/repos/#{repo.relative_path}/".sub('//', '/')
63
75
  end
64
76
 
65
- def copy_units(source_repository_version_href, content_unit_hrefs, dependency_solving)
77
+ def multi_copy_units(repo_id_map, dependency_solving)
66
78
  tasks = []
67
79
 
68
- if content_unit_hrefs.any?
80
+ if repo_id_map.values.pluck(:content_unit_hrefs).flatten.any?
81
+ data = PulpRpmClient::Copy.new
82
+ data.dependency_solving = dependency_solving
83
+ data.config = []
84
+ repo_id_map.each do |source_repo_ids, dest_repo_id_map|
85
+ dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
86
+ dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
87
+ content_unit_hrefs = dest_repo_id_map[:content_unit_hrefs]
88
+ # Not needed during incremental update due to dest_base_version
89
+ unless dest_repo_id_map[:base_version]
90
+ source_repo_for_package_envs = ::Katello::Repository.find(source_repo_ids.first)
91
+ unless source_repo_for_package_envs.library_instance?
92
+ source_repo_for_package_envs = source_repo_for_package_envs.library_instance
93
+ end
94
+ package_env_hrefs = packageenvironments({ :repository_version => source_repo_for_package_envs.version_href }).map(&:pulp_href).sort
95
+ tasks << remove_all_content_from_repo(dest_repo_href)
96
+ tasks << add_content_for_repo(dest_repo_href, package_env_hrefs) unless package_env_hrefs.empty?
97
+ end
98
+ source_repo_ids.each do |source_repo_id|
99
+ source_repo_version = ::Katello::Repository.find(source_repo_id).version_href
100
+ config = { source_repo_version: source_repo_version, dest_repo: dest_repo_href, content: content_unit_hrefs }
101
+ config[:dest_base_version] = dest_repo_id_map[:base_version] if dest_repo_id_map[:base_version]
102
+ data.config << config
103
+ end
104
+ end
105
+ # FIXME: data's content being [] causes all content to be copied back
106
+ tasks << api.copy_api.copy_content(data)
107
+ else
108
+ tasks << remove_all_content_from_mapping(repo_id_map)
109
+ end
110
+ tasks.flatten
111
+ end
112
+
113
+ def remove_all_content_from_mapping(repo_id_map)
114
+ tasks = []
115
+ repo_id_map.each do |_source_repo_ids, dest_repo_id_map|
116
+ dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
117
+ dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_master).repository_reference.repository_href
118
+ tasks << remove_all_content_from_repo(dest_repo_href)
119
+ end
120
+ tasks
121
+ end
122
+
123
+ def copy_units(source_repository, content_unit_hrefs, dependency_solving)
124
+ tasks = []
125
+
126
+ if content_unit_hrefs.sort!.any?
69
127
  data = PulpRpmClient::Copy.new
70
- data.config = [
71
- source_repo_version: source_repository_version_href,
128
+ data.config = [{
129
+ source_repo_version: source_repository.version_href,
72
130
  dest_repo: repository_reference.repository_href,
73
131
  dest_base_version: 0,
74
- content: content_unit_hrefs.sort
75
- ]
132
+ content: content_unit_hrefs
133
+ }]
76
134
  data.dependency_solving = dependency_solving
135
+ package_env_hrefs = packageenvironments({ :repository_version => source_repository.version_href }).map(&:pulp_href).sort
77
136
  tasks << api.copy_api.copy_content(data)
137
+ tasks << add_content(package_env_hrefs) unless package_env_hrefs.empty?
78
138
  else
79
- data = PulpRpmClient::RepositoryAddRemoveContent.new(
80
- remove_content_units: ['*'])
81
- tasks << api.repositories_api.modify(repository_reference.repository_href, data)
139
+ tasks << remove_all_content
82
140
  end
83
-
84
141
  tasks
85
142
  end
86
143
 
144
+ def remove_all_content_from_repo(repo_href)
145
+ data = PulpRpmClient::RepositoryAddRemoveContent.new(
146
+ remove_content_units: ['*'])
147
+ api.repositories_api.modify(repo_href, data)
148
+ end
149
+
150
+ def remove_all_content
151
+ data = PulpRpmClient::RepositoryAddRemoveContent.new(
152
+ remove_content_units: ['*'])
153
+ api.repositories_api.modify(repository_reference.repository_href, data)
154
+ end
155
+
87
156
  def packageenvironments(options = {})
88
- api.content_package_environments_api.list(options)
157
+ Katello::Pulp3::Api::Core.fetch_from_list { |page_opts| api.content_package_environments_api.list(page_opts.merge(options)) }
89
158
  end
90
159
 
91
160
  def metadatafiles(options = {})
@@ -96,6 +165,94 @@ module Katello
96
165
  api.content_distribution_trees_api.list(options)
97
166
  end
98
167
 
168
+ def add_filter_content(source_repo_ids, filters, filter_list_map)
169
+ filters.each do |filter|
170
+ if filter.inclusion
171
+ source_repo_ids.each do |repo_id|
172
+ filter_list_map[:whitelist_ids] += filter.content_unit_pulp_ids(::Katello::Repository.find(repo_id))
173
+ end
174
+ else
175
+ source_repo_ids.each do |repo_id|
176
+ filter_list_map[:blacklist_ids] += filter.content_unit_pulp_ids(::Katello::Repository.find(repo_id))
177
+ end
178
+ end
179
+ end
180
+ filter_list_map
181
+ end
182
+
183
+ def add_un_modular_rpms(source_repo_ids, filters, filter_list_map)
184
+ if (filter_list_map[:whitelist_ids].empty? && filters.select { |filter| filter.inclusion }.empty?)
185
+ filter_list_map[:whitelist_ids] += source_repo_ids.collect do |source_repo_id|
186
+ source_repo = ::Katello::Repository.find(source_repo_id)
187
+ source_repo.rpms.where(:modular => false).pluck(:pulp_id).sort
188
+ end
189
+ end
190
+ filter_list_map
191
+ end
192
+
193
+ def add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
194
+ inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
195
+ exclusion_modular_filters = modular_filters - inclusion_modular_filters
196
+ if inclusion_modular_filters.empty? &&
197
+ !(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
198
+ source_repo_ids.each do |source_repo_id|
199
+ source_repo = ::Katello::Repository.find(source_repo_id)
200
+ filter_list_map[:whitelist_ids] += source_repo.rpms.where(:modular => true).pluck(:pulp_id).sort
201
+ filter_list_map[:whitelist_ids] += source_repo.module_streams.pluck(:pulp_id).sort
202
+ end
203
+ end
204
+
205
+ unless inclusion_modular_filters.empty?
206
+ filter_list_map[:whitelist_ids] += source_repo_ids.collect do |source_repo_id|
207
+ source_repo = ::Katello::Repository.find(source_repo_id)
208
+ modular_packages(source_repo, inclusion_modular_filters)
209
+ end
210
+ end
211
+
212
+ unless exclusion_modular_filters.empty?
213
+ filter_list_map[:blacklist_ids] += source_repo_ids.collect do |source_repo_id|
214
+ source_repo = ::Katello::Repository.find(source_repo_id)
215
+ modular_packages(source_repo, exclusion_modular_filters)
216
+ end
217
+ end
218
+
219
+ filter_list_map
220
+ end
221
+
222
+ def copy_content_from_mapping(repo_id_map, options = {})
223
+ repo_id_map.each do |source_repo_ids, dest_repo_map|
224
+ filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
225
+ filter_class.where(:id => dest_repo_map[:filter_ids])
226
+ end
227
+ modular_filters = ContentViewModuleStreamFilter.where(:id => dest_repo_map[:filter_ids])
228
+ filters.flatten!.compact!
229
+
230
+ filter_list_map = { whitelist_ids: [], blacklist_ids: [] }
231
+ filter_list_map = add_filter_content(source_repo_ids, filters, filter_list_map)
232
+ filter_list_map = add_un_modular_rpms(source_repo_ids, filters, filter_list_map)
233
+ filter_list_map = add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
234
+
235
+ whitelist_ids = filter_list_map[:whitelist_ids].flatten&.uniq
236
+ blacklist_ids = filter_list_map[:blacklist_ids].flatten&.uniq
237
+ content_unit_hrefs = whitelist_ids - blacklist_ids
238
+
239
+ if content_unit_hrefs.any?
240
+ source_repo_ids.each do |source_repo_id|
241
+ content_unit_hrefs += additional_content_hrefs(::Katello::Repository.find(source_repo_id), content_unit_hrefs)
242
+ end
243
+ end
244
+ source_repo_ids.each do |source_repo_id|
245
+ content_unit_hrefs += ::Katello::Repository.find(source_repo_id).srpms.pluck(:pulp_id)
246
+ end
247
+
248
+ dest_repo_map[:content_unit_hrefs] = content_unit_hrefs.uniq.sort
249
+ end
250
+
251
+ dependency_solving = options[:solve_dependencies] || false
252
+
253
+ multi_copy_units(repo_id_map, dependency_solving)
254
+ end
255
+
99
256
  def copy_content_for_source(source_repository, options = {})
100
257
  filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
101
258
  filter_class.where(:id => options[:filter_ids])
@@ -113,19 +270,33 @@ module Katello
113
270
  end
114
271
  end
115
272
 
116
- if whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?
117
- whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort
118
- end
273
+ whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort if (whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?)
119
274
 
275
+ modular_filters = ContentViewModuleStreamFilter.where(:id => options[:filter_ids])
276
+ inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
277
+ exclusion_modular_filters = modular_filters - inclusion_modular_filters
278
+ if inclusion_modular_filters.empty? && !(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
279
+ whitelist_ids += source_repository.rpms.where(:modular => true).pluck(:pulp_id).sort
280
+ whitelist_ids += source_repository.module_streams.pluck(:pulp_id).sort
281
+ end
282
+ whitelist_ids += modular_packages(source_repository, inclusion_modular_filters) unless inclusion_modular_filters.empty?
283
+ blacklist_ids += modular_packages(source_repository, exclusion_modular_filters) unless exclusion_modular_filters.empty?
120
284
  content_unit_hrefs = whitelist_ids - blacklist_ids
121
-
122
285
  if content_unit_hrefs.any?
123
286
  content_unit_hrefs += additional_content_hrefs(source_repository, content_unit_hrefs)
124
287
  end
125
288
  content_unit_hrefs += source_repository.srpms.pluck(:pulp_id)
126
289
 
127
290
  dependency_solving = options[:solve_dependencies] || false
128
- copy_units(source_repository.version_href, content_unit_hrefs.uniq, dependency_solving)
291
+ copy_units(source_repository, content_unit_hrefs.uniq, dependency_solving)
292
+ end
293
+
294
+ def modular_packages(source_repository, filters)
295
+ list_ids = []
296
+ filters.each do |filter|
297
+ list_ids += filter.content_unit_pulp_ids(source_repository, true)
298
+ end
299
+ list_ids
129
300
  end
130
301
 
131
302
  def additional_content_hrefs(source_repository, content_unit_hrefs)
@@ -138,10 +309,6 @@ module Katello
138
309
  package_groups_to_include = filter_package_groups_by_pulp_href(source_repository.package_groups, content_unit_hrefs)
139
310
  content_unit_hrefs += package_groups_to_include.pluck(:pulp_id)
140
311
 
141
- package_environment_hrefs_to_include = filter_package_environments_by_pulp_hrefs(
142
- repo_service.packageenvironments(options).results, package_groups_to_include.pluck(:pulp_id))
143
- content_unit_hrefs += package_environment_hrefs_to_include
144
-
145
312
  metadata_file_hrefs_to_include = filter_metadatafiles_by_pulp_hrefs(
146
313
  repo_service.metadatafiles(options).results, content_unit_hrefs)
147
314
  content_unit_hrefs += metadata_file_hrefs_to_include
@@ -150,11 +317,6 @@ module Katello
150
317
  repo_service.distributiontrees(options).results, content_unit_hrefs)
151
318
  content_unit_hrefs + distribution_tree_hrefs_to_include
152
319
  end
153
-
154
- def regenerate_applicability
155
- # TODO
156
- fail NotImplementedError
157
- end
158
320
  end
159
321
  end
160
322
  end
@@ -0,0 +1,100 @@
1
+ module Katello
2
+ module Pulp3
3
+ class Task
4
+ # A call report Looks like: {"task":"/pulp/api/v3/tasks/5/"}
5
+ # {
6
+ # "pulp_href":"/pulp/api/v3/tasks/4/",
7
+ # "pulp_created":"2019-02-21T19:50:40.476767Z",
8
+ # "job_id":"d0359658-d926-47a2-b430-1b2092b3bd86",
9
+ # "state":"completed",
10
+ # "name":"pulp_file.app.tasks.publishing.publish",
11
+ # "started_at":"2019-02-21T19:50:40.556002Z",
12
+ # "finished_at":"2019-02-21T19:50:40.618397Z",
13
+ # "non_fatal_errors":[
14
+ #
15
+ # ],
16
+ # "error":null,
17
+ # "worker":"/pulp/api/v3/workers/1/",
18
+ # "parent":null,
19
+ # "spawned_tasks":[
20
+ #
21
+ # ],
22
+ # "progress_reports":[
23
+ #
24
+ # ],
25
+ # "created_resources":[
26
+ # "/pulp/api/v3/publications/1/"
27
+ # ]
28
+ # }
29
+
30
+ WAITING = 'waiting'.freeze
31
+ SKIPPED = 'skipped'.freeze
32
+ RUNNING = 'running'.freeze
33
+ COMPLETED = 'completed'.freeze
34
+ FAILED = 'failed'.freeze
35
+ CANCELED = 'canceled'.freeze
36
+
37
+ FINISHED_STATES = [COMPLETED, FAILED, CANCELED, SKIPPED].freeze
38
+
39
+ #needed for serialization in dynflow
40
+
41
+ delegate :[], :key?, :dig, :to_hash, :to => :task_data
42
+
43
+ def initialize(smart_proxy, data)
44
+ @smart_proxy = smart_proxy
45
+ if (href = data['task'])
46
+ @href = href
47
+ else
48
+ @pulp_data = data.with_indifferent_access
49
+ @href = @pulp_data['pulp_href']
50
+ Rails.logger.error("Got empty pulp_href on #{@pulp_data}") if @href.nil?
51
+ end
52
+ end
53
+
54
+ def task_data(force_refresh = false)
55
+ @pulp_data = nil if force_refresh
56
+ @pulp_data ||= tasks_api.read(@href).as_json.with_indifferent_access
57
+ end
58
+
59
+ def tasks_api
60
+ ::Katello::Pulp3::Api::Core.new(@smart_proxy).tasks_api
61
+ end
62
+
63
+ def task_group_href
64
+ task_data[:task_group]
65
+ end
66
+
67
+ def done?
68
+ task_data[:finish_time] || FINISHED_STATES.include?(task_data[:state])
69
+ end
70
+
71
+ def poll
72
+ task_data(true)
73
+ self
74
+ end
75
+
76
+ def started?
77
+ task_data[:start_time]
78
+ end
79
+
80
+ def error
81
+ if task_data[:state] == CANCELED
82
+ self.new(_("Task canceled"))
83
+ elsif task_data[:state] == FAILED
84
+ if task_data[:error][:description].blank?
85
+ _("Pulp task error")
86
+ else
87
+ task_data[:error][:description]
88
+ end
89
+ end
90
+ end
91
+
92
+ def cancel
93
+ data = PulpcoreClient::Task.new(state: 'canceled')
94
+ tasks_api.tasks_cancel(pulp_task['pulp_href'], data)
95
+ #the main task may have completed, so cancel spawned tasks too
96
+ task_data['spawned_tasks']&.each { |spawned| tasks_api.tasks_cancel(spawned['pulp_href'], data) }
97
+ end
98
+ end
99
+ end
100
+ end