Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. task :list_active_sync_schedules => :environment do
  2.  
  3. User.current = User.first
  4. products = Katello::Product.enabled.all
  5. products.each do |product|
  6. product.repositories.each do |repo|
  7. schedules = Katello.pulp_server.resources.repository_schedule.list(repo.pulp_id, repo.importer_type)
  8. if !schedules.empty?
  9. puts "'#{repo.name}' in Product '#{product.name}' with product ID '#{product.id}' has #{schedules.length} sync plans attached to them"
  10. end
  11. end
  12. end
  13.  
  14. end
  15.  
  16. task :cleanup_sync_schedules => :environment do
  17.  
  18. User.current = User.first
  19.  
  20. if ENV['product_id']
  21. product = Katello::Product.find(ENV['product_id'])
  22.  
  23. puts "Removing sync schedules for product: #{product.name}"
  24. product.repositories.each do |repo|
  25. repo.set_sync_schedule(nil)
  26. end
  27. product.sync_plan = nil
  28. product.save!
  29. else
  30. puts "Please specify a product ID to remove sync schedules for (e.g. rake cleanup_sync_schedules product_id=1)"
  31. end
  32.  
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement