katello 4.7.4 → 4.7.6

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/v2/simple_content_access_controller.rb +3 -1
  3. data/app/lib/actions/katello/organization/simple_content_access/enable.rb +10 -0
  4. data/app/lib/actions/katello/organization/simple_content_access/prepare_content_overrides.rb +36 -0
  5. data/app/lib/actions/katello/organization/simple_content_access/toggle.rb +12 -2
  6. data/app/lib/katello/concerns/base_template_scope_extensions.rb +1 -1
  7. data/app/lib/katello/util/content_overrides_migrator.rb +98 -0
  8. data/app/models/katello/product_content.rb +4 -0
  9. data/app/models/katello/root_repository.rb +1 -1
  10. data/app/services/katello/product_content_finder.rb +4 -0
  11. data/db/migrate/20220110223754_update_disconnected_settings.rb +8 -4
  12. data/lib/katello/version.rb +1 -1
  13. data/locale/bn/LC_MESSAGES/katello.mo +0 -0
  14. data/locale/cs/LC_MESSAGES/katello.mo +0 -0
  15. data/locale/de/LC_MESSAGES/katello.mo +0 -0
  16. data/locale/en/LC_MESSAGES/katello.mo +0 -0
  17. data/locale/es/LC_MESSAGES/katello.mo +0 -0
  18. data/locale/fr/LC_MESSAGES/katello.mo +0 -0
  19. data/locale/gu/LC_MESSAGES/katello.mo +0 -0
  20. data/locale/hi/LC_MESSAGES/katello.mo +0 -0
  21. data/locale/it/LC_MESSAGES/katello.mo +0 -0
  22. data/locale/ja/LC_MESSAGES/katello.mo +0 -0
  23. data/locale/ka/LC_MESSAGES/katello.mo +0 -0
  24. data/locale/kn/LC_MESSAGES/katello.mo +0 -0
  25. data/locale/ko/LC_MESSAGES/katello.mo +0 -0
  26. data/locale/mr/LC_MESSAGES/katello.mo +0 -0
  27. data/locale/or/LC_MESSAGES/katello.mo +0 -0
  28. data/locale/pa/LC_MESSAGES/katello.mo +0 -0
  29. data/locale/pt/LC_MESSAGES/katello.mo +0 -0
  30. data/locale/pt_BR/LC_MESSAGES/katello.mo +0 -0
  31. data/locale/ru/LC_MESSAGES/katello.mo +0 -0
  32. data/locale/ta/LC_MESSAGES/katello.mo +0 -0
  33. data/locale/te/LC_MESSAGES/katello.mo +0 -0
  34. data/locale/zh_CN/LC_MESSAGES/katello.mo +0 -0
  35. data/locale/zh_TW/LC_MESSAGES/katello.mo +0 -0
  36. metadata +39 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58b5925ff8555ac324b96a6ef2586d6f38e09400e6139a8b18d7e4301b1c6595
4
- data.tar.gz: c4d40153fc8d19270c842352ce292d9c67f2c829e72791b0903a5d6caf61da7a
3
+ metadata.gz: 8a0a050c517227f7841e9242a1a02bd8d035844684abb8ad25c61e42c3e16a5a
4
+ data.tar.gz: a6951453dcec4f9ae1fd49622c94d22dce1573a6e788697ec117146e412c61c2
5
5
  SHA512:
6
- metadata.gz: 213cea9b546d83bd1bd7fe0e8a912f765bbf110321f7388c29480baf52fbf0c39d7cb8185d453c2adf542bb1748e009952c74cf900ad2cba5a8b1adefd4dd9c5
7
- data.tar.gz: 572177ab7ccdf854b3ffe7df6714d6fc920491c5c7c0e424dd03eb0ecf8338aa09e327474ce68a4b10cb37d21b4f65d0577bbaa29c6cfaf2b110a35ac99687d6
6
+ metadata.gz: 5041a03d75d5a6cf5fc38aaf2d9a43a05123dbc7065f5dccdf9bd67f40f50483c67ed274d687ab7bafe8ccc8e918afa46406bbed21c0482552e964a6155bc126
7
+ data.tar.gz: 1a622363fcd90b70cd167ae71bb741a8de5e6ef4128a957c476ce90947289cf47d8374560e3e8088dea1aeaaab5f28875707f1a60a50eefc6f4485f4011fc52c
@@ -26,8 +26,10 @@ module Katello
26
26
  api :PUT, "/organizations/:organization_id/simple_content_access/enable",
27
27
  N_("Enable simple content access for a manifest")
28
28
  param :organization_id, :number, :desc => N_("Organization ID"), :required => true
29
+ param :auto_create_overrides, :bool, :desc => N_("Automatically create disabled content overrides for custom products which do not have an attached subscription"), :required => false, :default => true
29
30
  def enable
30
- task = async_task(::Actions::Katello::Organization::SimpleContentAccess::Enable, params[:organization_id])
31
+ auto_create = params.key?(:auto_create_overrides) ? ::Foreman::Cast.to_bool(params[:auto_create_overrides]) : true
32
+ task = async_task(::Actions::Katello::Organization::SimpleContentAccess::Enable, params[:organization_id], auto_create_overrides: auto_create)
31
33
  respond_for_async :resource => task
32
34
  end
33
35
 
@@ -3,6 +3,16 @@ module Actions
3
3
  module Organization
4
4
  module SimpleContentAccess
5
5
  class Enable < Toggle
6
+ def plan(organization_id, auto_create_overrides: true)
7
+ input[:auto_create_overrides] = auto_create_overrides
8
+ sequence do
9
+ if auto_create_overrides
10
+ plan_action(PrepareContentOverrides, organization_id)
11
+ end
12
+ super(organization_id) # puts plan_self inside the sequence
13
+ end
14
+ end
15
+
6
16
  def content_access_mode_value
7
17
  SIMPLE_CONTENT_ACCESS_ENABLED_VALUE
8
18
  end
@@ -0,0 +1,36 @@
1
+ module Actions
2
+ module Katello
3
+ module Organization
4
+ module SimpleContentAccess
5
+ class PrepareContentOverrides < Actions::Base
6
+ def plan(organization_id)
7
+ Rails.logger.info "PrepareContentOverrides plan: #{organization_id.inspect}"
8
+ organization = ::Organization.find(organization_id.to_i)
9
+ org_name = organization.name
10
+
11
+ plan_self(organization_id: organization_id, organization_name: org_name)
12
+ end
13
+
14
+ def run
15
+ organization = ::Organization.find(input[:organization_id].to_i)
16
+ migrator = ::Katello::Util::ContentOverridesMigrator.new(organization: organization)
17
+
18
+ output[:migrator_result] = migrator.execute_non_sca_overrides!
19
+ end
20
+
21
+ def rescue_strategy
22
+ Dynflow::Action::Rescue::Skip
23
+ end
24
+
25
+ def humanized_name
26
+ N_("Prepare content overrides for Simple Content Access")
27
+ end
28
+
29
+ def humanized_input
30
+ _("for organization %s") % input[:organization_name]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -12,9 +12,15 @@ module Actions
12
12
  attr_reader :organization
13
13
 
14
14
  def plan(organization_id)
15
- @organization = ::Organization.find(organization_id)
15
+ organization = ::Organization.find(organization_id.to_i)
16
+ input[:organization_name] = organization.name
17
+ input[:organization_label] = organization.label
16
18
  action_subject organization
17
- ::Katello::Resources::Candlepin::Owner.update(@organization.label, contentAccessMode: content_access_mode_value)
19
+ plan_self(organization_id: organization_id)
20
+ end
21
+
22
+ def run
23
+ ::Katello::Resources::Candlepin::Owner.update(input[:organization_label], contentAccessMode: content_access_mode_value)
18
24
  end
19
25
 
20
26
  def failure_notification(plan)
@@ -30,6 +36,10 @@ module Actions
30
36
  )
31
37
  end
32
38
 
39
+ def humanized_input
40
+ _("for organization %s") % input[:organization_name]
41
+ end
42
+
33
43
  private
34
44
 
35
45
  def consumer
@@ -161,7 +161,7 @@ module Katello
161
161
  returns String, desc: 'Package version'
162
162
  end
163
163
  def host_latest_applicable_rpm_version(host, package)
164
- ::Katello::Rpm.latest(host.applicable_rpms.where(name: package)).first.nvra
164
+ ::Katello::Rpm.latest(host.applicable_rpms.where(name: package))&.first&.nvra
165
165
  end
166
166
 
167
167
  apipie :method, 'Loads Pool objects' do
@@ -0,0 +1,98 @@
1
+ module Katello
2
+ module Util
3
+ class ContentOverridesMigrator # used in Actions::Katello::Organization::SimpleContentAccess::PrepareContentOverrides
4
+ include ActionView::Helpers::TextHelper
5
+
6
+ def initialize(organization:)
7
+ @organization = organization
8
+ end
9
+
10
+ def execute_non_sca_overrides!
11
+ host_errors = create_disabled_overrides_for_non_sca_org_hosts(organization: @organization)
12
+ ak_errors = create_disabled_overrides_for_non_sca_org_activation_keys(organization: @organization)
13
+
14
+ total_errors = host_errors + ak_errors
15
+ finish_message = "Finished creating overrides in non-SCA org; #{total_errors == 0 ? "no errors" : "#{pluralize(total_errors, "error")}"}"
16
+ messages = { result: finish_message, errors: total_errors }
17
+ messages[:host_errors] = "Hosts - #{pluralize(host_errors, "error")} creating disabled overrides for unsubscribed content; see log messages above" if host_errors > 0
18
+ messages[:ak_errors] = "Activation keys - #{pluralize(ak_errors, "error")} creating disabled overrides for unsubscribed content; see log messages above" if ak_errors > 0
19
+ messages[:success_message] = "Organization may now be switched to Simple Content Access mode without any change in access to content." if total_errors == 0
20
+ Rails.logger.info finish_message
21
+ Rails.logger.info messages[:host_errors] if messages[:host_errors]
22
+ Rails.logger.info messages[:ak_errors] if messages[:ak_errors]
23
+ Rails.logger.info messages[:success_message] if messages[:success_message]
24
+ messages
25
+ end
26
+
27
+ def create_disabled_overrides_for_non_sca(consumable:)
28
+ content_finder = ::Katello::ProductContentFinder.new(
29
+ match_subscription: false,
30
+ match_environment: false,
31
+ consumable: consumable
32
+ )
33
+ subscribed_content_finder = ::Katello::ProductContentFinder.new(
34
+ match_subscription: true,
35
+ match_environment: false,
36
+ consumable: consumable
37
+ )
38
+ candlepin_resource = consumable.is_a?(::Katello::Host::SubscriptionFacet) ? ::Katello::Resources::Candlepin::Consumer : ::Katello::Resources::Candlepin::ActivationKey
39
+ consumable_id = consumable.is_a?(::Katello::Host::SubscriptionFacet) ? consumable.uuid : consumable.cp_id
40
+ repos_with_existing_overrides = candlepin_resource.content_overrides(consumable_id).map do |override|
41
+ override[:contentLabel]
42
+ end
43
+ unsubscribed_content = content_finder.custom_content_labels - subscribed_content_finder.custom_content_labels - repos_with_existing_overrides
44
+ new_overrides = unsubscribed_content.map do |repo_label|
45
+ ::Katello::ContentOverride.new(
46
+ repo_label,
47
+ { name: "enabled", value: "0" } # Override to disabled
48
+ )
49
+ end
50
+ return if new_overrides.blank?
51
+ if consumable.is_a? ::Katello::Host::SubscriptionFacet
52
+ ::Katello::Resources::Candlepin::Consumer.update_content_overrides(
53
+ consumable.uuid,
54
+ new_overrides.map(&:to_entitlement_hash)
55
+ )
56
+ else
57
+ ::Katello::Resources::Candlepin::ActivationKey.update_content_overrides(
58
+ consumable.cp_id,
59
+ new_overrides.map(&:to_entitlement_hash)
60
+ )
61
+ end
62
+ end
63
+
64
+ def create_disabled_overrides_for_non_sca_org_hosts(organization:)
65
+ errors = 0
66
+ fail _("Organization must be specified") if organization.blank?
67
+ return 0 if organization.simple_content_access? # subscription attachment is meaningless with SCA
68
+ Rails.logger.info("Hosts - Creating disabled overrides for unsubscribed content in organization #{organization.name}")
69
+ # only registered hosts with content!
70
+ hosts_to_update = organization.hosts.joins(:subscription_facet).where.not("#{Katello::Host::SubscriptionFacet.table_name}.host_id" => nil)
71
+ hosts_to_update.each do |host|
72
+ create_disabled_overrides_for_non_sca(consumable: host.subscription_facet)
73
+ rescue => e
74
+ errors += 1
75
+ Rails.logger.error("Failed to update host #{host.name}: #{e.message}")
76
+ Rails.logger.debug e.backtrace.join("\n")
77
+ end
78
+ errors
79
+ end
80
+
81
+ def create_disabled_overrides_for_non_sca_org_activation_keys(organization:)
82
+ errors = 0
83
+ fail _("Organization must be specified") if organization.blank?
84
+ return 0 if organization.simple_content_access? # subscription attachment is meaningless with SCA
85
+ Rails.logger.info("Activation keys - Creating disabled overrides for unsubscribed content in organization #{organization.name}")
86
+ aks_to_update = organization.activation_keys
87
+ aks_to_update.each do |ak|
88
+ create_disabled_overrides_for_non_sca(consumable: ak)
89
+ rescue => e
90
+ errors += 1
91
+ Rails.logger.error("Failed to update activation key #{ak.name}: #{e.message}")
92
+ Rails.logger.debug e.backtrace.join("\n")
93
+ end
94
+ errors
95
+ end
96
+ end
97
+ end
98
+ end
@@ -15,6 +15,10 @@ module Katello
15
15
  where(:product_id => Product.redhat.select(:id))
16
16
  }
17
17
 
18
+ scope :custom, -> {
19
+ where.not(:product_id => Product.redhat.select(:id))
20
+ }
21
+
18
22
  scoped_search :on => :name, :relation => :content
19
23
  scoped_search :relation => :product, :on => :name, :rename => :product
20
24
  scoped_search :on => :content_type, :relation => :content, :complete_value => true
@@ -228,7 +228,7 @@ module Katello
228
228
  elsif ignorable_content.any? { |item| !IGNORABLE_CONTENT_UNIT_TYPES.include?(item) }
229
229
  errors.add(:ignorable_content, N_("Invalid value specified for ignorable content. Permissible values %s") % IGNORABLE_CONTENT_UNIT_TYPES.join(","))
230
230
  elsif self.mirroring_policy == MIRRORING_POLICY_COMPLETE
231
- errors.add(:ignorable_content, N_("Ignore SRPMs can not be set in combination with 'Complete Mirroring' mirroring policy."))
231
+ errors.add(:ignorable_content, N_("Ignore %s can not be set in combination with 'Complete Mirroring' mirroring policy.") % IGNORABLE_CONTENT_UNIT_TYPES.join(","))
232
232
  end
233
233
  end
234
234
 
@@ -30,6 +30,10 @@ module Katello
30
30
  consumable.organization.enabled_product_content_for(roots)
31
31
  end
32
32
 
33
+ def custom_content_labels
34
+ product_content.custom.map { |pc| pc.product.root_repositories.map(&:custom_content_label) }.flatten.uniq
35
+ end
36
+
33
37
  def self.wrap_with_overrides(product_contents:, overrides:, status: nil)
34
38
  pc_with_overrides = product_contents.map { |pc| ProductContentPresenter.new(pc, overrides) }
35
39
  if status
@@ -1,19 +1,23 @@
1
1
  class UpdateDisconnectedSettings < ActiveRecord::Migration[6.0]
2
+ class FakeSetting < Katello::Model
3
+ self.table_name = 'settings'
4
+ end
5
+
2
6
  def up
3
- setting_disconnected = Setting.find_by(name: 'content_disconnected')
7
+ setting_disconnected = FakeSetting.find_by(name: 'content_disconnected')
4
8
  setting = Setting.find_by(name: 'subscription_connection_enabled')
5
9
 
6
10
  setting&.update!(
7
11
  value: !setting_disconnected&.value
8
12
  )
9
- Setting.where(:name => 'content_disconnected').delete_all
13
+ FakeSetting.where(:name => 'content_disconnected').delete_all
10
14
  end
11
15
 
12
16
  def down
13
17
  remove_column :katello_cdn_configurations, :airgapped
14
18
  setting_disconnected = Setting.find_by(name: 'subscription_connection_enabled')
15
- Setting.set('content_disconnected', N_("A server operating in disconnected mode does not communicate with the Red Hat CDN."),
16
- !setting_disconnected.value, N_('Disconnected mode'))
19
+ FakeSetting.set('content_disconnected', N_("A server operating in disconnected mode does not communicate with the Red Hat CDN."),
20
+ !setting_disconnected.value, N_('Disconnected mode'))
17
21
 
18
22
  Setting.where(:name => 'subscription_connection_enabled').delete_all
19
23
  end
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "4.7.4".freeze
2
+ VERSION = "4.7.6".freeze
3
3
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.4
4
+ version: 4.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - N/A
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,20 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '5.0'
89
+ version: 7.2.1
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: 8.0.0
90
93
  type: :runtime
91
94
  prerelease: false
92
95
  version_requirements: !ruby/object:Gem::Requirement
93
96
  requirements:
94
97
  - - ">="
95
98
  - !ruby/object:Gem::Version
96
- version: '5.0'
99
+ version: 7.2.1
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: 8.0.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: foreman_remote_execution
99
105
  requirement: !ruby/object:Gem::Requirement
@@ -941,6 +947,7 @@ files:
941
947
  - app/lib/actions/katello/organization/manifest_refresh.rb
942
948
  - app/lib/actions/katello/organization/simple_content_access/disable.rb
943
949
  - app/lib/actions/katello/organization/simple_content_access/enable.rb
950
+ - app/lib/actions/katello/organization/simple_content_access/prepare_content_overrides.rb
944
951
  - app/lib/actions/katello/organization/simple_content_access/toggle.rb
945
952
  - app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
946
953
  - app/lib/actions/katello/product/content_create.rb
@@ -1208,6 +1215,7 @@ files:
1208
1215
  - app/lib/katello/resources/registry.rb
1209
1216
  - app/lib/katello/util/candlepin_repository_checker.rb
1210
1217
  - app/lib/katello/util/cdn_var_substitutor.rb
1218
+ - app/lib/katello/util/content_overrides_migrator.rb
1211
1219
  - app/lib/katello/util/data.rb
1212
1220
  - app/lib/katello/util/deduplication_migrator.rb
1213
1221
  - app/lib/katello/util/docker_manifest_clause_generator.rb
@@ -4489,31 +4497,54 @@ files:
4489
4497
  - locale/Makefile
4490
4498
  - locale/README
4491
4499
  - locale/action_names.rb
4500
+ - locale/bn/LC_MESSAGES/katello.mo
4492
4501
  - locale/bn/katello.po
4502
+ - locale/cs/LC_MESSAGES/katello.mo
4493
4503
  - locale/cs/katello.po
4504
+ - locale/de/LC_MESSAGES/katello.mo
4494
4505
  - locale/de/katello.po
4506
+ - locale/en/LC_MESSAGES/katello.mo
4495
4507
  - locale/en/katello.po
4508
+ - locale/es/LC_MESSAGES/katello.mo
4496
4509
  - locale/es/katello.po
4510
+ - locale/fr/LC_MESSAGES/katello.mo
4497
4511
  - locale/fr/katello.po
4512
+ - locale/gu/LC_MESSAGES/katello.mo
4498
4513
  - locale/gu/katello.po
4514
+ - locale/hi/LC_MESSAGES/katello.mo
4499
4515
  - locale/hi/katello.po
4516
+ - locale/it/LC_MESSAGES/katello.mo
4500
4517
  - locale/it/katello.po
4518
+ - locale/ja/LC_MESSAGES/katello.mo
4501
4519
  - locale/ja/katello.po
4520
+ - locale/ka/LC_MESSAGES/katello.mo
4502
4521
  - locale/ka/katello.po
4503
4522
  - locale/katello.pot
4523
+ - locale/kn/LC_MESSAGES/katello.mo
4504
4524
  - locale/kn/katello.po
4525
+ - locale/ko/LC_MESSAGES/katello.mo
4505
4526
  - locale/ko/katello.po
4527
+ - locale/mr/LC_MESSAGES/katello.mo
4506
4528
  - locale/mr/katello.po
4529
+ - locale/or/LC_MESSAGES/katello.mo
4507
4530
  - locale/or/katello.po
4531
+ - locale/pa/LC_MESSAGES/katello.mo
4508
4532
  - locale/pa/katello.po
4533
+ - locale/pt/LC_MESSAGES/katello.mo
4509
4534
  - locale/pt/katello.po
4535
+ - locale/pt_BR/LC_MESSAGES/katello.mo
4510
4536
  - locale/pt_BR/katello.po
4537
+ - locale/ru/LC_MESSAGES/katello.mo
4511
4538
  - locale/ru/katello.po
4539
+ - locale/ta/LC_MESSAGES/katello.mo
4512
4540
  - locale/ta/katello.po
4541
+ - locale/te/LC_MESSAGES/katello.mo
4513
4542
  - locale/te/katello.po
4514
4543
  - locale/update-i18n
4515
4544
  - locale/zanata.xml
4545
+ - locale/zh_CN/LC_MESSAGES/katello.mo
4516
4546
  - locale/zh_CN/katello.po
4547
+ - locale/zh_TW/LC_MESSAGES/katello.mo
4517
4548
  - locale/zh_TW/katello.po
4518
4549
  - package.json
4519
4550
  - vendor/assets/images/katello/add2.png
@@ -5427,7 +5458,7 @@ homepage: http://www.katello.org
5427
5458
  licenses:
5428
5459
  - GPL-2.0
5429
5460
  metadata: {}
5430
- post_install_message:
5461
+ post_install_message:
5431
5462
  rdoc_options: []
5432
5463
  require_paths:
5433
5464
  - lib
@@ -5442,8 +5473,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
5442
5473
  - !ruby/object:Gem::Version
5443
5474
  version: '0'
5444
5475
  requirements: []
5445
- rubygems_version: 3.1.6
5446
- signing_key:
5476
+ rubygems_version: 3.3.26
5477
+ signing_key:
5447
5478
  specification_version: 4
5448
5479
  summary: Content and Subscription Management plugin for Foreman
5449
5480
  test_files: []