Ceilometer: Add support for oslo.cache parameters
... and ensures memcached backend is set according to the deployment architecture automatically. Change-Id: I4c89ce09c7da33254cc01f2b5b1f8c3c7bd8a9b6
This commit is contained in:
@@ -71,6 +71,22 @@
|
||||
# Enable ssl oslo messaging services
|
||||
# Defaults to lookup('oslo_messaging_notify_use_ssl', undef, undef, '0')
|
||||
#
|
||||
# [*memcached_hosts*]
|
||||
# (Optional) Array of hostnames, ipv4 or ipv6 addresses for memcache.
|
||||
# Defaults to lookup('memcached_node_names', undef, undef, [])
|
||||
#
|
||||
# [*memcached_port*]
|
||||
# (Optional) Memcached port to use.
|
||||
# Defaults to lookup('memcached_port', undef, undef, 11211)
|
||||
#
|
||||
# [*memcached_ipv6*]
|
||||
# (Optional) Whether Memcached uses IPv6 network instead of IPv4 network.
|
||||
# Defauls to lookup('memcached_ipv6', undef, undef, false)
|
||||
#
|
||||
# [*cache_backend*]
|
||||
# (Optional) oslo.cache backend used for caching.
|
||||
# Defaults to lookup('ceilometer::cache::backend', undef, undef, false)
|
||||
#
|
||||
class tripleo::profile::base::ceilometer (
|
||||
$step = Integer(lookup('step')),
|
||||
$oslomsg_rpc_proto = lookup('oslo_messaging_rpc_scheme', undef, undef, 'rabbit'),
|
||||
@@ -85,11 +101,35 @@ class tripleo::profile::base::ceilometer (
|
||||
$oslomsg_notify_port = lookup('oslo_messaging_notify_port', undef, undef, '5672'),
|
||||
$oslomsg_notify_username = lookup('oslo_messaging_notify_user_name', undef, undef, 'guest'),
|
||||
$oslomsg_notify_use_ssl = lookup('oslo_messaging_notify_use_ssl', undef, undef, '0'),
|
||||
$memcached_hosts = lookup('memcached_node_names', undef, undef, []),
|
||||
$memcached_port = lookup('memcached_port', undef, undef, 11211),
|
||||
$memcached_ipv6 = lookup('memcached_ipv6', undef, undef, false),
|
||||
$cache_backend = lookup('ceilometer::cache::backend', undef, undef, false),
|
||||
) {
|
||||
|
||||
$memcached_hosts_real = any2array($memcached_hosts)
|
||||
|
||||
if $step >= 3 {
|
||||
$oslomsg_rpc_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_rpc_use_ssl)))
|
||||
$oslomsg_notify_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_notify_use_ssl)))
|
||||
|
||||
if $memcached_ipv6 or $memcached_hosts_real[0] =~ Stdlib::Compat::Ipv6 {
|
||||
if $cache_backend in ['oslo_cache.memcache_pool', 'dogpile.cache.memcached'] {
|
||||
# NOTE(tkajinm): The inet6 prefix is required for backends using
|
||||
# python-memcached
|
||||
$cache_memcache_servers = $memcached_hosts_real.map |$server| { "inet6:[${server}]:${memcached_port}" }
|
||||
} else {
|
||||
# NOTE(tkajinam): The other backends like pymemcache don't require
|
||||
# the inet6 prefix
|
||||
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
|
||||
}
|
||||
} else {
|
||||
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
|
||||
}
|
||||
class { 'ceilometer::cache':
|
||||
memcache_servers => $cache_memcache_servers
|
||||
}
|
||||
|
||||
class { 'ceilometer' :
|
||||
default_transport_url => os_transport_url({
|
||||
'transport' => $oslomsg_rpc_proto,
|
||||
|
||||
@@ -23,6 +23,7 @@ describe 'tripleo::profile::base::ceilometer' do
|
||||
it 'should do nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::ceilometer')
|
||||
is_expected.to_not contain_class('ceilometer')
|
||||
is_expected.to_not contain_class('ceilometer::cache')
|
||||
is_expected.to_not contain_class('ceilometer::config')
|
||||
is_expected.to_not contain_class('ceilometer::db')
|
||||
end
|
||||
@@ -30,8 +31,8 @@ describe 'tripleo::profile::base::ceilometer' do
|
||||
|
||||
context 'with step 3' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:oslomsg_rpc_hosts => [ '127.0.0.1' ],
|
||||
:step => 3,
|
||||
:oslomsg_rpc_hosts => [ '127.0.0.1' ],
|
||||
:oslomsg_rpc_username => 'ceilometer',
|
||||
:oslomsg_rpc_password => 'foo',
|
||||
} }
|
||||
@@ -40,11 +41,69 @@ describe 'tripleo::profile::base::ceilometer' do
|
||||
is_expected.to contain_class('ceilometer').with(
|
||||
:default_transport_url => 'rabbit://ceilometer:foo@127.0.0.1:5672/?ssl=0'
|
||||
)
|
||||
is_expected.to contain_class('ceilometer::cache').with(
|
||||
:memcache_servers => ['controller-1:11211']
|
||||
)
|
||||
is_expected.to contain_class('ceilometer::config')
|
||||
is_expected.to contain_class('ceilometer::db')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 3 and memcache ipv6' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:memcached_hosts => '::1',
|
||||
} }
|
||||
|
||||
it 'should format the memcache_server parameter' do
|
||||
is_expected.to contain_class('ceilometer::cache').with(
|
||||
:memcache_servers => ['[::1]:11211']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 3 and memcache ipv6 and memcached backend' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:memcached_hosts => '::1',
|
||||
:cache_backend => 'dogpile.cache.memcached',
|
||||
} }
|
||||
|
||||
it 'should format the memcache_server parameter' do
|
||||
is_expected.to contain_class('ceilometer::cache').with(
|
||||
:memcache_servers => ['inet6:[::1]:11211']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 3 and the ipv6 parameter' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:memcached_hosts => 'node.example.com',
|
||||
:memcached_ipv6 => true,
|
||||
} }
|
||||
|
||||
it 'should format the memcache_server parameter' do
|
||||
is_expected.to contain_class('ceilometer::cache').with(
|
||||
:memcache_servers => ['node.example.com:11211']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 3 and the ipv6 parameter and memcached backend' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:memcached_hosts => 'node.example.com',
|
||||
:memcached_ipv6 => true,
|
||||
:cache_backend => 'dogpile.cache.memcached',
|
||||
} }
|
||||
|
||||
it 'should format the memcache_server parameter' do
|
||||
is_expected.to contain_class('ceilometer::cache').with(
|
||||
:memcache_servers => ['inet6:[node.example.com]:11211']
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user