katello 3.14.1 → 3.15.0.rc1

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 (167) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +1 -1
  3. data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +3 -3
  4. data/app/controllers/katello/api/v2/repositories_controller.rb +1 -1
  5. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +1 -1
  6. data/app/lib/actions/katello/content_view/publish.rb +2 -0
  7. data/app/lib/actions/katello/content_view_version/incremental_update.rb +1 -0
  8. data/app/lib/actions/katello/host/reassign.rb +1 -2
  9. data/app/lib/actions/katello/host/update_content_view.rb +1 -1
  10. data/app/lib/actions/katello/host/update_release_version.rb +1 -1
  11. data/app/lib/actions/katello/organization/manifest_refresh.rb +1 -1
  12. data/app/lib/actions/katello/product/update_http_proxy.rb +1 -1
  13. data/app/lib/actions/katello/repository/clone_contents.rb +1 -1
  14. data/app/lib/actions/katello/repository/clone_to_environment.rb +2 -1
  15. data/app/lib/actions/katello/repository/create.rb +1 -1
  16. data/app/lib/actions/katello/repository/metadata_generate.rb +2 -8
  17. data/app/lib/actions/katello/repository/refresh_repository.rb +5 -1
  18. data/app/lib/actions/katello/repository/sync.rb +6 -1
  19. data/app/lib/actions/middleware/execute_if_contents_changed.rb +1 -1
  20. data/app/lib/actions/pulp/orchestration/repository/refresh_if_needed.rb +1 -1
  21. data/app/lib/actions/pulp/repository/clear.rb +1 -1
  22. data/app/lib/actions/pulp/repository/remove_units.rb +1 -1
  23. data/app/lib/actions/pulp3/abstract_async_task.rb +1 -2
  24. data/app/lib/actions/pulp3/capsule_content/generate_metadata.rb +1 -1
  25. data/app/lib/actions/pulp3/capsule_content/refresh_distribution.rb +2 -2
  26. data/app/lib/actions/pulp3/capsule_content/sync.rb +1 -1
  27. data/app/lib/actions/pulp3/content_migration.rb +17 -0
  28. data/app/lib/actions/pulp3/import_migration.rb +14 -0
  29. data/app/lib/actions/pulp3/orchestration/orphan_cleanup/remove_orphans.rb +4 -1
  30. data/app/lib/actions/pulp3/orchestration/repository/copy_all_units.rb +3 -3
  31. data/app/lib/actions/pulp3/orchestration/repository/create.rb +3 -1
  32. data/app/lib/actions/pulp3/orchestration/repository/generate_metadata.rb +0 -2
  33. data/app/lib/actions/pulp3/orchestration/repository/import_upload.rb +1 -1
  34. data/app/lib/actions/pulp3/orchestration/repository/refresh_if_needed.rb +18 -0
  35. data/app/lib/actions/pulp3/orchestration/repository/refresh_repos.rb +1 -1
  36. data/app/lib/actions/pulp3/orchestration/repository/remove_units.rb +1 -1
  37. data/app/lib/actions/pulp3/orchestration/repository/sync.rb +1 -1
  38. data/app/lib/actions/pulp3/orchestration/repository/upload_content.rb +1 -1
  39. data/app/lib/actions/pulp3/orphan_cleanup/delete_orphan_distributions.rb +16 -0
  40. data/app/lib/actions/pulp3/orphan_cleanup/delete_orphan_remotes.rb +16 -0
  41. data/app/lib/actions/pulp3/orphan_cleanup/delete_orphan_repository_versions.rb +1 -6
  42. data/app/lib/actions/pulp3/orphan_cleanup/remove_orphans.rb +15 -0
  43. data/app/lib/actions/pulp3/orphan_cleanup/remove_unneeded_repos.rb +2 -2
  44. data/app/lib/actions/pulp3/repository/create.rb +1 -1
  45. data/app/lib/actions/pulp3/repository/create_publication.rb +1 -1
  46. data/app/lib/actions/pulp3/repository/presenters/content_unit_presenter.rb +1 -0
  47. data/app/lib/actions/pulp3/repository/refresh_distribution.rb +4 -2
  48. data/app/lib/actions/pulp3/repository/save_version.rb +12 -8
  49. data/app/lib/actions/pulp3/repository/upload_file.rb +2 -2
  50. data/app/lib/katello/api/v2/rendering.rb +1 -0
  51. data/app/lib/katello/concerns/base_template_scope_extensions.rb +5 -1
  52. data/app/lib/katello/http_resource.rb +4 -1
  53. data/app/lib/katello/resources/registry.rb +9 -2
  54. data/app/models/katello/concerns/content_facet_host_extensions.rb +1 -0
  55. data/app/models/katello/concerns/organization_extensions.rb +4 -4
  56. data/app/models/katello/concerns/smart_proxy_extensions.rb +33 -7
  57. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +34 -12
  58. data/app/models/katello/content_view_docker_filter.rb +1 -1
  59. data/app/models/katello/content_view_version.rb +20 -47
  60. data/app/models/katello/glue/candlepin/owner.rb +4 -0
  61. data/app/models/katello/glue/candlepin/product.rb +12 -6
  62. data/app/models/katello/glue/pulp/repos.rb +6 -3
  63. data/app/models/katello/host/subscription_facet.rb +4 -5
  64. data/app/models/katello/ping.rb +3 -4
  65. data/app/models/katello/pool.rb +1 -1
  66. data/app/models/katello/pulp3/distribution_reference.rb +1 -1
  67. data/app/models/katello/repository.rb +14 -0
  68. data/app/models/katello/root_repository.rb +0 -2
  69. data/app/models/katello/subscription_status.rb +7 -0
  70. data/app/models/setting/content.rb +10 -3
  71. data/app/services/katello/candlepin/consumer.rb +1 -0
  72. data/app/services/katello/pulp/repository.rb +1 -1
  73. data/app/services/katello/pulp/repository/deb.rb +2 -0
  74. data/app/services/katello/pulp/repository/docker.rb +2 -0
  75. data/app/services/katello/pulp/repository/file.rb +2 -0
  76. data/app/services/katello/pulp/repository/yum.rb +9 -5
  77. data/app/services/katello/pulp3/ansible_collection.rb +1 -1
  78. data/app/services/katello/pulp3/api/ansible_collection.rb +46 -0
  79. data/app/services/katello/pulp3/api/core.rb +159 -0
  80. data/app/services/katello/pulp3/api/docker.rb +62 -0
  81. data/app/services/katello/pulp3/api/file.rb +54 -0
  82. data/app/services/katello/pulp3/api/yum.rb +54 -0
  83. data/app/services/katello/pulp3/distribution.rb +17 -0
  84. data/app/services/katello/pulp3/docker_blob.rb +1 -1
  85. data/app/services/katello/pulp3/docker_manifest.rb +1 -1
  86. data/app/services/katello/pulp3/docker_manifest_list.rb +1 -1
  87. data/app/services/katello/pulp3/docker_tag.rb +1 -1
  88. data/app/services/katello/pulp3/erratum.rb +109 -0
  89. data/app/services/katello/pulp3/file_unit.rb +1 -1
  90. data/app/services/katello/pulp3/migration.rb +71 -0
  91. data/app/services/katello/pulp3/migration_plan.rb +27 -0
  92. data/app/services/katello/pulp3/module_stream.rb +47 -0
  93. data/app/services/katello/pulp3/package_group.rb +66 -0
  94. data/app/services/katello/pulp3/pulp_content_unit.rb +9 -1
  95. data/app/services/katello/pulp3/repository.rb +118 -348
  96. data/app/services/katello/pulp3/repository/ansible_collection.rb +1 -29
  97. data/app/services/katello/pulp3/repository/docker.rb +23 -43
  98. data/app/services/katello/pulp3/repository/file.rb +1 -37
  99. data/app/services/katello/pulp3/repository/yum.rb +36 -37
  100. data/app/services/katello/pulp3/repository_mirror.rb +171 -0
  101. data/app/services/katello/pulp3/rpm.rb +143 -0
  102. data/app/services/katello/pulp3/smart_proxy_mirror_repository.rb +92 -0
  103. data/app/services/katello/pulp3/smart_proxy_repository.rb +38 -9
  104. data/app/services/katello/pulp3/srpm.rb +74 -0
  105. data/app/services/katello/pulp3/yum_metadata_file.rb +20 -0
  106. data/app/services/katello/registration_manager.rb +12 -11
  107. data/app/services/katello/repository_type.rb +11 -3
  108. data/app/services/katello/repository_type_manager.rb +11 -0
  109. data/app/views/dashboard/_subscription_widget.html.erb +6 -1
  110. data/app/views/katello/api/v2/content_view_versions/base.json.rabl +4 -11
  111. data/app/views/katello/api/v2/docker_manifest_lists/show.json.rabl +2 -1
  112. data/app/views/katello/api/v2/docker_manifests/show.json.rabl +2 -1
  113. data/app/views/katello/api/v2/package_groups/show.json.rabl +1 -1
  114. data/app/views/katello/api/v2/packages/show.json.rabl +2 -1
  115. data/app/views/katello/api/v2/repositories/base.json.rabl +2 -0
  116. data/app/views/katello/api/v2/repositories/show.json.rabl +2 -1
  117. data/app/views/katello/api/v2/smart_proxies/pulp_info.json.rabl +2 -0
  118. data/app/views/katello/api/v2/subscription_facet/show.json.rabl +1 -1
  119. data/app/views/smart_proxies/plugins/_pulp3.html.erb +19 -0
  120. data/app/views/smart_proxies/pulp_status.html.erb +10 -0
  121. data/db/migrate/20190930192813_add_pulp3_hrefs_to_content_types.rb +10 -0
  122. data/db/migrate/20191204020703_migrate_distribution_reference_to_use_repo_id.rb +22 -0
  123. data/db/migrate/20191204214919_add_content_view_version_counts.rb +7 -0
  124. data/db/migrate/20191213161248_add_dmi_uuid_to_katello_subscription_facets.rb +6 -0
  125. data/db/migrate/20200109162354_drop_host_update_lock_setting.rb +5 -0
  126. data/db/seeds.d/104-proxy.rb +1 -1
  127. data/db/seeds.d/111-upgrade_tasks.rb +3 -1
  128. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-subscriptions-modal.controller.js +3 -2
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-subscriptions-modal.html +8 -3
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +2 -2
  131. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/components/views/content-view-composite-available-content-views.html +1 -1
  132. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/components/views/content-view-composite-content-views-list.html +1 -1
  133. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/views/products-bulk-http-proxy-modal.html +3 -3
  134. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +2 -2
  135. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +2 -2
  136. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/views/product-repositories.html +4 -1
  137. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/views/products.html +1 -1
  138. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/content-access-mode-banner.html +1 -1
  139. data/lib/katello/engine.rb +25 -25
  140. data/lib/katello/plugin.rb +1 -1
  141. data/lib/katello/repository_types/ansible_collection.rb +1 -0
  142. data/lib/katello/repository_types/docker.rb +2 -1
  143. data/lib/katello/repository_types/file.rb +1 -1
  144. data/lib/katello/repository_types/yum.rb +29 -7
  145. data/lib/katello/tasks/pulp3_content_switchover.rake +21 -0
  146. data/lib/katello/tasks/pulp3_migration.rake +21 -0
  147. data/lib/katello/tasks/reset.rake +43 -16
  148. data/lib/katello/tasks/update_content_default_http_proxy.rake +3 -3
  149. data/lib/katello/tasks/upgrades/3.15/reindex_rpm_modular.rake +23 -0
  150. data/lib/katello/tasks/upgrades/3.15/set_sub_facet_dmi_uuid.rake +16 -0
  151. data/lib/katello/version.rb +1 -1
  152. data/package.json +9 -10
  153. data/webpack/components/WithOrganization/__snapshots__/withOrganization.test.js.snap +0 -63
  154. data/webpack/redux/actions/RedHatRepositories/helpers.js +5 -5
  155. data/webpack/redux/reducers/RedHatRepositories/repositorySetRepositories.js +17 -2
  156. data/webpack/scenes/RedHatRepositories/components/RepositorySet.js +1 -0
  157. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepositories.js +1 -1
  158. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository/RepositorySetRepository.js +2 -3
  159. data/webpack/scenes/RedHatRepositories/components/__tests__/RepositorySetRepositories.test.js +44 -28
  160. data/webpack/scenes/RedHatRepositories/components/__tests__/__snapshots__/RepositorySetRepositories.test.js.snap +77 -45
  161. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +2 -6
  162. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionTypeFormatter.test.js.snap +0 -1
  163. data/webpack/test_setup.js +3 -1
  164. metadata +62 -24
  165. data/app/lib/actions/katello/host/update.rb +0 -84
  166. data/app/lib/actions/pulp3/repository/create_version.rb +0 -19
  167. data/app/views/katello/api/v2/smart_proxies/download_policy.json.rabl +0 -1
@@ -62,6 +62,7 @@ module Katello
62
62
 
63
63
  scoped_search :on => :content_view_id, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
64
64
  scoped_search :on => :major, :rename => :version, :complete_value => true, :ext_method => :find_by_version
65
+ serialize :content_counts
65
66
 
66
67
  def self.find_by_version(_key, operator, value)
67
68
  conditions = ""
@@ -160,7 +161,7 @@ module Katello
160
161
  end
161
162
 
162
163
  def promote_puppet_environment?
163
- puppet_module_count > 0 || self.content_view.force_puppet_environment?
164
+ (!content_counts.blank? && content_counts.dig(PuppetModule::CONTENT_TYPE) > 0) || self.content_view.force_puppet_environment?
164
165
  end
165
166
 
166
167
  def archived_repos
@@ -257,50 +258,10 @@ module Katello
257
258
  Katello::Srpm.in_repositories(self.repositories)
258
259
  end
259
260
 
260
- def srpm_count
261
- Katello::Srpm.in_repositories(self.repositories.archived).count
262
- end
263
-
264
- def puppet_module_count
265
- puppet_modules.count
266
- end
267
-
268
- def package_count
269
- Katello::Rpm.in_repositories(self.repositories.archived).count
270
- end
271
-
272
261
  def module_streams
273
262
  ModuleStream.in_repositories(archived_repos)
274
263
  end
275
264
 
276
- def module_stream_count
277
- Katello::ModuleStream.in_repositories(self.repositories.archived).count
278
- end
279
-
280
- def file_count
281
- Katello::FileUnit.in_repositories(self.repositories.archived).count
282
- end
283
-
284
- def ostree_branch_count
285
- ostree_branches.count
286
- end
287
-
288
- def docker_manifest_list_count
289
- repositories.archived.docker_type.inject(0) do |sum, repo|
290
- sum + repo.docker_manifest_lists.count
291
- end
292
- end
293
-
294
- def docker_manifest_count
295
- repositories.archived.docker_type.inject(0) do |sum, repo|
296
- sum + repo.docker_manifests.count
297
- end
298
- end
299
-
300
- def docker_tag_count
301
- docker_tags.count
302
- end
303
-
304
265
  def docker_tags
305
266
  # Don't count tags from non-archived repos; this causes count errors
306
267
  ::Katello::DockerMetaTag.where(:id => RepositoryDockerMetaTag.where(:repository_id => repositories.archived.docker_type).select(:docker_meta_tag_id))
@@ -310,10 +271,6 @@ module Katello
310
271
  Katello::Deb.in_repositories(self.repositories.archived)
