add config for caching metadata in memory

* add config metadata_memory_cache_ttl to enable caching metadata
in memory
* set default to 5 as project neutron/master

Change-Id: Ib6a05ae5033c53c4196f736373752370012d82a6
This commit is contained in:
Tri Hoang Vo 2014-10-15 11:43:33 +02:00
parent d65ffe07d3
commit 7babb4f417
2 changed files with 33 additions and 14 deletions

View File

@ -60,24 +60,32 @@
# (optional) Number of backlog requests to configure the metadata server socket with.
# Defaults to 4096
#
# [*metadata_memory_cache_ttl*]
# (optional) Specifies time in seconds a metadata cache entry is valid in
# memory caching backend.
# Set to 0 will cause cache entries to never expire.
# Set to undef or false to disable cache.
# Defaults to 5
#
class neutron::agents::metadata (
$auth_password,
$shared_secret,
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
$debug = false,
$auth_tenant = 'services',
$auth_user = 'neutron',
$auth_url = 'http://localhost:35357/v2.0',
$auth_insecure = false,
$auth_ca_cert = undef,
$auth_region = 'RegionOne',
$metadata_ip = '127.0.0.1',
$metadata_port = '8775',
$metadata_workers = $::processorcount,
$metadata_backlog = '4096'
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
$debug = false,
$auth_tenant = 'services',
$auth_user = 'neutron',
$auth_url = 'http://localhost:35357/v2.0',
$auth_insecure = false,
$auth_ca_cert = undef,
$auth_region = 'RegionOne',
$metadata_ip = '127.0.0.1',
$metadata_port = '8775',
$metadata_workers = $::processorcount,
$metadata_backlog = '4096',
$metadata_memory_cache_ttl = 5,
) {
include neutron::params
@ -101,6 +109,16 @@ class neutron::agents::metadata (
'DEFAULT/metadata_backlog': value => $metadata_backlog;
}
if $metadata_memory_cache_ttl {
neutron_metadata_agent_config {
'DEFAULT/cache_url': value => "memory://?default_ttl=${metadata_memory_cache_ttl}";
}
} else {
neutron_metadata_agent_config {
'DEFAULT/cache_url': ensure => absent;
}
}
if $auth_ca_cert {
neutron_metadata_agent_config {
'DEFAULT/auth_ca_cert': value => $auth_ca_cert;

View File

@ -60,6 +60,7 @@ describe 'neutron::agents::metadata' do
should contain_neutron_metadata_agent_config('DEFAULT/metadata_workers').with(:value => facts[:processorcount])
should contain_neutron_metadata_agent_config('DEFAULT/metadata_backlog').with(:value => params[:metadata_backlog])
should contain_neutron_metadata_agent_config('DEFAULT/metadata_proxy_shared_secret').with(:value => params[:shared_secret])
should contain_neutron_metadata_agent_config('DEFAULT/cache_url').with(:value => 'memory://?default_ttl=5')
end
end