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.13.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.13.0 lib/katello/tasks/clean_old_file_repos.rake
katello-4.12.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.13.0.rc1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.12.0 lib/katello/tasks/clean_old_file_repos.rake
katello-4.12.0.rc3 lib/katello/tasks/clean_old_file_repos.rake
katello-4.12.0.rc2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.12.0.rc1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.11.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.11.0 lib/katello/tasks/clean_old_file_repos.rake
katello-4.11.0.rc2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.11.0.rc1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.10.0 lib/katello/tasks/clean_old_file_repos.rake
katello-4.9.2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.10.0.rc2 lib/katello/tasks/clean_old_file_repos.rake
katello-4.10.0.rc1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.8.4 lib/katello/tasks/clean_old_file_repos.rake
katello-4.9.1 lib/katello/tasks/clean_old_file_repos.rake
katello-4.8.3 lib/katello/tasks/clean_old_file_repos.rake
katello-4.9.0 lib/katello/tasks/clean_old_file_repos.rake