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
@@ -0,0 +1,14 @@
1
+ module Katello
2
+ module Logging
3
+ def self.time(message, data: {}, logger: Rails.logger, level: :info)
4
+ start = Time.now
5
+
6
+ yield
7
+
8
+ data[:duration] = ((Time.now - start) * 1000).truncate(2)
9
+ data_string = data.map { |k, v| "#{k}=#{v}" }.join(' ')
10
+
11
+ logger.send(level, "#{message} #{data_string}")
12
+ end
13
+ end
14
+ end
@@ -142,7 +142,7 @@ module Katello
142
142
  def upstream_consumer
143
143
  fail _("Current organization not set.") unless Organization.current
144
144
  upstream_consumer = Organization.current.owner_details['upstreamConsumer']
145
- fail _("Current organization has no manifest imported.") unless upstream_consumer
145
+ fail Katello::Errors::NoManifestImported unless upstream_consumer
146
146
 
147
147
  upstream_consumer
148
148
  end
@@ -9,6 +9,12 @@ module Katello
9
9
  super(id)
10
10
  end
11
11
 
12
+ def ping
13
+ resource.head
14
+ rescue RestClient::Unauthorized, RestClient::Gone
15
+ raise ::Katello::Errors::UpstreamConsumerGone
16
+ end
17
+
12
18
  # Overrides the HttpResource get method to check if the upstream
13
19
  # consumer exists.
14
20
  def get(params)
@@ -45,6 +45,19 @@ module Katello
45
45
  return errata_list
46
46
  end
47
47
  end
48
+
49
+ def filter_errata_by_pulp_href(errata, package_pulp_hrefs)
50
+ return [] if package_pulp_hrefs.empty?
51
+ rpms = Katello::Rpm.where(:pulp_id => package_pulp_hrefs)
52
+ rpm_filenames = rpms.map { |rpm| File.basename(rpm.filename) }
53
+ matching_errata = []
54
+ errata.each do |erratum|
55
+ if erratum.packages.any? && (erratum.packages.pluck(:filename) - rpm_filenames).empty?
56
+ matching_errata << erratum
57
+ end
58
+ end
59
+ matching_errata
60
+ end
48
61
  end
49
62
  end
50
63
  end
@@ -0,0 +1,32 @@
1
+ module Katello
2
+ module Util
3
+ module PulpcoreContentFilters
4
+ def filter_distribution_trees_by_pulp_hrefs(distributiontree_results, _content_pulp_hrefs)
5
+ distributiontree_results.collect { |result| result.pulp_href }.flatten.uniq
6
+ end
7
+
8
+ def filter_package_groups_by_pulp_href(package_groups, package_pulp_hrefs)
9
+ rpms = Katello::Rpm.where(:pulp_id => package_pulp_hrefs)
10
+ package_groups.reject do |package_group|
11
+ (package_group.package_names & rpms.pluck(:name)).empty?
12
+ end
13
+ end
14
+
15
+ def filter_package_environments_by_pulp_hrefs(packageenvironment_results, package_pulp_hrefs)
16
+ matching_package_env_groups = []
17
+
18
+ packageenvironment_results.each do |result|
19
+ if (result.packagegroups & package_pulp_hrefs).any?
20
+ matching_package_env_groups << result.pulp_href
21
+ end
22
+ end
23
+
24
+ matching_package_env_groups.flatten.uniq
25
+ end
26
+
27
+ def filter_metadatafiles_by_pulp_hrefs(metadatafiles_results, _package_pulp_hrefs)
28
+ metadatafiles_results.collect { |result| result.pulp_href }.flatten.uniq
29
+ end
30
+ end
31
+ end
32
+ end
@@ -50,6 +50,7 @@ module Katello
50
50
 
51
51
  before_save :correct_puppet_environment
52
52
  before_validation :correct_kickstart_repository
53
+ before_update :check_host_registration, :if => proc { organization_id_changed? }
53
54
 
54
55
  scope :with_pools_expiring_in_days, ->(days) { joins(:pools).merge(Katello::Pool.expiring_in_days(days)).distinct }
55
56
 
@@ -76,6 +77,12 @@ module Katello
76
77
  end
77
78
  end
78
79
 
80
+ def check_host_registration
81
+ if subscription_facet
82
+ fail ::Katello::Errors::HostRegisteredException
83
+ end
84
+ end
85
+
79
86
  def correct_kickstart_repository
80
87
  return unless content_facet
81
88
 
@@ -8,6 +8,7 @@ module Katello
8
8
  :inverse_of => :http_proxy, :dependent => :nullify
9
9
  after_update :update_default_proxy_setting
10
10
  after_commit :update_repository_proxy_details
11
+ before_destroy :remove_references_to_proxy
11
12
 
12
13
  def self.default_global_content_proxy
13
14
  if Setting[:content_default_http_proxy]
@@ -16,6 +17,34 @@ module Katello
16
17
  end
17
18
  end
18
19
 
20
+ def repositories_with_proxy(proxy_id)
21
+ root_repos = RootRepository.with_selected_proxy(proxy_id)
22
+
23
+ if self == HttpProxy.default_global_content_proxy
24
+ root_repos += RootRepository.with_global_proxy
25
+ end
26
+
27
+ root_repos
28
+ end
29
+
30
+ def remove_references_to_proxy
31
+ root_repos = repositories_with_proxy(nil).uniq.sort
32
+
33
+ setting = Setting.find_by(name: 'content_default_http_proxy')
34
+ if setting&.value && setting.value == self.name
35
+ setting.update_attribute(:value, '')
36
+ end
37
+
38
+ unless root_repos.empty?
39
+ ForemanTasks.async_task(
40
+ ::Actions::BulkAction,
41
+ ::Actions::Katello::Repository::Update,
42
+ root_repos,
43
+ http_proxy_policy: Katello::RootRepository::GLOBAL_DEFAULT_HTTP_PROXY,
44
+ http_proxy_id: nil)
45
+ end
46
+ end
47
+
19
48
  def update_default_proxy_setting
20
49
  changes = self.previous_changes
21
50
  if changes.key?(:name)
@@ -32,13 +61,7 @@ module Katello
32
61
  changes = self.previous_changes
33
62
  if changes.key?(:url) || changes.key?(:username) || changes.key?(:password)
34
63
 
35
- root_repos = RootRepository.with_selected_proxy(id)
36
-
37
- if self == HttpProxy.default_global_content_proxy
38
- root_repos += RootRepository.with_global_proxy
39
- end
40
-
41
- repos = root_repos.uniq.collect(&:library_instance)
64
+ repos = repositories_with_proxy(id).uniq.collect(&:library_instance)
42
65
 
43
66
  unless repos.empty?
44
67
  ForemanTasks.async_task(
@@ -82,6 +82,20 @@ module Katello
82
82
  self.providers.anonymous.first
83
83
  end
84
84
 
85
+ def manifest_imported?
86
+ owner_details['upstreamConsumer'].present?
87
+ end
88
+
89
+ def manifest_expired?
90
+ manifest_expiry = owner_details.dig(:upstreamConsumer, :idCert, :serial, :expiration)
91
+
92
+ if manifest_expiry
93
+ DateTime.parse(manifest_expiry) < DateTime.now
94
+ else
95
+ false
96
+ end
97
+ end
98
+
85
99
  def manifest_history
86
100
  imports.map { |i| OpenStruct.new(i) }
87
101
  end
@@ -44,7 +44,6 @@ module Katello
44
44
  end
45
45
 
46
46
  def backend_identifier_field
47
- nil
48
47
  end
49
48
 
50
49
  def content_unit_class
@@ -108,7 +107,8 @@ module Katello
108
107
  pulp_id_href_map = {}
109
108
  service_class = SmartProxy.pulp_master!.content_service(content_type)
110
109
  fetch_only_ids = !repository.content_view.default? &&
111
- !repository.repository_type.unique_content_per_repo
110
+ !repository.repository_type.unique_content_per_repo &&
111
+ service_class.supports_id_fetch?
112
112
 
113
113
  service_class.pulp_units_batch_for_repo(repository, fetch_identifiers: fetch_only_ids).each do |units|
114
114
  units.each do |unit|
@@ -26,8 +26,37 @@ module Katello
26
26
  end
27
27
  end
28
28
 
29
+ def content_unit_pulp_ids(repo)
30
+ if filter_by_id?
31
+ errata_ids = erratum_rules.map(&:errata_id)
32
+ errata_pulp_ids = errata_package_pulp_ids_from_errata_ids(repo, errata_ids)
33
+ else
34
+ clauses = []
35
+ clauses << errata_from
36
+ clauses << errata_to
37
+ clauses << types_clause
38
+ package_filenames = Erratum.list_filenames_by_clauses(repo, clauses.compact)
39
+ errata_pulp_ids = errata_package_pulp_ids_from_package_filenames(repo, package_filenames)
40
+ end
41
+ errata_pulp_ids
42
+ end
43
+
29
44
  private
30
45
 
46
+ def rpms_by_filename(repo, package_filenames)
47
+ query_params = package_filenames.map { |filename| "%#{filename}" }
48
+ repo.rpms.where("filename ILIKE ANY ( array[?] )", query_params)
49
+ end
50
+
51
+ def errata_package_pulp_ids_from_package_filenames(repo, package_filenames)
52
+ rpms_by_filename(repo, package_filenames).pluck(:pulp_id)
53
+ end
54
+
55
+ def errata_package_pulp_ids_from_errata_ids(repo, errata_ids)
56
+ package_filenames = Katello::ErratumPackage.joins(:erratum).where("#{Erratum.table_name}.errata_id" => errata_ids).pluck(:filename)
57
+ rpms_by_filename(repo, package_filenames).pluck(:pulp_id)
58
+ end
59
+
31
60
  def erratum_arel
32
61
  ::Katello::Erratum.arel_table
33
62
  end
@@ -7,7 +7,11 @@ module Katello
7
7
  validates_lengths_from_database
8
8
 
9
9
  # Returns a set of Pulp/MongoDB conditions to filter out packages in the
10
- # repo repository that match parameters
10
+ # repo repository that match parameters if the repository content type
11
+ # is managed by pulp2.
12
+ #
13
+ # Returns a set of pulpcore hrefs (pulp_ids) if the repository content
14
+ # type is managed by pulpcore.
11
15
  #
12
16
  # @param repo [Repository] a repository containing packages to filter
13
17
  # @return [Array] an array of hashes with MongoDB conditions
@@ -20,6 +24,7 @@ module Katello
20
24
  if self.original_packages
21
25
  package_filenames.concat(repo.packages_without_errata.map(&:filename))
22
26
  end
27
+
23
28
  ContentViewPackageFilter.generate_rpm_clauses(package_filenames)
24
29
  end
25
30
 
@@ -27,6 +32,16 @@ module Katello
27
32
  self[:original_packages] = value
28
33
  end
29
34
 
35
+ def content_unit_pulp_ids(repo)
36
+ package_filenames = []
37
+ self.package_rules.each do |rule|
38
+ package_filenames.concat(query_rpms(repo, rule))
39
+ end
40
+
41
+ rpms = Rpm.in_repositories(repo)
42
+ rpms.where(filename: package_filenames).where(:modular => false).pluck(:pulp_id).flatten.uniq
43
+ end
44
+
30
45
  def self.generate_rpm_clauses(package_filenames = [])
31
46
  { 'filename' => { "$in" => package_filenames } } unless package_filenames.empty?
32
47
  end
@@ -10,5 +10,12 @@ module Katello
10
10
  package_group_ids = package_group_rules.reject { |rule| rule.uuid.blank? }.flat_map.map(&:uuid)
11
11
  { "_id" => { "$in" => package_group_ids } } unless package_group_ids.empty?
12
12
  end
13
+
14
+ def content_unit_pulp_ids(repo)
15
+ package_group_hrefs = package_group_rules.reject { |rule| rule.uuid.blank? }.flat_map.map(&:uuid)
16
+ package_group_names = repo.package_groups.
17
+ where(:pulp_id => package_group_hrefs).collect { |package_group| package_group.package_names }.flatten.uniq
18
+ repo.rpms.where(:name => package_group_names).pluck(:pulp_id).compact
19
+ end
13
20
  end
14
21
  end
@@ -7,16 +7,17 @@ module Katello
7
7
  180
8
8
  end
9
9
 
10
- def initialize(host_id)
11
- @host = ::Host.find_by_id(host_id)
12
- Rails.logger.warn "Host not found for ID #{object_id}" if @host.nil?
10
+ def initialize(object_id)
13
11
  end
14
12
 
15
13
  def run
16
- return unless @host
14
+ return if ::Katello::ApplicableHostQueue.queue_depth == 0
17
15
 
18
16
  begin
19
- ForemanTasks.async_task(::Actions::Katello::Applicability::Host::Generate, host_id: @host.id)
17
+ while ::Katello::ApplicableHostQueue.queue_depth != 0
18
+ hosts = ::Katello::ApplicableHostQueue.pop_hosts
19
+ ForemanTasks.async_task(::Actions::Katello::Applicability::Hosts::BulkGenerate, host_ids: hosts.map(&:host_id))
20
+ end
20
21
  rescue => e
21
22
  self.retry = true if e.is_a?(ForemanTasks::Lock::LockConflict)
22
23
  raise e
@@ -36,11 +36,15 @@ module Katello
36
36
 
37
37
  objects = self.in_organization(org)
38
38
  objects.each do |item|
39
- if candlepin_ids.include?(item.cp_id)
40
- item.import_data
41
- item.import_managed_associations if import_managed_associations && item.respond_to?(:import_managed_associations)
42
- else
43
- item.destroy
39
+ exists_in_candlepin = candlepin_ids.include?(item.cp_id)
40
+
41
+ Katello::Logging.time("Imported #{self}", data: { cp_id: item.cp_id, destroyed: !exists_in_candlepin }) do
42
+ if exists_in_candlepin
43
+ item.import_data
44
+ item.import_managed_associations if import_managed_associations && item.respond_to?(:import_managed_associations)
45
+ else
46
+ item.destroy
47
+ end
44
48
  end
45
49
  end
46
50
  end
@@ -164,7 +164,7 @@ module Katello
164
164
  def import_hosts
165
165
  uuids = Resources::Candlepin::Pool.consumer_uuids(self.cp_id)
166
166
 
167
- sub_facet_ids_from_cp, host_ids_from_cp = Katello::Host::SubscriptionFacet.where(:uuid => uuids).pluck([:id, :host_id]).transpose
167
+ sub_facet_ids_from_cp, host_ids_from_cp = Katello::Host::SubscriptionFacet.where('uuid in (?)', uuids).pluck([:id, :host_id]).transpose
168
168
  sub_facet_ids_from_cp ||= []
169
169
  host_ids_from_cp ||= []
170
170
 
@@ -187,8 +187,13 @@ module Katello
187
187
  end
188
188
 
189
189
  def import_managed_associations
190
- import_hosts
191
- create_activation_key_associations
190
+ Katello::Logging.time("Imported host associations") do
191
+ import_hosts
192
+ end
193
+
194
+ Katello::Logging.time("Imported activation key associations") do
195
+ create_activation_key_associations
196
+ end
192
197
  end
193
198
 
194
199
  def hosts
@@ -132,11 +132,18 @@ module Katello
132
132
  cp_products = cp_products.select { |prod| Glue::Candlepin::Product.engineering_product_id?(prod['id']) }
133
133
 
134
134
  prod_content_importer = Katello::ProductContentImporter.new
135
- cp_products.each do |product_json|
136
- product = import_product(product_json)
137
- prod_content_importer.add_product_content(product, product_json['productContent']) if product.redhat?
135
+
136
+ Katello::Logging.time("Imported #{cp_products.size} products") do
137
+ cp_products.each do |product_json|
138
+ product = import_product(product_json)
139
+ prod_content_importer.add_product_content(product, product_json['productContent']) if product.redhat?
140
+ end
141
+ end
142
+
143
+ Katello::Logging.time("Imported product content") do
144
+ prod_content_importer.import
138
145
  end
139
- prod_content_importer.import
146
+
140
147
  self.index_subscriptions(self.organization)
141
148
  prod_content_importer
142
149
  end
@@ -82,10 +82,10 @@ module Katello
82
82
  def update_bound_repositories(repos)
83
83
  self.bound_repositories = repos
84
84
  self.save!
85
- self.propagate_yum_repos
86
85
  if SETTINGS[:katello][:katello_applicability]
87
86
  ::Katello::EventQueue.push_event(::Katello::Events::GenerateHostApplicability::EVENT_TYPE, self.host.id)
88
87
  else
88
+ self.propagate_yum_repos
89
89
  ForemanTasks.async_task(Actions::Katello::Host::GenerateApplicability, [self.host])
90
90
  end
91
91
  end
@@ -0,0 +1,4 @@
1
+ module Katello
2
+ class HostQueueElement < Katello::Model
3
+ end
4
+ end
@@ -25,7 +25,8 @@ module Katello
25
25
  end
26
26
 
27
27
  def package_names
28
- group = Pulp::PackageGroup.new(self.pulp_id)
28
+ service_class = SmartProxy.pulp_master!.content_service(CONTENT_TYPE)
29
+ group = service_class.new(self.pulp_id)
29
30
  group.default_package_names + group.conditional_package_names + group.optional_package_names + group.mandatory_package_names
30
31
  end
31
32
  end
@@ -9,7 +9,7 @@ module Katello
9
9
  has_many :pool_activation_keys, :class_name => "Katello::PoolActivationKey", :dependent => :destroy, :inverse_of => :pool
10
10
  has_many :activation_keys, :through => :pool_activation_keys, :class_name => "Katello::ActivationKey"
11
11
 
12
- has_many :subscription_facet_pools, :class_name => "Katello::SubscriptionFacetPool", :dependent => :destroy
12
+ has_many :subscription_facet_pools, :class_name => "Katello::SubscriptionFacetPool", :dependent => :delete_all
13
13
  has_many :subscription_facets, :through => :subscription_facet_pools
14
14
 
15
15
  belongs_to :organization, :class_name => 'Organization', :inverse_of => :pools
@@ -0,0 +1,14 @@
1
+ module Katello
2
+ module Pulp3
3
+ class ContentGuard < Katello::Model
4
+ def self.import(smart_proxy = SmartProxy.pulp_master!, force = false)
5
+ return unless (count == 0 || force)
6
+ content_guard_api = Katello::Pulp3::Api::ContentGuard.new(smart_proxy)
7
+ content_guard = content_guard_api.list&.results&.first
8
+ return unless content_guard
9
+ katello_content_guard = self.new(name: content_guard.name, pulp_href: content_guard.pulp_href)
10
+ katello_content_guard.save!
11
+ end
12
+ end
13
+ end
14
+ end