katello 4.7.4 → 4.7.5
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.
- checksums.yaml +4 -4
- data/app/controllers/katello/api/v2/simple_content_access_controller.rb +3 -1
- data/app/lib/actions/katello/organization/simple_content_access/enable.rb +10 -0
- data/app/lib/actions/katello/organization/simple_content_access/prepare_content_overrides.rb +36 -0
- data/app/lib/actions/katello/organization/simple_content_access/toggle.rb +12 -2
- data/app/lib/katello/util/content_overrides_migrator.rb +98 -0
- data/app/models/katello/root_repository.rb +1 -1
- data/db/migrate/20220110223754_update_disconnected_settings.rb +8 -4
- data/lib/katello/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd4bf2aa04a425ae9878634d31f53214b3ea3f0143df8d085621bfc558cadd77
|
4
|
+
data.tar.gz: 84916e97ceb9cecdd2fedd5683294e238c66f1698d74583e31378d93df1cf94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd2c0ab5a699d02aeed2c6c614db181e0270c3f05f80273d1bd19d6ac1c279151fe5cee92493a146d4a18c97f3d40b11a85c83b80f048abba51632b7e67060a
|
7
|
+
data.tar.gz: 352f528834b0ed0a45066b689064baac6a2195b6f33b006b80459b11c781ed01fd8d59bf9f5914bc618eaea5263d613f6bc6aaacfcadc3549997bd72739ff73f
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -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 orgs; #{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] = "You may now switch all organizations 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
|
@@ -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
|
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
|
|
@@ -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 =
|
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
|
-
|
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
|
-
|
16
|
-
|
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
|
data/lib/katello/version.rb
CHANGED
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
|
+
version: 4.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- N/A
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -941,6 +941,7 @@ files:
|
|
941
941
|
- app/lib/actions/katello/organization/manifest_refresh.rb
|
942
942
|
- app/lib/actions/katello/organization/simple_content_access/disable.rb
|
943
943
|
- app/lib/actions/katello/organization/simple_content_access/enable.rb
|
944
|
+
- app/lib/actions/katello/organization/simple_content_access/prepare_content_overrides.rb
|
944
945
|
- app/lib/actions/katello/organization/simple_content_access/toggle.rb
|
945
946
|
- app/lib/actions/katello/orphan_cleanup/remove_orphans.rb
|
946
947
|
- app/lib/actions/katello/product/content_create.rb
|
@@ -1208,6 +1209,7 @@ files:
|
|
1208
1209
|
- app/lib/katello/resources/registry.rb
|
1209
1210
|
- app/lib/katello/util/candlepin_repository_checker.rb
|
1210
1211
|
- app/lib/katello/util/cdn_var_substitutor.rb
|
1212
|
+
- app/lib/katello/util/content_overrides_migrator.rb
|
1211
1213
|
- app/lib/katello/util/data.rb
|
1212
1214
|
- app/lib/katello/util/deduplication_migrator.rb
|
1213
1215
|
- app/lib/katello/util/docker_manifest_clause_generator.rb
|