katello 3.16.0.rc1.1 → 3.16.0.rc4

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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/v2/api_controller.rb +8 -4
  3. data/app/controllers/katello/api/v2/subscriptions_controller.rb +1 -1
  4. data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +13 -1
  5. data/app/controllers/katello/concerns/hosts_controller_extensions.rb +11 -0
  6. data/app/controllers/katello/remote_execution_controller.rb +1 -1
  7. data/app/lib/actions/katello/applicability/hosts/{generate.rb → bulk_generate.rb} +11 -2
  8. data/app/lib/actions/katello/applicability/repository/regenerate.rb +7 -2
  9. data/app/lib/actions/katello/host/generate_applicability.rb +7 -2
  10. data/app/lib/actions/katello/host/upload_profiles.rb +20 -11
  11. data/app/lib/actions/katello/repository/sync.rb +1 -2
  12. data/app/lib/actions/katello/repository/update.rb +12 -1
  13. data/app/lib/actions/katello/repository/update_cv_repo_cert_guard.rb +17 -0
  14. data/app/lib/actions/pulp3/ContentGuard/refresh.rb +19 -0
  15. data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +6 -8
  16. data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +1 -1
  17. data/app/lib/actions/pulp3/repository/copy_content.rb +1 -0
  18. data/app/lib/actions/pulp3/repository/refresh_distribution.rb +1 -0
  19. data/app/lib/actions/pulp3/repository/save_distribution_references.rb +3 -1
  20. data/app/lib/actions/pulp3/repository/save_version.rb +3 -1
  21. data/app/lib/actions/pulp3/repository/update_cv_repository_cert_guard.rb +15 -0
  22. data/app/lib/katello/concerns/base_template_scope_extensions.rb +5 -1
  23. data/app/lib/katello/errors.rb +25 -0
  24. data/app/lib/katello/logging.rb +14 -0
  25. data/app/lib/katello/resources/candlepin.rb +1 -1
  26. data/app/lib/katello/resources/candlepin/upstream_consumer.rb +6 -0
  27. data/app/lib/katello/util/errata.rb +13 -0
  28. data/app/lib/katello/util/pulpcore_content_filters.rb +32 -0
  29. data/app/models/katello/concerns/host_managed_extensions.rb +7 -0
  30. data/app/models/katello/concerns/http_proxy_extensions.rb +30 -7
  31. data/app/models/katello/concerns/organization_extensions.rb +14 -0
  32. data/app/models/katello/concerns/pulp_database_unit.rb +2 -2
  33. data/app/models/katello/content_view_erratum_filter.rb +29 -0
  34. data/app/models/katello/content_view_package_filter.rb +16 -1
  35. data/app/models/katello/content_view_package_group_filter.rb +7 -0
  36. data/app/models/katello/events/generate_host_applicability.rb +6 -5
  37. data/app/models/katello/glue/candlepin/candlepin_object.rb +9 -5
  38. data/app/models/katello/glue/candlepin/pool.rb +8 -3
  39. data/app/models/katello/glue/provider.rb +11 -4
  40. data/app/models/katello/host/content_facet.rb +1 -1
  41. data/app/models/katello/host_queue_element.rb +4 -0
  42. data/app/models/katello/package_group.rb +2 -1
  43. data/app/models/katello/pool.rb +1 -1
  44. data/app/models/katello/pulp3/content_guard.rb +14 -0
  45. data/app/models/katello/rhsm_fact_parser.rb +4 -0
  46. data/app/models/katello/root_repository.rb +4 -1
  47. data/app/models/setting/content.rb +3 -1
  48. data/app/services/katello/applicable_host_queue.rb +21 -0
  49. data/app/services/katello/candlepin/message_handler.rb +2 -3
  50. data/app/services/katello/pulp/pulp_content_unit.rb +4 -0
  51. data/app/services/katello/pulp3/api/content_guard.rb +45 -0
  52. data/app/services/katello/pulp3/api/yum.rb +24 -0
  53. data/app/services/katello/pulp3/erratum.rb +4 -0
  54. data/app/services/katello/pulp3/pulp_content_unit.rb +4 -0
  55. data/app/services/katello/pulp3/repository.rb +29 -6
  56. data/app/services/katello/pulp3/repository/yum.rb +98 -3
  57. data/app/services/katello/pulp3/rpm.rb +3 -2
  58. data/app/services/katello/ui_notifications/subscriptions/manifest_expired_warning.rb +20 -8
  59. data/app/services/katello/upstream_connection_checker.rb +48 -0
  60. data/app/views/katello/api/v2/srpms/backend.json.rabl +11 -0
  61. data/app/views/katello/api/v2/srpms/base.json.rabl +5 -0
  62. data/app/views/katello/api/v2/srpms/compare.json.rabl +10 -0
  63. data/app/views/katello/api/v2/srpms/index.json.rabl +1 -1
  64. data/app/views/katello/api/v2/srpms/show.json.rabl +3 -3
  65. data/config/routes/api/v2.rb +2 -0
  66. data/db/migrate/20200407171926_create_content_guard.rb +10 -0
  67. data/db/migrate/20200511204005_create_katello_host_queue_elements.rb +12 -0
  68. data/db/migrate/20200526200422_encrypt_root_repository_upstream_password.rb +47 -0
  69. data/db/seeds.d/109-katello-notification-blueprints.rb +1 -1
  70. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-repository-sets.html +1 -1
  71. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-traces.html +1 -1
  72. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +1 -1
  73. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/content-view-version.factory.js +2 -2
  74. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +367 -450
  75. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/de.po +4046 -2509
  76. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/es.po +4277 -2503
  77. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/fr.po +4372 -2591
  78. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/it.po +4013 -2500
  79. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ja.po +4127 -2630
  80. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ko.po +4024 -2530
  81. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/pt_BR.po +4492 -2766
  82. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/ru.po +4293 -2667
  83. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_CN.po +4072 -2460
  84. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/locale/zh_TW.po +4004 -2442
  85. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/translations.js +10 -10
  86. data/lib/katello/permission_creator.rb +1 -1
  87. data/lib/katello/version.rb +1 -1
  88. data/locale/action_names.rb +51 -43
  89. data/locale/bn/katello.po +4015 -2558
  90. data/locale/cs/katello.po +3756 -2221
  91. data/locale/de/katello.po +4303 -3044
  92. data/locale/en/katello.po +3137 -1558
  93. data/locale/es/katello.po +4280 -3012
  94. data/locale/fr/katello.po +4302 -3080
  95. data/locale/gu/katello.po +4034 -2584
  96. data/locale/hi/katello.po +4034 -2575
  97. data/locale/it/katello.po +4291 -3040
  98. data/locale/ja/katello.po +4345 -2863
  99. data/locale/katello.pot +2631 -1460
  100. data/locale/kn/katello.po +4033 -2585
  101. data/locale/ko/katello.po +4320 -2815
  102. data/locale/mr/katello.po +3971 -2506
  103. data/locale/or/katello.po +4018 -2559
  104. data/locale/pa/katello.po +3985 -2514
  105. data/locale/pt/katello.po +3358 -1810
  106. data/locale/pt_BR/katello.po +4252 -2959
  107. data/locale/ru/katello.po +4308 -2902
  108. data/locale/ta/katello.po +4012 -2562
  109. data/locale/te/katello.po +4046 -2585
  110. data/locale/zh_CN/katello.po +4344 -2803
  111. data/locale/zh_TW/katello.po +4470 -2957
  112. data/package.json +3 -3
  113. data/webpack/components/Content/ContentTable.js +2 -0
  114. data/webpack/components/Content/Details/ContentDetails.js +3 -0
  115. data/webpack/global_test_setup.js +3 -0
  116. data/webpack/scenes/AnsibleCollections/Details/AnsibleCollectionDetails.js +3 -0
  117. data/webpack/scenes/ModuleStreams/Details/ModuleStreamDetails.js +3 -0
  118. data/webpack/scenes/RedHatRepositories/RedHatRepositoriesPage.js +2 -0
  119. data/webpack/scenes/RedHatRepositories/components/EnabledRepository/EnabledRepository.js +2 -0
  120. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js +2 -0
  121. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailAssociations.js +2 -0
  122. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailProductContent.js +2 -0
  123. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailProducts.js +2 -0
  124. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +2 -0
  125. data/webpack/scenes/Subscriptions/SubscriptionActions.js +19 -21
  126. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +3 -1
  127. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +15 -1
  128. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +66 -9
  129. data/webpack/scenes/Subscriptions/SubscriptionsSelectors.js +11 -0
  130. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js +15 -1
  131. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/{UpstreamSubscriptionsContstants.js → UpstreamSubscriptionsConstants.js} +3 -0
  132. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +2 -0
  133. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js +1 -1
  134. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js +1 -1
  135. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js +10 -34
  136. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +17 -7
  137. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsActions.test.js.snap +2 -4
  138. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +6 -4
  139. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsReducer.test.js.snap +26 -25
  140. data/webpack/scenes/Subscriptions/__tests__/subscriptions.fixtures.js +0 -58
  141. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTable.js +10 -4
  142. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.test.js +1 -0
  143. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +1 -68
  144. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Dialogs/UpdateDialog.js +1 -1
  145. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Dialogs/index.js +4 -4
  146. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Table.js +12 -10
  147. data/webpack/scenes/Subscriptions/index.js +11 -4
  148. data/webpack/scenes/Tasks/TaskActions.js +2 -1
  149. data/webpack/test-utils/nockWrapper.js +1 -1
  150. metadata +54 -24
