Project

General

Profile

« Previous | Next » 

Revision b9eb2179

Added by Samir Jha over 4 years ago

Fixes #28839 - Reset pulpcore db with reset

View differences:

hooks/boot/01-kafo-hook-extensions.rb
end
def local_redis?
(foreman_server? && !param_value('foreman', 'jobs_sidekiq_redis_url')) || param_value('foreman_proxy::plugin::pulp', 'pulpcore_enabled') || devel_scenario?
(foreman_server? && !param_value('foreman', 'jobs_sidekiq_redis_url')) || pulpcore_enabled? || devel_scenario?
end
def pulpcore_enabled?
param_value('foreman_proxy_plugin_pulp', 'pulpcore_enabled')
end
def needs_postgresql_scl_upgrade?
katello/hooks/pre/10-reset_feature.rb
reset_database
reset_candlepin
reset_pulp
reset_pulpcore if pulpcore_enabled?
else
Kafo::KafoConfigure.logger.warn 'Katello not installed yet, can not drop database!'
......
)
end
def load_pulpcore_config
db_config = {}
db_config[:host] = param_value('foreman_proxy_content', 'pulpcore_postgresql_host') || 'localhost'
db_config[:port] = param_value('foreman_proxy_content', 'pulpcore_postgresql_port') || 5432
db_config[:database] = param_value('foreman_proxy_content', 'pulpcore_postgresql_db_name') || 'pulpcore'
db_config[:username] = param_value('foreman_proxy_content', 'pulpcore_postgresql_user')
db_config[:password] = param_value('foreman_proxy_content', 'pulpcore_postgresql_password')
db_config
end
def reset_pulpcore
Kafo::KafoConfigure.logger.info 'Dropping Pulpcore database!'
config = load_pulpcore_config
if remote_host?(config[:host])
empty_database!(config)
else
execute("sudo -u postgres dropdb #{config[:database]}")
end
end
def remote_host?(hostname)
!['localhost', '127.0.0.1', `hostname`.strip].include?(hostname)
end

Also available in: Unified diff