Sha256: cde353dfc080e0f13ee8046bd534a79477d79e9215ab8beea95c02507aff50be

Contents?: true

Size: 1.34 KB

Versions: 33

Compression:

Stored size: 1.34 KB

Contents

namespace :katello do
  namespace :upgrades do
    namespace '3.11' do
      def wait_on_task(task, time = 0.1)
        task = SmartProxy.pulp_master.pulp_api.resources.task.poll(task['task_id'])
        return if Actions::Pulp::AbstractAsyncTask::FINISHED_STATES.include?(task['state'])
        sleep time
        wait_on_task(task, time + 0.2)
      end

      desc "update puppet repos to regenerate pulp configuration"
      task :update_puppet_repos => %w(environment) do
        User.current = User.anonymous_admin
        Katello::Repository.puppet_type.each do |repo|
          begin
            puts "Refreshing repository #{repo.label} (#{repo.id})"
            install_dist = repo.backend_service(SmartProxy.pulp_master).backend_data['distributors'].find { |dist| dist['distributor_type_id'] == 'puppet_install_distributor' }
            if install_dist
              response = SmartProxy.pulp_master.pulp_api.resources.repository.delete_distributor(repo.pulp_id, install_dist['id'])
              wait_on_task('task_id' => response['spawned_tasks'][0]['task_id'])
            end
            ForemanTasks.sync_task(::Actions::Pulp::Repository::Refresh, repo)
          rescue RestClient::ResourceNotFound
            Rails.logger.warn("Recieved 404 on repository: #{repo.id} - #{repo.name}")
            next
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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