311
272
  end
312
273
 
313
- def deb_count
314
- debs.count
315
- end
316
-
317
274
  def errata(errata_type = nil)
318
275
  errata = Erratum.in_repositories(archived_repos)
319
276
  errata = errata.of_type(errata_type) if errata_type
@@ -348,8 +305,24 @@ module Katello
348
305
  PackageGroup.in_repositories(archived_repos)
349
306
  end
350
307
 
351
- def package_group_count
352
- package_groups.count
308
+ def update_content_counts!
309
+ self.content_counts = {}
310
+ RepositoryTypeManager.indexable_content_types.map(&:model_class).each do |content_type|
311
+ if content_type::CONTENT_TYPE == DockerTag::CONTENT_TYPE
312
+ content_counts[DockerTag::CONTENT_TYPE] = docker_tags.count
313
+ else
314
+ content_counts[content_type::CONTENT_TYPE] = content_type.in_repositories(self.repositories.archived).count
315
+ end
316
+ end
317
+ save!
318
+ end
319
+
320
+ def content_counts_map
321
+ return {} if content_counts.blank?
322
+ counts = Hash[content_counts.map { |key, value| ["#{key}_count", value] }]
323
+ counts.merge("module_stream_count" => counts["modulemd_count"],
324
+ "package_count" => counts["rpm_count"],
325
+ "ostree_branch_count" => counts["ostree_count"])
353
326
  end
354
327
 
355
328
  def check_ready_to_promote!(to_env)
@@ -35,6 +35,10 @@ module Katello
35
35
  self.owner_details['contentAccessMode']
36
36
  end
37
37
 
38
+ def golden_ticket?
39
+ content_access_mode == "org_environment"
40
+ end
41
+
38
42
  def generate_debug_cert
39
43
  Resources::Candlepin::Owner.generate_ueber_cert(label)
40
44
  end
@@ -101,13 +101,19 @@ module Katello
101
101
 
102
102
  def import_custom_subscription
103
103
  fail _("Cannot import a custom subscription from a redhat product.") if self.redhat?
104
- sub = nil
105
- ::Katello::Util::Support.active_record_retry do
106
- sub = ::Katello::Subscription.where(:cp_id => self.cp_id, :organization_id => self.organization.id).first_or_create
104
+ User.as_anonymous_admin do
105
+ sub = nil
106
+ ::Katello::Util::Support.active_record_retry do
107
+ sub = ::Katello::Subscription.where(:cp_id => self.cp_id, :organization_id => self.organization.id).first_or_create
108
+ end
109
+ unless sub.persisted?
110
+ message = _("Subscription was not persisted - %{error_message}") % {:error_message => sub.errors.full_messages.join("; ")}
111
+ fail HttpErrors::UnprocessableEntity, message
112
+ end
113
+ sub.import_data
114
+ pools = ::Katello::Resources::Candlepin::Product.pools(self.organization.label, self.cp_id)
115
+ pools.each { |pool_json| ::Katello::Pool.import_pool(pool_json['id']) }
107
116
  end
108
- sub.import_data
109
- pools = ::Katello::Resources::Candlepin::Product.pools(self.organization.label, self.cp_id)
110
- pools.each { |pool_json| ::Katello::Pool.import_pool(pool_json['id']) }
111
117
  end
112
118
  end
113
119
  end
@@ -76,9 +76,12 @@ module Katello
76
76
  summary
77
77
  end
78
78
 
79
+ def last_sync_audit
80
+ Audited::Audit.where(:auditable_id => self.repositories, :auditable_type => Katello::Repository.name).order(:created_at).last
81
+ end
82
+
79
83
  def last_sync
80
- task = last_repo_sync_task
81
- task.nil? ? nil : task.started_at.to_s
84
+ last_repo_sync_task&.started_at&.to_s || last_sync_audit&.created_at&.to_s
82
85
  end
83
86
 
84
87
  def last_repo_sync_task
@@ -97,7 +100,7 @@ module Katello
97
100
  def last_repo_sync_task_group
98
101
  if last_repo_sync_task
99
102
  started_after = last_repo_sync_task.started_at - 30.seconds
100
- last_repo_sync_tasks.where("#{ForemanTasks::Task::DynflowTask.table_name}.started_at > '%s'", started_after).uniq
103
+ last_repo_sync_tasks.where("#{ForemanTasks::Task::DynflowTask.table_name}.started_at > '%s'", started_after.utc).uniq
101
104
  else
102
105
  []
103
106
  end
@@ -41,11 +41,6 @@ module Katello
41
41
  host_facts["virt::host_type"] || host_facts["hypervisor::type"]
42
42
  end
43
43
 
44
- def dmi_system_uuid
45
- host_facts = self.host.facts
46
- host_facts["dmi::system::uuid"]
47
- end
48
-
49
44
  def update_from_consumer_attributes(consumer_params)
50
45
  import_database_attributes(consumer_params)
51
46
  self.facts = consumer_params['facts'] unless consumer_params['facts'].blank?
@@ -56,6 +51,10 @@ module Katello
56
51
  update_hypervisor(consumer_params)
57
52
  update_guests(consumer_params)
58
53
 
54
+ if consumer_params['facts']
55
+ self.dmi_uuid = consumer_params['facts']['dmi.system.uuid']
56
+ end
57
+
59
58
  self.autoheal = consumer_params['autoheal'] unless consumer_params['autoheal'].blank?
60
59
  self.service_level = consumer_params['serviceLevel'] unless consumer_params['serviceLevel'].nil?
61
60
  self.registered_at = consumer_params['created'] unless consumer_params['created'].blank?
@@ -71,7 +71,7 @@ module Katello
71
71
 
72
72
  def ping_pulp3_without_auth(service_result, capsule_id)
73
73
  exception_watch(service_result) do
74
- Katello::Ping.pulp3_without_auth(fetch_proxy(capsule_id).pulp3_url("api/v3"))
74
+ Katello::Ping.pulp3_without_auth(fetch_proxy(capsule_id).pulp3_url)
75
75
  end
76
76
  end
77
77
 
@@ -193,10 +193,9 @@ module Katello
193
193
  end
194
194
 
195
195
  workers = json["online_workers"] || []
196
- resource_manager_exists = workers.any? { |worker| worker["name"].include?("resource-manager@") }
197
- reservered_resource_worker_exists = workers.any? { |worker| worker["name"] =~ /reserved-resource-worker-./ }
196
+ resource_manager_exists = workers.any? { |worker| worker["name"].include?("resource-manager") }
198
197
 
199
- unless resource_manager_exists && reservered_resource_worker_exists
198
+ unless resource_manager_exists && workers.count > 1
200
199
  fail _("Not all necessary pulp workers running at %s.") % url
201
200
  end
202
201
 
@@ -101,7 +101,7 @@ module Katello
101
101
  end
102
102
 
103
103
  class Jail < ::Safemode::Jail
104
- allow :id, :name, :available, :quantity, :product_id, :contract_number, :type, :account_number, :start_date, :end_date
104
+ allow :id, :name, :available, :quantity, :product_id, :contract_number, :type, :account_number, :start_date, :end_date, :organization
105
105
  end
106
106
  end
107
107
  end
@@ -1,7 +1,7 @@
1
1
  module Katello
2
2
  module Pulp3
3
3
  class DistributionReference < Katello::Model
4
- belongs_to :root_repository, :class_name => 'Katello::RootRepository'
4
+ belongs_to :repository, :class_name => 'Katello::Repository'
5
5
  end
6
6
  end
7
7
  end
@@ -1,6 +1,8 @@
1
1
  module Katello
2
2
  # rubocop:disable Metrics/ClassLength
3
3
  class Repository < Katello::Model
4
+ audited
5
+
4
6
  #pulp uses pulp id to sync with 'yum_distributor' on the end
5
7
  PULP_ID_MAX_LENGTH = 220
6
8
 
@@ -19,6 +21,8 @@ module Katello
19
21
  include ERB::Util
20
22
  include ::ScopedSearchExtensions
21
23
 
24
+ AUDIT_SYNC_ACTION = 'sync'.freeze
25
+
22
26
  DEB_TYPE = 'deb'.freeze
23
27
  YUM_TYPE = 'yum'.freeze
24
28
  FILE_TYPE = 'file'.freeze
@@ -99,6 +103,8 @@ module Katello
99
103
  has_many :filters, :through => :repository_content_view_filters
100
104
 
101
105
  belongs_to :content_view_version, :inverse_of => :repositories, :class_name => "Katello::ContentViewVersion"
106
+ has_many :distribution_references, :class_name => 'Katello::Pulp3::DistributionReference', :foreign_key => :repository_id,
107
+ :dependent => :destroy, :inverse_of => :repository
102
108
 
103
109
  validates_with Validators::ContainerImageNameValidator, :attributes => :container_repository_name, :allow_blank => false, :if => :docker?
104
110
  validates :container_repository_name, :if => :docker?, :uniqueness => {message: ->(object, _data) do
@@ -189,6 +195,10 @@ module Katello
189
195
  end
190
196
  end
191
197
 
198
+ def audit_sync
199
+ write_audit(action: AUDIT_SYNC_ACTION, comment: _('Successfully synchronized.'), audited_changes: {})
200
+ end
201
+
192
202
  def set_pulp_id
193
203
  return if self.pulp_id
194
204
 
@@ -460,6 +470,10 @@ module Katello
460
470
  clone
461
471
  end
462
472
 
473
+ def latest_sync_audit
474
+ self.audits.where(:action => AUDIT_SYNC_ACTION).order(:created_at).last
475
+ end
476
+
463
477
  def cancel_dynflow_sync
464
478
  if latest_dynflow_sync
465
479
  plan = latest_dynflow_sync.execution_plan
@@ -42,8 +42,6 @@ module Katello
42
42
 
43
43
  has_many :repository_references, :class_name => 'Katello::Pulp3::RepositoryReference', :foreign_key => :root_repository_id,
44
44
  :dependent => :destroy, :inverse_of => :root_repository
45
- has_many :distribution_references, :class_name => 'Katello::Pulp3::DistributionReference', :foreign_key => :root_repository_id,
46
- :dependent => :destroy, :inverse_of => :root_repository
47
45
 
48
46
  before_validation :update_ostree_upstream_sync_policy
49
47
 
@@ -1,5 +1,6 @@
1
1
  module Katello
2
2
  class SubscriptionStatus < HostStatus::Status
3
+ DISABLED = 5
3
4
  UNSUBSCRIBED_HYPERVISOR = 4
4
5
  UNKNOWN = 3
5
6
  INVALID = 2
@@ -20,6 +21,8 @@ module Katello
20
21
  N_("Unentitled")
21
22
  when UNSUBSCRIBED_HYPERVISOR
22
23
  N_("Unsubscribed hypervisor")
24
+ when DISABLED
25
+ N_("Disabled")
23
26
  else
24
27
  N_("Unknown subscription status")
25
28
  end
@@ -29,6 +32,8 @@ module Katello
29
32
  case status
30
33
  when INVALID
31
34
  ::HostStatus::Global::ERROR
35
+ when DISABLED
36
+ ::HostStatus::Global::OK
32
37
  when VALID
33
38
  ::HostStatus::Global::OK
34
39
  else
@@ -43,6 +48,8 @@ module Katello
43
48
  status = status_override || Katello::Candlepin::Consumer.new(host.subscription_facet.uuid, host.organization.label).entitlement_status
44
49
 
45
50
  case status
51
+ when Katello::Candlepin::Consumer::ENTITLEMENTS_DISABLED
52
+ DISABLED
46
53
  when Katello::Candlepin::Consumer::ENTITLEMENTS_VALID
47
54
  VALID
48
55
  when Katello::Candlepin::Consumer::ENTITLEMENTS_PARTIAL
@@ -2,6 +2,8 @@ class Setting::Content < Setting
2
2
  #rubocop:disable Metrics/MethodLength
3
3
  #rubocop:disable Metrics/AbcSize
4
4
 
5
+ validate :content_default_http_proxy, if: proc { |s| s.name == 'content_default_http_proxy' }
6
+
5
7
  after_save :add_organizations_and_locations_if_global_http_proxy
6
8
 
7
9
  def self.hashify_parameters(parameters)
@@ -22,7 +24,7 @@ class Setting::Content < Setting
22
24
 
23
25
  [
24
26
  self.set('content_default_http_proxy', N_("Default HTTP Proxy for syncing content"),
25
- nil, N_('Default http proxy'),
27
+ nil, N_('Default HTTP proxy'),
26
28
  nil,
27
29
  collection: proc { http_proxy_select }, include_blank: N_("no global default")
28
30
  ),
@@ -114,8 +116,6 @@ class Setting::Content < Setting
114
116
  N_('Default Location where new Puppet content will be put upon Content View publish'),
115
117
  nil, N_('Default Location Puppet content'), nil,
116
118
  :collection => proc { Hash[Location.unscoped.all.map { |loc| [loc[:title], loc[:title]] }] }),
117
- self.set('host_update_lock', N_("Allow multiple concurrent Actions::Katello::Host::Update calls for one host to be processed at the same time."),
118
- false, N_('Concurrent Actions::Katello::Host::Update allowed')),
119
119
  self.set('expire_soon_days', N_('The number of days remaining in a subscription before you will be reminded about renewing it.'),
120
120
  120, N_('Expire soon days')),
121
121
  self.set('content_view_solve_dependencies',
@@ -160,6 +160,13 @@ class Setting::Content < Setting
160
160
  end
161
161
  end
162
162
  end
163
+
164
+ def content_default_http_proxy
165
+ proxy = HttpProxy.where(name: value).first
166
+ return if proxy || value.blank?
167
+
168
+ errors.add(:base, _('There is no such HTTP proxy'))
169
+ end
163
170
  end
164
171
 
165
172
  # If the database is not migrated yet, the system will not be able to load
@@ -6,6 +6,7 @@ module Katello
6
6
  ENTITLEMENTS_VALID = 'valid'.freeze
7
7
  ENTITLEMENTS_PARTIAL = 'partial'.freeze
8
8
  ENTITLEMENTS_INVALID = 'invalid'.freeze
9
+ ENTITLEMENTS_DISABLED = 'disabled'.freeze
9
10
 
10
11
  SYSTEM = "system".freeze
11
12
  HYPERVISOR = "hypervisor".freeze
@@ -214,7 +214,7 @@ module Katello
214
214
  end
215
215
 
216
216
  def refresh_mirror_entities
217
- refresh
217
+ refresh_if_needed
218
218
  end
219
219
 
220
220
  def update_or_associate_importer
@@ -2,6 +2,8 @@ module Katello
2
2
  module Pulp
3
3
  class Repository
4
4
  class Deb < ::Katello::Pulp::Repository
5
+ REPOSITORY_TYPE = 'deb'.freeze
6
+
5
7
  def generate_master_importer
6
8
  config = {
7
9
  feed: root.url,
@@ -2,6 +2,8 @@ module Katello
2
2
  module Pulp
3
3
  class Repository
4
4
  class Docker < ::Katello::Pulp::Repository
5
+ REPOSITORY_TYPE = 'docker'.freeze
6
+
5
7
  def unit_type_id(uploads = [])
6
8
  uploads.pluck('digest').any? ? 'docker_tag' : super
7
9
  end
@@ -2,6 +2,8 @@ module Katello
2
2
  module Pulp
3
3
  class Repository
4
4
  class File < ::Katello::Pulp::Repository
5
+ REPOSITORY_TYPE = 'iso'.freeze
6
+
5
7
  def unit_keys(uploads)
6
8
  uploads.map do |upload|
7
9
  upload.except('id', 'content_unit_id')
@@ -2,6 +2,8 @@ module Katello
2
2
  module Pulp
3
3
  class Repository
4
4
  class Yum < ::Katello::Pulp::Repository
5
+ REPOSITORY_TYPE = 'yum'.freeze
6
+
5
7
  def generate_master_importer
6
8
  config = {
7
9
  download_policy: root.download_policy,
@@ -51,11 +53,13 @@ module Katello
51
53
  distributors
52
54
  end
53
55
 
54
- def distributors_to_publish(_options)
55
- if repo.clone && !repo.master? && smart_proxy.pulp_master?
56
- source_service = repo.target_repository.backend_service(smart_proxy)
56
+ def distributors_to_publish(options)
57
+ source_repo_id = options[:source_repository]&.fetch(:id)
58
+ if (source_repo_id || !repo.master?) && smart_proxy.pulp_master?
59
+ source_repository = source_repo_id ? ::Katello::Repository.find(source_repo_id) : repo.target_repository
60
+ source_service = source_repository.backend_service(smart_proxy)
57
61
  source_distributor_id = source_service.lookup_distributor_id(Runcible::Models::YumDistributor.type_id)
58
- {Runcible::Models::YumCloneDistributor => {source_repo_id: repo.target_repository.pulp_id,
62
+ {Runcible::Models::YumCloneDistributor => {source_repo_id: source_repository.pulp_id,
59
63
  source_distributor_id: source_distributor_id}}
60
64
  else
61
65
  {Runcible::Models::YumDistributor => {}}
@@ -171,7 +175,7 @@ module Katello
171
175
  task = nil
172
176
  repo.remove_partial_errata! do |errata_to_delete|
173
177
  task = repo.unassociate_by_filter(::Katello::ContentViewErratumFilter::CONTENT_TYPE,
174
- "id" => { "$in" => errata_to_delete.map(&:errata_id) })
178
+ "id" => { "$in" => errata_to_delete.map(&:errata_id).sort })
175
179
  end
176
180
  task
177
181
  end
@@ -4,7 +4,7 @@ module Katello
4
4
  include LazyAccessor
5
5
 
6
6
  def self.content_api
7
- PulpAnsibleClient::ContentCollectionVersionsApi.new(Katello::Pulp3::Repository::AnsibleCollection.api_client(SmartProxy.pulp_master!))
7
+ PulpAnsibleClient::ContentCollectionVersionsApi.new(Katello::Pulp3::Api::AnsibleCollection.new(SmartProxy.pulp_master!).api_client)
8
8
  end
9
9
 
10
10
  def self.ids_for_repository(repo_id)