Last active
August 29, 2015 14:17
-
-
Save ehelms/52405ed3e75ec54ed91f to your computer and use it in GitHub Desktop.
Sync Schedule Removal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :list_active_sync_schedules => :environment do | |
User.current = User.first | |
products = Katello::Product.enabled.all | |
products.each do |product| | |
product.repositories.each do |repo| | |
schedules = Katello.pulp_server.resources.repository_schedule.list(repo.pulp_id, repo.importer_type) | |
if !schedules.empty? | |
puts schedules | |
puts "'#{repo.name}' in Product '#{product.name}' with product ID '#{product.id}' has #{schedules.length} sync plans attached to them" | |
end | |
end | |
end | |
end | |
task :cleanup_sync_schedules => :environment do | |
User.current = User.first | |
if ENV['product_id'] | |
product = Katello::Product.find(ENV['product_id']) | |
puts "Removing sync schedules for product: #{product.name}" | |
product.repositories.each do |repo| | |
repo.set_sync_schedule(nil) | |
end | |
product.sync_plan = nil | |
product.save! | |
else | |
puts "Please specify a product ID to remove sync schedules for (e.g. rake cleanup_sync_schedules product_id=1)" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment