Sha256: 7b885a6ad376b1617b03f6f32a1b2ed7474c2dd73e5bdc4ee324bad46bee8da2

Contents?: true

Size: 1.76 KB

Versions: 16

Compression:

Stored size: 1.76 KB

Contents

namespace :katello do
  namespace :upgrades do
    namespace '3.8' do
      desc "Clear checksum type for on-demand repositories"
      task :clear_checksum_type => %w(environment) do
        User.current = User.anonymous_admin

        Katello::RootRepository.yum_type.find_each do |root_repo|
          root_repo.transaction do
            if [::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND, ::Runcible::Models::YumImporter::DOWNLOAD_BACKGROUND].include?(root_repo.download_policy) && root_repo.url.present? && URI(root_repo.url).scheme == 'file'
              root_repo.update_attribute(:download_policy, ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE)
              root_repo.repositories.each do |repo|
                importer = repo.importers[0]
                config = {
                  :download_policy => ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE
                }

                SmartProxy.pulp_master.pulp_api.resources.repository.update_importer(repo.pulp_id, importer[:id], config) if (importer && importer[:id])
              end
            end

            if root_repo.on_demand? && root_repo.url.present?
              root_repo.update_attribute(:checksum_type, nil)

              root_repo.repositories.each do |repo|
                repo.update_attribute(:saved_checksum_type, nil)

                if repo.find_distributor[:config]&.delete(:checksum_type)
                  SmartProxy.pulp_master.pulp_api.resources.repository.update_distributor(
                    repo.pulp_id, repo.find_distributor[:id], repo.find_distributor[:config])
                end
              # rubocop:disable Lint/SuppressedException
              rescue RestClient::ResourceNotFound
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
katello-3.16.2 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.1.2 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.1.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.17.0.rc1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc5.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc5 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc4.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc4 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc3.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc3 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc2.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc2 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc1.1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake
katello-3.16.0.rc1 lib/katello/tasks/upgrades/3.8/clear_checksum_type.rake