@@ -61,6 +61,10 @@ module Katello
61
61
  os_attributes[:release_name] = release_name
62
62
  end
63
63
 
64
+ if facts['distribution.name'] == 'Red Hat Enterprise Linux Workstation'
65
+ os_attributes[:name] = os_name + '_Workstation'
66
+ end
67
+
64
68
  ::Operatingsystem.find_by(os_attributes) || ::Operatingsystem.create!(os_attributes)
65
69
  end
66
70
  end
@@ -5,6 +5,9 @@ module Katello
5
5
  serialize :docker_tags_whitelist
6
6
 
7
7
  include Ext::LabelFromName
8
+ include Encryptable
9
+
10
+ encrypts :upstream_password
8
11
 
9
12
  IGNORABLE_CONTENT_UNIT_TYPES = %w(rpm drpm srpm distribution erratum).freeze
10
13
  CHECKSUM_TYPES = %w(sha1 sha256).freeze
@@ -97,7 +100,7 @@ module Katello
97
100
  scope :with_no_proxy, -> { where(:http_proxy_policy => RootRepository::NO_DEFAULT_HTTP_PROXY) }
98
101
  scope :with_selected_proxy, ->(http_proxy_id) {
99
102
  where(:http_proxy_policy => RootRepository::USE_SELECTED_HTTP_PROXY).
100
- where("http_proxy_id = ?", http_proxy_id)
103
+ where(:http_proxy_id => http_proxy_id)
101
104
  }
102
105
  delegate :redhat?, :provider, :organization, to: :product
103
106
 
@@ -145,7 +145,9 @@ class Setting::Content < Setting
145
145
  "as long as the registering DMI UUID is not used by another host."),
146
146
  true, N_('Host Profile Assume')),
147
147
  self.set('host_tasks_workers_pool_size', N_("Amount of workers in the pool to handle the execution of host-related tasks. When set to 0, the default queue will be used instead. Restart of the dynflowd/foreman-tasks service is required."),
148
- 5, N_('Host Tasks Workers Pool Size'))
148
+ 5, N_('Host Tasks Workers Pool Size')),
149
+ self.set('applicability_batch_size', N_("Number of host applicability calculations to process per task."),
150
+ 50, N_('Applicability Batch Size'))
149
151
  ]
150
152
  end
151
153
 
@@ -0,0 +1,21 @@
1
+ module Katello
2
+ class ApplicableHostQueue
3
+ def self.batch_size
4
+ ::Setting::Content.find_by(name: "applicability_batch_size").value
5
+ end
6
+
7
+ def self.queue_depth
8
+ ::Katello::HostQueueElement.all.size
9
+ end
10
+
11
+ def self.push_host(host_id)
12
+ HostQueueElement.create!({ host_id: host_id })
13
+ end
14
+
15
+ def self.pop_hosts(amount = self.batch_size)
16
+ queue = HostQueueElement.group(:host_id).select("MIN(created_at) as created_at, host_id").limit(amount)
17
+ HostQueueElement.where(host_id: queue.map(&:host_id)).delete_all
18
+ queue
19
+ end
20
+ end
21
+ end
@@ -81,9 +81,8 @@ module Katello
81
81
  end
82
82
 
83
83
  def delete_pool
84
- if pool
85
- Rails.logger.info "deleting pool #{pool.id} from Katello"
86
- pool.destroy!
84
+ if Katello::Pool.where(:cp_id => pool_id).destroy_all.any?
85
+ Rails.logger.info "deleted pool #{pool_id} from Katello"
87
86
  end
88
87
  end
89
88
  end
@@ -34,6 +34,10 @@ module Katello
34
34
  nil
35
35
  end
36
36
 
37
+ def self.supports_id_fetch?
38
+ true
39
+ end
40
+
37
41
  def self.content_type
38
42
  self::CONTENT_TYPE
39
43
  end
@@ -0,0 +1,45 @@
1
+ require 'pulp_certguard_client'
2
+
3
+ module Katello
4
+ module Pulp3
5
+ module Api
6
+ class ContentGuard < Core
7
+ def self.client_module
8
+ PulpCertguardClient
9
+ end
10
+
11
+ def self.api_exception_class
12
+ PulpCertguardClient::ApiError
13
+ end
14
+
15
+ def api_client
16
+ PulpCertguardClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpCertguardClient::Configuration))
17
+ end
18
+
19
+ def rhsm_api_client
20
+ PulpCertguardClient::ContentguardsRhsmApi.new(api_client)
21
+ end
22
+
23
+ def create(name = "RHSMCertGuard", ca_certificate = Cert::Certs.ca_cert)
24
+ data = PulpCertguardClient::CertguardRHSMCertGuard.new(name: name, ca_certificate: ca_certificate)
25
+ rhsm_api_client.create(data)
26
+ rescue self.class.api_exception_class => e
27
+ raise e unless list&.results&.first
28
+ end
29
+
30
+ def list(options = {})
31
+ rhsm_api_client.list options
32
+ end
33
+
34
+ def partial_update(href, ca_certificate = Cert::Certs.ca_cert)
35
+ data = PulpCertguardClient::CertguardRHSMCertGuard.new(ca_certificate: ca_certificate)
36
+ rhsm_api_client.partial_update(href, data)
37
+ end
38
+
39
+ def delete(href)
40
+ rhsm_api_client.delete(href) if href
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -28,6 +28,10 @@ module Katello
28
28
  PulpRpmClient::RpmRepositorySyncURL
29
29
  end
30
30
 
31
+ def self.rpm_package_group_class
32
+ PulpRpmClient::RpmPackageGroup
33
+ end
34
+
31
35
  def api_client
32
36
  PulpRpmClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpRpmClient::Configuration))
33
37
  end
@@ -51,6 +55,26 @@ module Katello
51
55
  def distributions_api
52
56
  PulpRpmClient::DistributionsRpmApi.new(api_client)
53
57
  end
58
+
59
+ def copy_api
60
+ PulpRpmClient::RpmCopyApi.new(api_client)
61
+ end
62
+
63
+ def content_package_groups_api
64
+ PulpRpmClient::ContentPackagegroupsApi.new(api_client)
65
+ end
66
+
67
+ def content_package_environments_api
68
+ PulpRpmClient::ContentPackageenvironmentsApi.new(api_client)
69
+ end
70
+
71
+ def content_repo_metadata_files_api
72
+ PulpRpmClient::ContentRepoMetadataFilesApi.new(api_client)
73
+ end
74
+
75
+ def content_distribution_trees_api
76
+ PulpRpmClient::ContentDistributionTreesApi.new(api_client)
77
+ end
54
78
  end
55
79
  end
56
80
  end
@@ -15,6 +15,10 @@ module Katello
15
15
  "pulp_href"
16
16
  end
17
17
 
18
+ def self.supports_id_fetch?
19
+ false
20
+ end
21
+
18
22
  def self.ids_for_repository(repo_id)
19
23
  repo = Katello::Pulp3::Repository::Yum.new(Katello::Repository.find(repo_id), SmartProxy.pulp_master)
20
24
  repo_content_list = repo.content_list
@@ -19,6 +19,10 @@ module Katello
19
19
  nil
20
20
  end
21
21
 
22
+ def self.supports_id_fetch?
23
+ true
24
+ end
25
+
22
26
  def update_model
23
27
  fail NotImplementedError
24
28
  end
@@ -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
@@ -143,7 +147,7 @@ module Katello
143
147
 
144
148
  def distribution_needs_update?
145
149
  if distribution_reference
146
- expected = distribution_options(relative_path).except(:name).compact
150
+ expected = secure_distribution_options(relative_path).except(:name).compact
147
151
  actual = get_distribution.to_hash
148
152
  expected != actual.slice(*expected.keys)
149
153
  elsif repo.environment
@@ -180,13 +184,20 @@ module Katello
180
184
  api.repositories_api.list(options).results
181
185
  end
182
186
 
187
+ def read
188
+ api.repositories_api.read(repository_reference.try(:repository_href))
189
+ end
190
+
183
191
  def delete(href = repository_reference.try(:repository_href))
184
192
  repository_reference.try(:destroy)
185
193
  ignore_404_exception { api.repositories_api.delete(href) } if href
186
194
  end
187
195
 
188
196
  def sync
189
- repository_sync_url_data = api.class.repository_sync_url_class.new(remote: repo.remote_href, mirror: repo.root.mirror_on_sync)
197
+ sync_url_params = {remote: repo.remote_href, mirror: repo.root.mirror_on_sync}
198
+ skip_type_param = skip_types
199
+ sync_url_params[:skip_types] = skip_type_param if skip_type_param
200
+ repository_sync_url_data = api.class.repository_sync_url_class.new(sync_url_params)
190
201
  [api.repositories_api.sync(repository_reference.repository_href, repository_sync_url_data)]
191
202
  end
192
203
 
@@ -209,7 +220,7 @@ module Katello
209
220
  end
210
221
 
211
222
  def create_distribution(path)
212
- distribution_data = api.class.distribution_class.new(distribution_options(path))
223
+ distribution_data = api.class.distribution_class.new(secure_distribution_options(path))
213
224
  api.distributions_api.create(distribution_data)
214
225
  end
215
226
 
@@ -219,7 +230,8 @@ module Katello
219
230
 
220
231
  def update_distribution
221
232
  if distribution_reference
222
- options = distribution_options(relative_path).except(:name)
233
+ options = secure_distribution_options(relative_path).except(:name)
234
+ distribution_reference.update(:content_guard_href => options[:content_guard])
223
235
  api.distributions_api.partial_update(distribution_reference.href, options)
224
236
  end
225
237
  end
@@ -246,9 +258,10 @@ module Katello
246
258
 
247
259
  def save_distribution_references(hrefs)
248
260
  hrefs.each do |href|
249
- path = api.get_distribution(href)&.base_path
261
+ pulp3_distribution_data = api.get_distribution(href)
262
+ path, content_guard_href = pulp3_distribution_data&.base_path, pulp3_distribution_data&.content_guard
250
263
  unless distribution_reference
251
- DistributionReference.create!(path: path, href: href, repository_id: repo.id)
264
+ DistributionReference.create!(path: path, href: href, repository_id: repo.id, content_guard_href: content_guard_href)
252
265
  end
253
266
  end
254
267
  end
@@ -284,6 +297,16 @@ module Katello
284
297
  remote_options.merge!(ssl_remote_options)
285
298
  end
286
299
 
300
+ def secure_distribution_options(path)
301
+ secured_distribution_options = {}
302
+ if root.unprotected
303
+ secured_distribution_options[:content_guard] = nil
304
+ else
305
+ secured_distribution_options[:content_guard] = ::Katello::Pulp3::ContentGuard.first.pulp_href
306
+ end
307
+ secured_distribution_options.merge!(distribution_options(path))
308
+ end
309
+
287
310
  def ssl_remote_options
288
311
  if root.redhat? && Katello::Resources::CDN::CdnResource.redhat_cdn?(root.url)
289
312
  {
@@ -4,6 +4,9 @@ module Katello
4
4
  module Pulp3
5
5
  class Repository
6
6
  class Yum < ::Katello::Pulp3::Repository
7
+ include Katello::Util::Errata
8
+ include Katello::Util::PulpcoreContentFilters
9
+
7
10
  def remote_options
8
11
  if root.url.blank?
9
12
  common_remote_options.merge(url: nil, policy: root.download_policy)
@@ -12,6 +15,14 @@ module Katello
12
15
  end
13
16
  end
14
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
+
15
26
  def distribution_options(path)
16
27
  {
17
28
  base_path: path,
@@ -59,9 +70,93 @@ module Katello
59
70
  "/pulp/repos/#{repo.relative_path}/".sub('//', '/')
60
71
  end
61
72
 
62
- def copy_content_for_source
63
- # TODO
64
- fail NotImplementedError
73
+ def copy_units(source_repository_version_href, content_unit_hrefs, dependency_solving)
74
+ tasks = []
75
+
76
+ if content_unit_hrefs.any?
77
+ data = PulpRpmClient::Copy.new
78
+ data.config = [
79
+ source_repo_version: source_repository_version_href,
80
+ dest_repo: repository_reference.repository_href,
81
+ dest_base_version: 0,
82
+ content: content_unit_hrefs.sort
83
+ ]
84
+ data.dependency_solving = dependency_solving
85
+ tasks << api.copy_api.copy_content(data)
86
+ else
87
+ data = PulpRpmClient::RepositoryAddRemoveContent.new(
88
+ remove_content_units: ['*'])
89
+ tasks << api.repositories_api.modify(repository_reference.repository_href, data)
90
+ end
91
+
92
+ tasks
93
+ end
94
+
95
+ def packageenvironments(options = {})
96
+ api.content_package_environments_api.list(options)
97
+ end
98
+
99
+ def metadatafiles(options = {})
100
+ api.content_repo_metadata_files_api.list(options)
101
+ end
102
+
103
+ def distributiontrees(options = {})
104
+ api.content_distribution_trees_api.list(options)
105
+ end
106
+
107
+ def copy_content_for_source(source_repository, options = {})
108
+ filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
109
+ filter_class.where(:id => options[:filter_ids])
110
+ end
111
+
112
+ filters.flatten!.compact!
113
+
114
+ whitelist_ids = []
115
+ blacklist_ids = []
116
+ filters.each do |filter|
117
+ if filter.inclusion
118
+ whitelist_ids += filter.content_unit_pulp_ids(source_repository)
119
+ else
120
+ blacklist_ids += filter.content_unit_pulp_ids(source_repository)
121
+ end
122
+ end
123
+
124
+ if whitelist_ids.empty? && filters.select { |filter| filter.inclusion }.empty?
125
+ whitelist_ids = source_repository.rpms.where(:modular => false).pluck(:pulp_id).sort
126
+ end
127
+
128
+ content_unit_hrefs = whitelist_ids - blacklist_ids
129
+
130
+ if content_unit_hrefs.any?
131
+ content_unit_hrefs += additional_content_hrefs(source_repository, content_unit_hrefs)
132
+ end
133
+ content_unit_hrefs += source_repository.srpms.pluck(:pulp_id)
134
+
135
+ dependency_solving = options[:solve_dependencies] || false
136
+ copy_units(source_repository.version_href, content_unit_hrefs.uniq, dependency_solving)
137
+ end
138
+
139
+ def additional_content_hrefs(source_repository, content_unit_hrefs)
140
+ repo_service = source_repository.backend_service(SmartProxy.pulp_master)
141
+ options = { :repository_version => source_repository.version_href }
142
+
143
+ errata_to_include = filter_errata_by_pulp_href(source_repository.errata, content_unit_hrefs)
144
+ content_unit_hrefs += errata_to_include.collect { |erratum| erratum.repository_errata.pluck(:erratum_pulp3_href) }.flatten
145
+
146
+ package_groups_to_include = filter_package_groups_by_pulp_href(source_repository.package_groups, content_unit_hrefs)
147
+ content_unit_hrefs += package_groups_to_include.pluck(:pulp_id)
148
+
149
+ package_environment_hrefs_to_include = filter_package_environments_by_pulp_hrefs(
150
+ repo_service.packageenvironments(options).results, package_groups_to_include.pluck(:pulp_id))
151
+ content_unit_hrefs += package_environment_hrefs_to_include
152
+
153
+ metadata_file_hrefs_to_include = filter_metadatafiles_by_pulp_hrefs(
154
+ repo_service.metadatafiles(options).results, content_unit_hrefs)
155
+ content_unit_hrefs += metadata_file_hrefs_to_include
156
+
157
+ distribution_tree_hrefs_to_include = filter_distribution_trees_by_pulp_hrefs(
158
+ repo_service.distributiontrees(options).results, content_unit_hrefs)
159
+ content_unit_hrefs + distribution_tree_hrefs_to_include
65
160
  end
66
161
 
67
162
  def regenerate_applicability
@@ -119,11 +119,12 @@ module Katello
119
119
  each { |field| custom_json[field] = backend_data[field] }
120
120
  custom_json['release_sortable'] = Util::Package.sortable_version(backend_data['release'])
121
121
  custom_json['version_sortable'] = Util::Package.sortable_version(backend_data['version'])
122
- custom_json['nvra'] = model.build_nvra
123
122
  custom_json['filename'] = backend_data['location_href']
124
123
  custom_json['checksum'] = backend_data['pkgId']
125
124
  custom_json['sourcerpm'] = backend_data['rpm_sourcerpm']
126
- model.update!(custom_json)
125
+ model.assign_attributes(custom_json)
126
+ model.nvra = model.build_nvra
127
+ model.save!
127
128
  end
128
129
  end
129
130
  end
@@ -7,14 +7,11 @@ module Katello
7
7
  CDN_PATH = '/content/dist/rhel/server/7/listing'.freeze
8
8
 
9
9
  def self.deliver!(orgs = ::Organization.all)
10
+ return if Setting[:content_disconnected]
11
+
10
12
  orgs.each do |org|
11
- next unless redhat_connected?(org)
12
- content = org.contents.find_by(:label => CONTENT_LABEL)
13
- product = content&.products&.find { |p| p.key }
14
- if content && product && product.pools.any?
15
- if got_403? { product.cdn_resource.get(CDN_PATH) }
16
- new(org).deliver!
17
- end
13
+ if cdn_inaccessible?(org) || upstream_inaccessible?(org)
14
+ new(org).deliver!
18
15
  end
19
16
  end
20
17
  rescue StandardError => e
@@ -47,6 +44,14 @@ module Katello
47
44
  @blueprint ||= NotificationBlueprint.find_by(name: 'manifest_expired_warning')
48
45
  end
49
46
 
47
+ def self.cdn_inaccessible?(org)
48
+ content = org.contents.find_by(:label => CONTENT_LABEL)
49
+ product = content&.products&.find { |p| p.key }
50
+ if content && product && product.pools.any?
51
+ return got_403? { product.cdn_resource.get(CDN_PATH) }
52
+ end
53
+ end
54
+
50
55
  def self.got_403?
51
56
  yield
52
57
  false
@@ -54,8 +59,15 @@ module Katello
54
59
  true
55
60
  end
56
61
 
62
+ def self.upstream_inaccessible?(org)
63
+ return unless org.manifest_imported?
64
+
65
+ checker = Katello::UpstreamConnectionChecker.new(org)
66
+ !checker.can_connect?
67
+ end
68
+
57
69
  def self.redhat_connected?(org)
58
- org.redhat_provider.repository_url.include?(CDN_HOSTNAME) && !Setting[:content_disconnected]
70
+ org.redhat_provider.repository_url.include?(CDN_HOSTNAME)
59
71
  end
60
72
  end
61
73
  end