Ceilometer: Add support for oslo.cache parameters
... and ensures memcached backend is set according to the deployment
architecture automatically.
Conflicts:
manifests/profile/base/ceilometer.pp
Change-Id: I4c89ce09c7da33254cc01f2b5b1f8c3c7bd8a9b6
(cherry picked from commit 6af76714f6)
This commit is contained in:
committed by
Yadnesh Kulkarni
parent
3845de2f03
commit
40278e101e
@@ -71,6 +71,22 @@
|
|||||||
# Enable ssl oslo messaging services
|
# Enable ssl oslo messaging services
|
||||||
# Defaults to hiera('oslo_messaging_notify_use_ssl', '0')
|
# Defaults to hiera('oslo_messaging_notify_use_ssl', '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 (
|
class tripleo::profile::base::ceilometer (
|
||||||
$step = Integer(hiera('step')),
|
$step = Integer(hiera('step')),
|
||||||
$oslomsg_rpc_proto = hiera('oslo_messaging_rpc_scheme', 'rabbit'),
|
$oslomsg_rpc_proto = hiera('oslo_messaging_rpc_scheme', 'rabbit'),
|
||||||
@@ -85,11 +101,35 @@ class tripleo::profile::base::ceilometer (
|
|||||||
$oslomsg_notify_port = hiera('oslo_messaging_notify_port', '5672'),
|
$oslomsg_notify_port = hiera('oslo_messaging_notify_port', '5672'),
|
||||||
$oslomsg_notify_username = hiera('oslo_messaging_notify_user_name', 'guest'),
|
$oslomsg_notify_username = hiera('oslo_messaging_notify_user_name', 'guest'),
|
||||||
$oslomsg_notify_use_ssl = hiera('oslo_messaging_notify_use_ssl', '0'),
|
$oslomsg_notify_use_ssl = hiera('oslo_messaging_notify_use_ssl', '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 {
|
if $step >= 3 {
|
||||||
$oslomsg_rpc_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_rpc_use_ssl)))
|
$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)))
|
$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' :
|
class { 'ceilometer' :
|
||||||
default_transport_url => os_transport_url({
|
default_transport_url => os_transport_url({
|
||||||
'transport' => $oslomsg_rpc_proto,
|
'transport' => $oslomsg_rpc_proto,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ describe 'tripleo::profile::base::ceilometer' do
|
|||||||
it 'should do nothing' do
|
it 'should do nothing' do
|
||||||
is_expected.to contain_class('tripleo::profile::base::ceilometer')
|
is_expected.to contain_class('tripleo::profile::base::ceilometer')
|
||||||
is_expected.to_not contain_class('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::config')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -39,10 +40,68 @@ describe 'tripleo::profile::base::ceilometer' do
|
|||||||
is_expected.to contain_class('ceilometer').with(
|
is_expected.to contain_class('ceilometer').with(
|
||||||
:default_transport_url => 'rabbit://ceilometer:foo@127.0.0.1:5672/?ssl=0'
|
: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::config')
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user