Add a new parameter named cache_server_url

If you want to use horizon with a different cacheing backend you
may run into problems. E.g. with redis it expects a database after
the port.
So introducing a new parameter which allows any string as LOCATION
solves this problem and maybe a couple of others.

Change-Id: Ida54599049f69573d27f477c395f14ae0ec26c3c
This commit is contained in:
Christoph Manns 2018-06-18 16:41:03 +02:00
parent 80bdd47754
commit 7846563132
3 changed files with 30 additions and 0 deletions

View File

@ -35,6 +35,11 @@
# (optional) A hash of parameters to enable specific cache options.
# Defaults to undef
#
# [*cache_server_url*]
# (optional) URL of a cache server.
# This allows arbitary strings to be set as CACHE BACKEND LOCATION.
# Defaults to undef.
#
# [*cache_server_ip*]
# (optional) Memcached IP address. Can be a string, or an array.
# Defaults to undef.
@ -426,6 +431,7 @@ class horizon(
$package_ensure = 'present',
$cache_backend = 'django.core.cache.backends.locmem.LocMemCache',
$cache_options = undef,
$cache_server_url = undef,
$cache_server_ip = undef,
$cache_server_port = '11211',
$horizon_app_links = false,
@ -498,6 +504,10 @@ class horizon(
include ::horizon::deps
if $cache_server_url and $cache_server_ip {
fail('Only one of cache_server_url or cache_server_ip can be set.')
}
$hypervisor_defaults = {
'can_set_mount_point' => true,
'can_set_password' => false,

View File

@ -242,6 +242,23 @@ describe 'horizon' do
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url' do
before do
params.merge!({
:cache_server_url => 'redis://:password@10.0.0.1:6379/1',
})
end
it 'generates local_settings.py' do
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
" 'LOCATION': 'redis://:password@10.0.0.1:6379/1',",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'installs python memcache library when cache_backend is set to memcache' do
before do
params.merge!({

View File

@ -226,6 +226,9 @@ CACHES = {
'LOCATION': '<%= @cache_server_ip %>:<%= @cache_server_port %>',
<% end %>
<% end %>
<% if @cache_server_url %>
'LOCATION': '<%= @cache_server_url %>',
<% end %>
}
}