refactor of cinder manifests

This commit refactors the cinder manifests to make
them more consistent with other manifests:

* removed default value for keystone_password
* removed the prefix cinder_ from class parameters
(it is redundant)
* set package_ensure defaults to present
* removed extra package_ensure parameter
* changed $iscsi_enabled to $volume_driver (this
change is being done in anticipation of needing
additional volume drivers)
* add test coverage
* simple updates to .gitignore
* refactor sql_connection to be composed of multiple class paramters
for consistency.

It also delete the openstack::cinder class b/c
I could not seem to declare ::cinder while it
existed.

Change-Id: I4a7b49d95957675be82c3b77958ae9d0c47eb4fa
This commit is contained in:
Daneyon Hansen
2013-05-14 18:52:49 +00:00
committed by Dan Bode
parent 336292278c
commit b4aa935eac
6 changed files with 192 additions and 87 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
spec/fixtures/modules/* spec/fixtures/modules/*
spec/fixtures/manifests/* spec/fixtures/manifests/*
*swp *swp
.vendor
Gemfile.lock

View File

@@ -1,27 +0,0 @@
class openstack::cinder(
$sql_connection,
$rabbit_password,
$rabbit_host = '127.0.0.1',
$volume_group = 'cinder-volumes',
$enabled = true
) {
warning('The "openstack::cinder" class is deprecated. Use "openstack::cinder::controller and openstack::cinder::volume" instead.')
class { 'cinder::base':
rabbit_password => $rabbit_password,
rabbit_host => $rabbit_host,
sql_connection => $sql_connection,
verbose => $verbose,
}
# Install / configure nova-volume
class { 'cinder::volume':
enabled => $enabled,
}
if $enabled {
class { 'cinder::volume::iscsi':
volume_group => $volume_group,
}
}
}

View File

@@ -1,43 +1,54 @@
class openstack::cinder::controller( class openstack::cinder::controller(
$cinder_sql_connection,
$rabbit_password, $rabbit_password,
$cinder_rpc_backend = 'cinder.openstack.common.rpc.impl_kombu', $keystone_password,
$keystone_tenant = 'services', $rpc_backend = 'cinder.openstack.common.rpc.impl_kombu',
$keystone_enabled = true, $keystone_tenant = 'services',
$keystone_user = 'cinder', $keystone_enabled = true,
$keystone_password = 'cinder', $keystone_user = 'cinder',
$keystone_auth_host = 'localhost', $keystone_auth_host = 'localhost',
$keystone_auth_port = '35357', $keystone_auth_port = '35357',
$keystone_auth_protocol = 'http', $keystone_auth_protocol = 'http',
$keystone_service_port = '5000', $keystone_service_port = '5000',
$rabbit_userid = 'guest', $rabbit_userid = 'guest',
$rabbit_host = '127.0.0.1', $rabbit_host = '127.0.0.1',
$rabbit_hosts = undef, $rabbit_hosts = undef,
$rabbit_port = '5672', $rabbit_port = '5672',
$cinder_rabbit_virtual_host = '/', $rabbit_virtual_host = '/',
$cinder_package_ensure = 'present', # Database. Currently mysql is the only option.
$cinder_api_package_ensure = 'latest', $db_type = 'mysql',
$cinder_scheduler_package_ensure = 'latest', $db_user = 'cinder',
$cinder_bind_host = '0.0.0.0', $db_password = 'cinder_pass',
$cinder_api_paste_config = '/etc/cinder/api-paste.ini', $db_host = '127.0.0.1',
$scheduler_driver = 'cinder.scheduler.simple.SimpleScheduler', $db_dbname = 'cinder',
$cinder_api_enabled = true, $package_ensure = present,
$cinder_scheduler_enabled = true, $api_package_ensure = present,
$cinder_verbose = 'False' $scheduler_package_ensure = present,
$bind_host = '0.0.0.0',
$api_paste_config = '/etc/cinder/api-paste.ini',
$scheduler_driver = 'cinder.scheduler.simple.SimpleScheduler',
$api_enabled = true,
$scheduler_enabled = true,
$verbose = false
) { ) {
####### DATABASE SETUP ######
# set up mysql server
if ($db_type == 'mysql') {
$sql_connection = "mysql://${db_user}:${db_password}@${db_host}/${db_dbname}?charset=utf8"
}
class {'::cinder': class {'::cinder':
sql_connection => $cinder_sql_connection, sql_connection => $sql_connection,
rpc_backend => $cinder_rpc_backend, rpc_backend => $rpc_backend,
rabbit_userid => $rabbit_userid, rabbit_userid => $rabbit_userid,
rabbit_password => $rabbit_password, rabbit_password => $rabbit_password,
rabbit_host => $rabbit_host, rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port, rabbit_port => $rabbit_port,
rabbit_hosts => $rabbit_hosts, rabbit_hosts => $rabbit_hosts,
rabbit_virtual_host => $cinder_rabbit_virtual_host, rabbit_virtual_host => $cinder_rabbit_virtual_host,
package_ensure => $cinder_package_ensure, package_ensure => $package_ensure,
api_paste_config => $cinder_api_paste_config, api_paste_config => $api_paste_config,
verbose => $cinder_verbose, verbose => $verbose,
} }
class {'::cinder::api': class {'::cinder::api':
@@ -48,15 +59,15 @@ class openstack::cinder::controller(
keystone_auth_port => $keystone_auth_port, keystone_auth_port => $keystone_auth_port,
keystone_auth_protocol => $keystone_auth_protocol, keystone_auth_protocol => $keystone_auth_protocol,
service_port => $keystone_service_port, service_port => $keystone_service_port,
package_ensure => $cinder_api_package_ensure, package_ensure => $api_package_ensure,
bind_host => $cinder_bind_host, bind_host => $bind_host,
enabled => $cinder_api_enabled, enabled => $api_enabled,
} }
class {'::cinder::scheduler': class {'::cinder::scheduler':
scheduler_driver => $scheduler_driver, scheduler_driver => $scheduler_driver,
package_ensure => $cinder_scheduler_package_ensure, package_ensure => $scheduler_package_ensure,
enabled => $cinder_scheduler_enabled, enabled => $scheduler_enabled,
} }
} }

View File

@@ -1,48 +1,50 @@
class openstack::cinder::storage( class openstack::cinder::storage(
$sql_connection, $sql_connection,
$rabbit_password, $rabbit_password,
$rabbit_userid = 'guest', $rabbit_userid = 'guest',
$rabbit_host = '127.0.0.1', $rabbit_host = '127.0.0.1',
$rabbit_hosts = undef, $rabbit_hosts = undef,
$rabbit_port = '5672', $rabbit_port = '5672',
$rabbit_virtual_host = '/', $rabbit_virtual_host = '/',
$cinder_package_ensure = 'present', $package_ensure = 'present',
$api_paste_config = '/etc/cinder/api-paste.ini', $api_paste_config = '/etc/cinder/api-paste.ini',
$cinder_package_ensure = 'latest', $volume_package_ensure = 'present',
$cinder_volume_package_ensure = 'latest', $volume_group = 'cinder-volumes',
$volume_group = 'cinder-volumes', $enabled = true,
$cinder_volume_enabled = true, $volume_driver = 'iscsi',
$iscsi_enabled = true, $iscsi_ip_address = '127.0.0.1',
$iscsi_ip_address = '127.0.0.1', $setup_test_volume = false,
$setup_test_volume = true, $verbose = false
$cinder_verbose = 'False',
) { ) {
class {'::cinder': class {'::cinder':
sql_connection => $cinder_sql_connection, sql_connection => $sql_connection,
rabbit_userid => $rabbit_userid, rabbit_userid => $rabbit_userid,
rabbit_password => $rabbit_password, rabbit_password => $rabbit_password,
rabbit_host => $rabbit_host, rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port, rabbit_port => $rabbit_port,
rabbit_hosts => $rabbit_hosts, rabbit_hosts => $rabbit_hosts,
rabbit_virtual_host => $rabbit_virtual_host, rabbit_virtual_host => $rabbit_virtual_host,
package_ensure => $cinder_package_ensure, package_ensure => $package_ensure,
api_paste_config => $cinder_api_paste_config, api_paste_config => $api_paste_config,
verbose => $cinder_verbose, verbose => $verbose,
} }
class { '::cinder::volume': class { '::cinder::volume':
package_ensure => $cinder_volume_package_ensure, package_ensure => $volume_package_ensure,
enabled => $cinder_volume_enabled, enabled => $enabled,
} }
if $iscsi_enabled {
class { '::cinder::volume::iscsi': if $volume_driver == 'iscsi' {
class { 'cinder::volume::iscsi':
iscsi_ip_address => $iscsi_ip_address, iscsi_ip_address => $iscsi_ip_address,
volume_group => $volume_group, volume_group => $volume_group,
} }
if $setup_test_volume {
class {'::cinder::setup_test_volume':}
}
} else {
warning("Unsupported volume driver: ${volume_driver}, make sure you are configuring this yourself")
} }
if $setup_test_volume {
class {'::cinder::setup_test_volume':}
}
} }

View File

@@ -0,0 +1,54 @@
require 'spec_helper'
describe 'openstack::cinder::controller' do
let :required_params do
{
:db_password => 'db_password',
:rabbit_password => 'rabpass',
:keystone_password => 'user_pass'
}
end
let :facts do
{ :osfamily => 'Redhat' }
end
let :params do
required_params
end
it 'should configure using the default values' do
should contain_class('cinder').with(
:sql_connection => "mysql://cinder:#{required_params[:db_password]}@127.0.0.1/cinder?charset=utf8",
:rpc_backend => 'cinder.openstack.common.rpc.impl_kombu',
:rabbit_userid => 'guest',
:rabbit_password => required_params[:rabbit_password],
:rabbit_host => '127.0.0.1',
:rabbit_port => '5672',
:rabbit_hosts => nil,
:rabbit_virtual_host => '/',
:package_ensure => 'present',
:api_paste_config => '/etc/cinder/api-paste.ini',
:verbose => false
)
should contain_class('cinder::api').with(
:keystone_password => required_params[:keystone_password],
:keystone_enabled => true,
:keystone_user => 'cinder',
:keystone_auth_host => 'localhost',
:keystone_auth_port => '35357',
:keystone_auth_protocol => 'http',
:service_port => '5000',
:package_ensure => 'present',
:bind_host => '0.0.0.0',
:enabled => true
)
should contain_class('cinder::scheduler').with(
:scheduler_driver => 'cinder.scheduler.simple.SimpleScheduler',
:package_ensure => 'present',
:enabled => true
)
end
end

View File

@@ -0,0 +1,63 @@
require 'spec_helper'
describe 'openstack::cinder::storage' do
let :required_params do
{
:sql_connection => 'mysql://a:b:c:d',
:rabbit_password => 'rabpass'
}
end
let :params do
required_params
end
let :facts do
{ :osfamily => 'Redhat' }
end
it 'should configure cinder and cinder::volume using defaults and required parameters' do
should contain_class('cinder').with(
:sql_connection => required_params[:sql_connection],
:rabbit_userid => 'guest',
:rabbit_password => required_params[:rabbit_password],
:rabbit_host => '127.0.0.1',
:rabbit_port => '5672',
:rabbit_hosts => nil,
:rabbit_virtual_host => '/',
:package_ensure => 'present',
:api_paste_config => '/etc/cinder/api-paste.ini',
:verbose => false
)
should contain_class('cinder::volume').with(
:package_ensure => 'present',
:enabled => true
)
should contain_class('cinder::volume::iscsi').with(
:iscsi_ip_address => '127.0.0.1',
:volume_group => 'cinder-volumes'
)
should_not contain_class('cinder::setup_test_volume')
end
describe 'with a volume driver other than iscsi' do
let :params do
required_params.merge(
:volume_driver => 'netapp'
)
end
it { should_not contain_class('cinder::volume::iscsi') }
end
describe 'when setting up test volumes for iscsi' do
let :params do
required_params.merge(
:setup_test_volume => 'setup_test_volume'
)
end
it { should contain_class('cinder::setup_test_volume') }
end
end