Skip to content

Commit

Permalink
Fixes #37131 - Migrate all organizations to SCA (Katello#10875)
Browse files Browse the repository at this point in the history
* Fixes #37131 - Migrate all organizations to SCA
  - Add upgrade rake task to migrate all organizations to SCA on upgrade
  - Add dry run option to rake task
  - Update content access mode list for all orgs so that entitlement mode is
    not allowed

* Refs #37131 - rerecord VCRs
  • Loading branch information
jeremylenz authored Feb 2, 2024
1 parent da4a68d commit 16cbea2
Show file tree
Hide file tree
Showing 15 changed files with 3,034 additions and 2,767 deletions.
4 changes: 2 additions & 2 deletions app/lib/katello/resources/candlepin/owner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create(key, description, content_access_mode: 'org_environment')
:displayName => description,
:contentPrefix => "/#{key}/$env",
:contentAccessMode => content_access_mode,
:contentAccessModeList => ['entitlement', 'org_environment'].join(',')
:contentAccessModeList => 'org_environment'
}
owner_json = self.post(path, attrs.to_json, self.default_headers).body
JSON.parse(owner_json).with_indifferent_access
Expand All @@ -42,7 +42,7 @@ def find(key)
def update(key, attrs)
owner = find(key)
owner.merge!(attrs)
owner.merge!(:contentAccessModeList => ['entitlement', 'org_environment'].join(','))
owner.merge!(:contentAccessModeList => 'org_environment')
self.put(path(key), JSON.generate(owner), self.default_headers).body
end

Expand Down
3 changes: 2 additions & 1 deletion db/seeds.d/111-upgrade_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{:name => 'katello:upgrades:4.2:remove_checksum_values'},
{:name => 'katello:upgrades:4.4:publish_import_cvvs'},
{:name => 'katello:upgrades:4.8:fix_incorrect_providers'},
{:name => 'katello:upgrades:4.8:regenerate_imported_repository_metadata'}
{:name => 'katello:upgrades:4.8:regenerate_imported_repository_metadata'},
{:name => 'katello:upgrades:4.12:update_content_access_modes'}
]
end
35 changes: 35 additions & 0 deletions lib/katello/tasks/upgrades/4.12/update_content_access_modes.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace :katello do
namespace :upgrades do
namespace '4.12' do
desc "Update content access modes for all organizations"
task :update_content_access_modes, [:commit] => ["environment"] do |_t, args|
# make sure Candlepin is running
print "Checking Candlepin status\n"
Katello::Ping.ping!(services: [:candlepin])

# To run without committing changes, use:
# foreman-rake katello:upgrades:4.12:update_content_access_modes[dry_run]
commit = !(args[:commit].to_s == 'dry_run')
msg_word = commit ? "Setting" : "Checking"
print "#{msg_word} content access modes\n"
migrated_orgs_count = 0
Organization.all.each do |org|
next if org.simple_content_access?

print "#{msg_word} content access mode for #{org.name}\n"
migrated_orgs_count += 1
if commit
::Katello::Resources::Candlepin::Owner.update(org.label, contentAccessMode: 'org_environment')
end
end
print "----------------------------------------\n"
if commit
print "Set content access mode for #{migrated_orgs_count} organizations\n"
else
print "#{migrated_orgs_count} organizations would be migrated to Simple Content Access on upgrade\n"
end
print "----------------------------------------\n"
end
end
end
end
358 changes: 177 additions & 181 deletions test/fixtures/vcr_cassettes/katello/certs/verify_ueber_cert_changes.yml

Large diffs are not rendered by default.

399 changes: 197 additions & 202 deletions test/fixtures/vcr_cassettes/katello/certs/verify_ueber_cert_no_change.yml

Large diffs are not rendered by default.

Loading

0 comments on commit 16cbea2

Please sign in to comment.