Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 "'#{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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement