Sha256: 9ca643252a932eacc5a9cc8cb24829660e16a41bdaea1bacd6f126530c642135

Contents?: true

Size: 1.1 KB

Versions: 38

Compression:

Stored size: 1.1 KB

Contents

# Before 3.8, you could successfully edit only the username, or only the
# password, but since we added a validation now those old repos are now
# invalid.  This finds those repos and clears their credentials.

namespace :katello do
  namespace :upgrades do
    namespace '3.10' do
      desc "Clear invalid credentials for repositories"
      task :clear_invalid_repo_credentials => %w(environment) do
        User.current = User.anonymous_admin

        # Where one, but not both, is set
        root_repos = Katello::RootRepository.where('(upstream_username IS NULL AND upstream_password is NOT NULL) OR (upstream_username IS NOT NULL AND upstream_password is NULL)')

        root_repos.each do |root_repo|
          puts "Clearing invalid credentials for #{root_repo.label} (#{root_repo.id})"
          root_repo.update(upstream_username: nil, upstream_password: nil)

          root_repo.repositories.each do |repo|
            puts "Refreshing repository #{repo.label} (#{repo.id})"
            ForemanTasks.sync_task(::Actions::Pulp::Repository::Refresh, repo)
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
katello-3.18.5 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.4 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.3.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.3 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-4.0.0.rc3 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.2.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.17.3 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-4.0.0.rc2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.1.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.17.2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-4.0.0.rc1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.0 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.17.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.16.2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.0.rc2.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.0.rc2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.17.0 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.18.0.rc1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake