Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Created April 22, 2015 21:30
Show Gist options
  • Select an option

  • Save daviddavis/701021efee12312a3e58 to your computer and use it in GitHub Desktop.

Select an option

Save daviddavis/701021efee12312a3e58 to your computer and use it in GitHub Desktop.
def cleanup_host_delete_artifacts
# clean up dirty consumer data in candleplin,
# that did not get cleared by host delete.
# look at https://bugzilla.redhat.com/show_bug.cgi?id=1140653
# for more information
cp_consumers = ::Katello::Resources::Candlepin::Consumer.get({})
cp_consumer_ids = cp_consumers.map {|cons| cons["uuid"]}
katello_consumer_ids = ::Katello::System.pluck(:uuid)
deletable_ids = cp_consumer_ids - katello_consumer_ids
deletable_ids.each do |consumer_id|
begin
Katello::Resources::Candlepin::Consumer.destroy(consumer_id)
rescue RestClient::Exception => e
p "exception when destroying candlepin consumer #{consumer_id}:#{e.inspect}"
end
begin
Katello.pulp_server.extensions.consumer.delete(consumer_id)
rescue RestClient::ResourceNotFound => e
#do nothing
rescue RestClient::Exception => e
p "exception when destroying pulp consumer #{consumer_id}:#{e.inspect}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment