Sha256: 61ebd680cc464dbc32fb846e3d2e59c18a5b140e8f0d6e12253a6d1b66f7588c

Contents?: true

Size: 1.09 KB

Versions: 185

Compression:

Stored size: 1.09 KB

Contents

namespace :katello do
  desc "Cleans up file repos that were moved to /pulp/isos/<org name>/"
  task :clean_old_file_repos => ['environment'] do
    User.current = User.anonymous_admin
    PUB_DIR = '/var/www/pub'.freeze
    SCRIPT_PATH = '/tmp/delete_old_file_repos.sh'.freeze
    delete = []

    %w(http https).each do |proto|
      dir = "#{PUB_DIR}/#{proto}/isos/"
      if File.directory?(dir)
        Dir.foreach(dir) do |entry|
          # If directory is a file repo, then it was published using
          # the UUID.  It's a target for deletion.
          if (repo = Katello::Repository.find_by(pulp_id: File.basename(entry)))
            if repo.content_type == Katello::Repository::FILE_TYPE
              delete << "#{dir}#{entry}"
            end
          end
        end
      end
    end

    if delete.empty?
      puts "There are no directories to delete."
    else
      open(SCRIPT_PATH, 'w') { |f| f << "rm -rf #{delete.join " \\\n "}\n" }
      puts "To clean up the directories, please run the following as root:\n# bash #{SCRIPT_PATH}"
    end

    puts "Rake task completed."
  end
end

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
katello-4.0.1.2 lib/katello/tasks/clean_old_file_repos.rake
katello-3.18.3.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.1.0.rc2.2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.1.0.rc2.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.1.1 lib/katello/tasks/clean_old_file_repos.rake
katello-3.18.3 lib/katello/tasks/clean_old_file_repos.rake
katello-4.1.0.rc2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.1.0.rc1.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.1.0.rc1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.0 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.0.rc3.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.0.rc3 lib/katello/tasks/clean_old_file_repos.rake
katello-3.18.2.1 lib/katello/tasks/clean_old_file_repos.rake
katello-3.18.2 lib/katello/tasks/clean_old_file_repos.rake
katello-3.17.3 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.0.rc2 lib/katello/tasks/clean_old_file_repos.rake
katello-3.18.1.1 lib/katello/tasks/clean_old_file_repos.rake
katello-3.17.2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.0.0.rc1 lib/katello/tasks/clean_old_file_repos.rake