Implement zaqar::init class

This configure high level (non-driver) settings for zaqar
in addition to keystone auth settings.

Change-Id: Iec49c7aca993fcb44e89d27b17c0aaadb24452d9
This commit is contained in:
Dan Prince 2016-02-11 14:18:31 -05:00
parent fa9218c4cd
commit a5a474d4d8
3 changed files with 158 additions and 3 deletions

View File

@ -4,7 +4,79 @@
#
# === Parameters
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# [*auth_uri*]
# Specifies the public Identity URI for Zaqar to use.
# Default 'http://localhost:5000/'
#
class zaqar {}
# [*identity_uri*]
# Specifies the admin Identity URI for Zaqar to use.
# Default 'http://localhost:35357/'
#
# [*admin_user*]
# The user name from 'zaqar::keystone::auth'. Default 'zaqar'
#
# [*admin_tenant_name*]
# The tenant name from 'zaqar::keystone::auth'. Default 'services'
#
# [*admin_password*]
# The password from 'zaqar::keystone::auth'. Default 'password'
#
# [*auth_strategy*]
# Backend to use for authentication. For no auth, keep it empty.
# Default 'keystone'.
#
# [*admin_mode*]
# Activate privileged endpoints. (boolean value)
# Default false
#
# [*pooling*]
# Enable pooling across multiple storage backends. If pooling is
# enabled, the storage driver configuration is used to determine where
# the catalogue/control plane data is kept. (boolean value)
# Default false
#
# [*unreliable*]
# Disable all reliability constraints. (boolean value)
# Default false
#
# [*package_name*]
# (Optional) Package name to install for zaqar.
# Defaults to $::zaqar::params::package_name
#
# [*package_ensure*]
# (Optional) Ensure state for package.
# Defaults to present.
#
class zaqar(
$admin_password,
$auth_uri = 'http://localhost:5000/',
$identity_uri = 'http://localhost:35357/',
$admin_user = 'zaqar',
$admin_tenant_name = 'services',
$auth_strategy = 'keystone',
$admin_mode = $::os_service_default,
$unreliable = $::os_service_default,
$pooling = $::os_service_default,
$package_name = $::zaqar::params::package_name,
$package_ensure = 'present',
) inherits zaqar::params {
package { 'zaqar-common':
ensure => $package_ensure,
name => $package_name,
tag => ['openstack', 'zaqar-package'],
}
zaqar_config {
'keystone_authtoken/auth_uri' : value => $auth_uri;
'keystone_authtoken/identity_uri' : value => $identity_uri;
'keystone_authtoken/admin_user' : value => $admin_user;
'keystone_authtoken/admin_password' : value => $admin_password;
'keystone_authtoken/admin_tenant_name' : value => $admin_tenant_name;
'DEFAULT/auth_strategy' : value => $auth_strategy;
'DEFAULT/admin_mode' : value => $admin_mode;
'DEFAULT/unreliable' : value => $unreliable;
'DEFAULT/pooling' : value => $pooling;
}
}

22
manifests/params.pp Normal file
View File

@ -0,0 +1,22 @@
# == Class: zaqar::params
#
# Parameters for puppet-zaqar
#
class zaqar::params {
$client_package = 'python-zaqarclient'
case $::osfamily {
'RedHat': {
$package_name = 'openstack-zaqar'
$service_name = 'openstack-zaqar'
}
'Debian': {
$package_name = 'zaqar'
$service_name = 'zaqar'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: \
${::operatingsystem}, module ${module_name} only support osfamily \
RedHat and Debian")
}
}
}

View File

@ -0,0 +1,61 @@
require 'spec_helper'
describe 'zaqar' do
let :req_params do
{
:admin_password => 'foo',
}
end
let :facts do
{ :osfamily => 'RedHat' }
end
describe 'with only required params' do
let :params do
req_params
end
it { is_expected.to contain_package('zaqar-common').with(
:ensure => 'present',
:name => 'openstack-zaqar'
)}
it { is_expected.to contain_class('zaqar::params') }
it 'should contain default config' do
is_expected.to contain_zaqar_config('keystone_authtoken/auth_uri').with(
:value => 'http://localhost:5000/'
)
is_expected.to contain_zaqar_config('keystone_authtoken/identity_uri').with(
:value => 'http://localhost:35357/'
)
is_expected.to contain_zaqar_config('keystone_authtoken/admin_tenant_name').with(
:value => 'services'
)
is_expected.to contain_zaqar_config('keystone_authtoken/admin_user').with(
:value => 'zaqar'
)
is_expected.to contain_zaqar_config('keystone_authtoken/admin_password').with(
:value => 'foo'
)
end
end
describe 'with custom values' do
let :params do
req_params.merge!({
:admin_mode => true,
:unreliable => true,
:pooling => true
})
end
it do
is_expected.to contain_zaqar_config('DEFAULT/admin_mode').with_value(true)
is_expected.to contain_zaqar_config('DEFAULT/unreliable').with_value(true)
is_expected.to contain_zaqar_config('DEFAULT/pooling').with_value(true)
end
end
end