Sha256: 92a0e0332ef9d1b8356a5060d142ae71e73fa1ba8ed292738e761fdda5ac783e

Contents?: true

Size: 1.11 KB

Versions: 39

Compression:

Stored size: 1.11 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_attributes(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

39 entries across 39 versions & 1 rubygems

Version Path
katello-3.15.3.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.3 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.1.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0.rc2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0.rc1.3 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0.rc1.2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0.rc1.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.15.0.rc1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.14.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.13.4 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.14.0 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.13.3 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.14.0.rc2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.13.2 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.14.0.rc1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake
katello-3.13.1 lib/katello/tasks/upgrades/3.10/clear_invalid_repo_credentials.rake