Adds Support for Separating Memcached from Horizon

Previously, memcached would always be included in the
openstack::horizon class.  Additionally, the cache_server_ip
parameter was used concurrently by memcached and horizon classes.
This prevented users from 1. Using an existing memcached deployment
2. Binding memcached to a local address and having
Horizon use an external memcached server.

This change implements the configure_memcached and memcached_listen_ip
parameters.  configure_memcached allows users to enable/disable
the memcached class on an as-needed basis.  memcached_listen_ip allows
users to seperate the IP address used for binding memcached from the
address used by Horizon to access memcached.

configure_memcached defaults to 'true' and memcached_listen_ip
defaults to undef for backwards compatibility and to enable memcached
and have memcached use cache_server_ip for binding an IP.

Change-Id: I5e4f4b5786d5ce7da59004a6a55b675a6dd32541
This commit is contained in:
danehans
2013-07-15 19:47:39 +00:00
parent ccf17d41dd
commit f47b877daf
2 changed files with 57 additions and 4 deletions

View File

@@ -14,6 +14,14 @@
# (required) A secret key for a particular Django installation. This is used to provide cryptographic signing,
# and should be set to a unique, unpredictable value.
#
# [*configure_memcached*]
# (optional) Enable/disable the use of memcached with Horizon.
# Defaults to true.
#
# [*memcached_listen_ip*]
# (optional) The IP address for binding memcached.
# Defaults to undef.
#
# [*cache_server_ip*]
# (optional) Ip address where the memcache server is listening.
# Defaults to '127.0.0.1'.
@@ -55,6 +63,8 @@
class openstack::horizon (
$secret_key,
$configure_memcached = true,
$memcached_listen_ip = undef,
$cache_server_ip = '127.0.0.1',
$cache_server_port = '11211',
$horizon_app_links = undef,
@@ -65,10 +75,18 @@ class openstack::horizon (
$api_result_limit = 1000
) {
class { 'memcached':
listen_ip => $cache_server_ip,
tcp_port => $cache_server_port,
udp_port => $cache_server_port,
if $configure_memcached {
if $memcached_listen_ip {
$cache_server_ip_real = $memcached_listen_ip
} else {
warning('The cache_server_ip parameter is deprecated. Use memcached_listen_ip instead.')
$cache_server_ip_real = $cache_server_ip
}
class { 'memcached':
listen_ip => $cache_server_ip_real,
tcp_port => $cache_server_port,
udp_port => $cache_server_port,
}
}
class { '::horizon':

View File

@@ -39,4 +39,39 @@ describe 'openstack::horizon' do
)
end
context 'when memcached is disabled' do
let :params do
required_params.merge(
:configure_memcached => false
)
end
it 'should configure horizon without memcached using default parameters and secret key' do
should_not contain_class('memcached')
should contain_class('horizon').with(
:cache_server_ip => '127.0.0.1',
:cache_server_port => '11211',
:secret_key => 'super_secret',
:horizon_app_links => false,
:keystone_host => '127.0.0.1',
:keystone_scheme => 'http',
:keystone_default_role => 'Member',
:django_debug => 'False',
:api_result_limit => 1000
)
end
end
context 'when memcached listen ip is overridden' do
let :params do
required_params.merge(
:configure_memcached => true,
:memcached_listen_ip => '10.10.10.10'
)
end
it 'should override params for memcached' do
should contain_class('memcached').with(
:listen_ip => '10.10.10.10'
)
end
end
end