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:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
spec/fixtures/modules/*
|
||||
spec/fixtures/manifests/*
|
||||
*swp
|
||||
.vendor
|
||||
Gemfile.lock
|
||||
|
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,10 @@
|
||||
class openstack::cinder::controller(
|
||||
$cinder_sql_connection,
|
||||
$rabbit_password,
|
||||
$cinder_rpc_backend = 'cinder.openstack.common.rpc.impl_kombu',
|
||||
$keystone_password,
|
||||
$rpc_backend = 'cinder.openstack.common.rpc.impl_kombu',
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_enabled = true,
|
||||
$keystone_user = 'cinder',
|
||||
$keystone_password = 'cinder',
|
||||
$keystone_auth_host = 'localhost',
|
||||
$keystone_auth_port = '35357',
|
||||
$keystone_auth_protocol = 'http',
|
||||
@@ -14,30 +13,42 @@ class openstack::cinder::controller(
|
||||
$rabbit_host = '127.0.0.1',
|
||||
$rabbit_hosts = undef,
|
||||
$rabbit_port = '5672',
|
||||
$cinder_rabbit_virtual_host = '/',
|
||||
$cinder_package_ensure = 'present',
|
||||
$cinder_api_package_ensure = 'latest',
|
||||
$cinder_scheduler_package_ensure = 'latest',
|
||||
$cinder_bind_host = '0.0.0.0',
|
||||
$cinder_api_paste_config = '/etc/cinder/api-paste.ini',
|
||||
$rabbit_virtual_host = '/',
|
||||
# Database. Currently mysql is the only option.
|
||||
$db_type = 'mysql',
|
||||
$db_user = 'cinder',
|
||||
$db_password = 'cinder_pass',
|
||||
$db_host = '127.0.0.1',
|
||||
$db_dbname = 'cinder',
|
||||
$package_ensure = present,
|
||||
$api_package_ensure = present,
|
||||
$scheduler_package_ensure = present,
|
||||
$bind_host = '0.0.0.0',
|
||||
$api_paste_config = '/etc/cinder/api-paste.ini',
|
||||
$scheduler_driver = 'cinder.scheduler.simple.SimpleScheduler',
|
||||
$cinder_api_enabled = true,
|
||||
$cinder_scheduler_enabled = true,
|
||||
$cinder_verbose = 'False'
|
||||
$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':
|
||||
sql_connection => $cinder_sql_connection,
|
||||
rpc_backend => $cinder_rpc_backend,
|
||||
sql_connection => $sql_connection,
|
||||
rpc_backend => $rpc_backend,
|
||||
rabbit_userid => $rabbit_userid,
|
||||
rabbit_password => $rabbit_password,
|
||||
rabbit_host => $rabbit_host,
|
||||
rabbit_port => $rabbit_port,
|
||||
rabbit_hosts => $rabbit_hosts,
|
||||
rabbit_virtual_host => $cinder_rabbit_virtual_host,
|
||||
package_ensure => $cinder_package_ensure,
|
||||
api_paste_config => $cinder_api_paste_config,
|
||||
verbose => $cinder_verbose,
|
||||
package_ensure => $package_ensure,
|
||||
api_paste_config => $api_paste_config,
|
||||
verbose => $verbose,
|
||||
}
|
||||
|
||||
class {'::cinder::api':
|
||||
@@ -48,15 +59,15 @@ class openstack::cinder::controller(
|
||||
keystone_auth_port => $keystone_auth_port,
|
||||
keystone_auth_protocol => $keystone_auth_protocol,
|
||||
service_port => $keystone_service_port,
|
||||
package_ensure => $cinder_api_package_ensure,
|
||||
bind_host => $cinder_bind_host,
|
||||
enabled => $cinder_api_enabled,
|
||||
package_ensure => $api_package_ensure,
|
||||
bind_host => $bind_host,
|
||||
enabled => $api_enabled,
|
||||
}
|
||||
|
||||
class {'::cinder::scheduler':
|
||||
scheduler_driver => $scheduler_driver,
|
||||
package_ensure => $cinder_scheduler_package_ensure,
|
||||
enabled => $cinder_scheduler_enabled,
|
||||
package_ensure => $scheduler_package_ensure,
|
||||
enabled => $scheduler_enabled,
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,43 +6,45 @@ class openstack::cinder::storage(
|
||||
$rabbit_hosts = undef,
|
||||
$rabbit_port = '5672',
|
||||
$rabbit_virtual_host = '/',
|
||||
$cinder_package_ensure = 'present',
|
||||
$package_ensure = 'present',
|
||||
$api_paste_config = '/etc/cinder/api-paste.ini',
|
||||
$cinder_package_ensure = 'latest',
|
||||
$cinder_volume_package_ensure = 'latest',
|
||||
$volume_package_ensure = 'present',
|
||||
$volume_group = 'cinder-volumes',
|
||||
$cinder_volume_enabled = true,
|
||||
$iscsi_enabled = true,
|
||||
$enabled = true,
|
||||
$volume_driver = 'iscsi',
|
||||
$iscsi_ip_address = '127.0.0.1',
|
||||
$setup_test_volume = true,
|
||||
$cinder_verbose = 'False',
|
||||
$setup_test_volume = false,
|
||||
$verbose = false
|
||||
) {
|
||||
|
||||
class {'::cinder':
|
||||
sql_connection => $cinder_sql_connection,
|
||||
sql_connection => $sql_connection,
|
||||
rabbit_userid => $rabbit_userid,
|
||||
rabbit_password => $rabbit_password,
|
||||
rabbit_host => $rabbit_host,
|
||||
rabbit_port => $rabbit_port,
|
||||
rabbit_hosts => $rabbit_hosts,
|
||||
rabbit_virtual_host => $rabbit_virtual_host,
|
||||
package_ensure => $cinder_package_ensure,
|
||||
api_paste_config => $cinder_api_paste_config,
|
||||
verbose => $cinder_verbose,
|
||||
package_ensure => $package_ensure,
|
||||
api_paste_config => $api_paste_config,
|
||||
verbose => $verbose,
|
||||
}
|
||||
|
||||
|
||||
class { '::cinder::volume':
|
||||
package_ensure => $cinder_volume_package_ensure,
|
||||
enabled => $cinder_volume_enabled,
|
||||
package_ensure => $volume_package_ensure,
|
||||
enabled => $enabled,
|
||||
}
|
||||
if $iscsi_enabled {
|
||||
class { '::cinder::volume::iscsi':
|
||||
|
||||
if $volume_driver == 'iscsi' {
|
||||
class { 'cinder::volume::iscsi':
|
||||
iscsi_ip_address => $iscsi_ip_address,
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
54
spec/classes/openstack_cinder_controller_spec.rb
Normal file
54
spec/classes/openstack_cinder_controller_spec.rb
Normal 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
|
63
spec/classes/openstack_cinder_storage_spec.rb
Normal file
63
spec/classes/openstack_cinder_storage_spec.rb
Normal 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
|
Reference in New Issue
Block a user