Add the base implementation for coordination parameters
This change introduces the oslo::coordination resource type, which can be used to manage paramaeters and packages used for coordination(tooz). Change-Id: I93ee3a37137232604aaa1532f4d46bf28264b677
This commit is contained in:
parent
d434f1b891
commit
475d6e8bbd
|
@ -0,0 +1,66 @@
|
|||
# == Define: oslo::coordination
|
||||
#
|
||||
# Setup and configure coordination settings.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*backend_url*]
|
||||
# (Optional) Coordination backend URL.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) ensure state for package.
|
||||
# Defaults to 'present'
|
||||
#
|
||||
define oslo::coordination (
|
||||
$backend_url = $::os_service_default,
|
||||
$package_ensure = 'present',
|
||||
) {
|
||||
|
||||
include oslo::params
|
||||
|
||||
if !is_service_default($backend_url) {
|
||||
case $backend_url {
|
||||
/^redis:\/\//: {
|
||||
ensure_packages('python-redis', {
|
||||
name => $::oslo::params::python_redis_package_name,
|
||||
ensure => $package_ensure,
|
||||
tag => 'openstack',
|
||||
})
|
||||
}
|
||||
/^etcd3\+http[s]?:\/\//: {
|
||||
ensure_packages('python-etcd3gw', {
|
||||
name => $::oslo::params::python_etcd3gw_package_name,
|
||||
ensure => $package_ensure,
|
||||
tag => 'openstack',
|
||||
})
|
||||
}
|
||||
/^etcd3:\/\//: {
|
||||
if $::oslo::params::python_etcd3_package_name {
|
||||
ensure_packages('python-etcd3', {
|
||||
name => $::oslo::params::python_etcd3_package_name,
|
||||
ensure => $package_ensure,
|
||||
tag => 'openstack',
|
||||
})
|
||||
} else {
|
||||
warning('The python-etcd3 package is not available.')
|
||||
}
|
||||
}
|
||||
/^memcached:\/\//: {
|
||||
ensure_packages('python-pymemcache', {
|
||||
name => $::oslo::params::python_pymemcache_package_name,
|
||||
ensure => $package_ensure,
|
||||
tag => 'openstack',
|
||||
})
|
||||
}
|
||||
default: {
|
||||
# Nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$coordination_options = {
|
||||
'coordination/backend_url' => { value => $backend_url },
|
||||
}
|
||||
create_resources($name, $coordination_options)
|
||||
}
|
|
@ -11,14 +11,22 @@ class oslo::params {
|
|||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$sqlite_package_name = undef
|
||||
$pymysql_package_name = undef
|
||||
$python_memcache_package_name = "python${pyvers}-memcached"
|
||||
$sqlite_package_name = undef
|
||||
$pymysql_package_name = undef
|
||||
$python_memcache_package_name = "python${pyvers}-memcached"
|
||||
$python_redis_package_name = "python${pyvers}-redis"
|
||||
$python_etcd3gw_package_name = "python${pyvers}-etcd3gw"
|
||||
$python_etcd3_package_name = undef
|
||||
$python_pymemcache_package_name = "python${pyvers}-pymemcache"
|
||||
}
|
||||
'Debian': {
|
||||
$sqlite_package_name = "python${pyvers}-pysqlite2"
|
||||
$pymysql_package_name = "python${pyvers}-pymysql"
|
||||
$python_memcache_package_name = "python${pyvers}-memcache"
|
||||
$sqlite_package_name = "python${pyvers}-pysqlite2"
|
||||
$pymysql_package_name = "python${pyvers}-pymysql"
|
||||
$python_memcache_package_name = "python${pyvers}-memcache"
|
||||
$python_redis_package_name = "python${pyvers}-redis"
|
||||
$python_etcd3gw_package_name = "python${pyvers}-etcd3gw"
|
||||
$python_etcd3_package_name = "python${pyvers}-etcd3"
|
||||
$python_pymemcache_package_name = "python${pyvers}-pymemcache"
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
The new ``oslo::coordination`` resource type has been added. This manages
|
||||
parameters for coordination which is implemented in the tooz library and
|
||||
backend packages required for each drivers.
|
|
@ -0,0 +1,127 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'oslo::coordination' do
|
||||
|
||||
let (:title) { 'keystone_config' }
|
||||
|
||||
shared_examples 'oslo::coordination' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'configures oslo_cache default params' do
|
||||
is_expected.to contain_keystone_config('coordination/backend_url').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with redis backend' do
|
||||
let :params do
|
||||
{ :backend_url => 'redis://localhost:6379' }
|
||||
end
|
||||
|
||||
it 'configures redis backend' do
|
||||
is_expected.to contain_keystone_config('coordination/backend_url').with_value('redis://localhost:6379')
|
||||
|
||||
is_expected.to contain_package('python-redis').with(
|
||||
:name => platform_params[:python_redis_package_name],
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with etcd3 backend' do
|
||||
let :params do
|
||||
{ :backend_url => 'etcd3://localhost:2379' }
|
||||
end
|
||||
|
||||
it 'configures etcd3gw backend' do
|
||||
is_expected.to contain_keystone_config('coordination/backend_url').with_value('etcd3://localhost:2379')
|
||||
|
||||
if platform_params[:python_etcd3_package_name]
|
||||
is_expected.to contain_package('python-etcd3').with(
|
||||
:name => platform_params[:python_etcd3_package_name],
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack',
|
||||
)
|
||||
else
|
||||
is_expected.to_not contain_package('python-etcd3')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with etcd3gw backend(http)' do
|
||||
let :params do
|
||||
{ :backend_url => 'etcd3+http://localhost:2379' }
|
||||
end
|
||||
|
||||
it 'configures etcd3gw backend' do
|
||||
is_expected.to contain_keystone_config('coordination/backend_url').with_value('etcd3+http://localhost:2379')
|
||||
is_expected.to contain_package('python-etcd3gw')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with etcd3gw backend(https)' do
|
||||
let :params do
|
||||
{ :backend_url => 'etcd3+https://localhost:2379' }
|
||||
end
|
||||
|
||||
it 'configures etcd3gw backend' do
|
||||
is_expected.to contain_keystone_config('coordination/backend_url').with_value('etcd3+https://localhost:2379')
|
||||
is_expected.to contain_package('python-etcd3gw')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with memcache backend' do
|
||||
let :params do
|
||||
{ :backend_url => 'memcached://localhost:11211' }
|
||||
end
|
||||
|
||||
it 'configures memcache backend' do
|
||||
is_expected.to contain_keystone_config('coordination/backend_url').with_value('memcached://localhost:11211')
|
||||
|
||||
is_expected.to contain_package('python-pymemcache').with(
|
||||
:name => platform_params[:python_pymemcache_package_name],
|
||||
:ensure => 'present',
|
||||
:tag => 'openstack',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
let(:platform_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
{ :python_redis_package_name => 'python3-redis',
|
||||
:python_etcd3_package_name => 'python3-etcd3',
|
||||
:python_etcd3gw_package_name => 'python3-etcd3gw',
|
||||
:python_pymemcache_package_name => 'python3-pymemcache' }
|
||||
when 'RedHat'
|
||||
if facts[:operatingsystem] == 'Fedora'
|
||||
{ :python_redis_package_name => 'python3-redis',
|
||||
:python_etcd3gw_package_name => 'python3-etcd3gw',
|
||||
:python_pymemcache_package_name => 'python3-pymemcache' }
|
||||
else
|
||||
if facts[:operatingsystemmajrelease] > '7'
|
||||
{ :python_redis_package_name => 'python3-redis',
|
||||
:python_etcd3gw_package_name => 'python3-etcd3gw',
|
||||
:python_pymemcache_package_name => 'python3-pymemcache' }
|
||||
else
|
||||
{ :python_redis_package_name => 'python-redis',
|
||||
:python_etcd3gw_package_name => 'python-etcd3gw',
|
||||
:python_pymemcache_package_name => 'python-pymemcache' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'oslo::coordination'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue