Add openstack::cinder::all class
This patch adds openstack::cinder::all to deploy cinder services all-in-one. This will be used to refacter the openstack::all. Partially implements blueprint openstack-cinder-class Change-Id: I231db777ef4e1310d6f4e549e7a711117de811b7
This commit is contained in:
96
manifests/cinder/all.pp
Normal file
96
manifests/cinder/all.pp
Normal file
@@ -0,0 +1,96 @@
|
||||
class openstack::cinder::all(
|
||||
$rabbit_password,
|
||||
$keystone_password,
|
||||
$db_password,
|
||||
$rpc_backend = 'cinder.openstack.common.rpc.impl_kombu',
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_enabled = true,
|
||||
$keystone_user = 'cinder',
|
||||
$keystone_auth_host = 'localhost',
|
||||
$keystone_auth_port = '35357',
|
||||
$keystone_auth_protocol = 'http',
|
||||
$keystone_service_port = '5000',
|
||||
$rabbit_userid = 'openstack',
|
||||
$rabbit_host = '127.0.0.1',
|
||||
$rabbit_hosts = undef,
|
||||
$rabbit_port = '5672',
|
||||
$rabbit_virtual_host = '/',
|
||||
# Database. Currently mysql is the only option.
|
||||
$db_type = 'mysql',
|
||||
$db_user = 'cinder',
|
||||
$db_host = '127.0.0.1',
|
||||
$db_dbname = 'cinder',
|
||||
$package_ensure = present,
|
||||
$bind_host = '0.0.0.0',
|
||||
$api_paste_config = '/etc/cinder/api-paste.ini',
|
||||
$scheduler_driver = 'cinder.scheduler.simple.SimpleScheduler',
|
||||
$enabled = true,
|
||||
$volume_group = 'cinder-volumes',
|
||||
$volume_driver = 'iscsi',
|
||||
$iscsi_ip_address = '127.0.0.1',
|
||||
$setup_test_volume = false,
|
||||
$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"
|
||||
} else {
|
||||
fail("Unsupported db_type ${db_type}")
|
||||
}
|
||||
|
||||
class {'::cinder':
|
||||
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 => $package_ensure,
|
||||
api_paste_config => $api_paste_config,
|
||||
verbose => $verbose,
|
||||
}
|
||||
|
||||
class {'::cinder::api':
|
||||
keystone_password => $keystone_password,
|
||||
keystone_enabled => $keystone_enabled,
|
||||
keystone_user => $keystone_user,
|
||||
keystone_auth_host => $keystone_auth_host,
|
||||
keystone_auth_port => $keystone_auth_port,
|
||||
keystone_auth_protocol => $keystone_auth_protocol,
|
||||
service_port => $keystone_service_port,
|
||||
package_ensure => $package_ensure,
|
||||
bind_host => $bind_host,
|
||||
enabled => $enabled,
|
||||
}
|
||||
|
||||
class {'::cinder::scheduler':
|
||||
scheduler_driver => $scheduler_driver,
|
||||
package_ensure => $package_ensure,
|
||||
enabled => $enabled,
|
||||
}
|
||||
|
||||
class {'::cinder::volume':
|
||||
package_ensure => $package_ensure,
|
||||
enabled => $enabled,
|
||||
}
|
||||
|
||||
if $volume_driver {
|
||||
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':
|
||||
volume_name => $volume_group,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warning("Unsupported volume driver: ${volume_driver}, make sure you are configuring this yourself")
|
||||
}
|
||||
}
|
||||
}
|
98
spec/classes/openstack_cinder_all_spec.rb
Normal file
98
spec/classes/openstack_cinder_all_spec.rb
Normal file
@@ -0,0 +1,98 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'openstack::cinder::all' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:db_password => 'db_password',
|
||||
:rabbit_password => 'rabpass',
|
||||
:keystone_password => 'user_pass'
|
||||
}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it 'should configure using the default values' do
|
||||
should contain_class('cinder').with(
|
||||
:sql_connection => "mysql://cinder:#{params[:db_password]}@127.0.0.1/cinder?charset=utf8",
|
||||
:rpc_backend => 'cinder.openstack.common.rpc.impl_kombu',
|
||||
:rabbit_userid => 'openstack',
|
||||
:rabbit_password => 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 => 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
|
||||
)
|
||||
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
|
||||
before do
|
||||
params.merge!(
|
||||
:volume_driver => 'netapp'
|
||||
)
|
||||
end
|
||||
it { should_not contain_class('cinder::volume::iscsi') }
|
||||
end
|
||||
|
||||
describe 'when setting up test volumes for iscsi' do
|
||||
before do
|
||||
params.merge!(
|
||||
:setup_test_volume => true
|
||||
)
|
||||
end
|
||||
it { should contain_class('cinder::setup_test_volume').with(
|
||||
:volume_name => 'cinder-volumes'
|
||||
)}
|
||||
describe 'when volume_group is set' do
|
||||
before do
|
||||
params.merge!(:volume_group => 'foo')
|
||||
end
|
||||
it { should contain_class('cinder::setup_test_volume').with(
|
||||
:volume_name => 'foo'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
context 'with unsupported db type' do
|
||||
|
||||
before do
|
||||
params.merge!({:db_type => 'sqlite'})
|
||||
end
|
||||
|
||||
it do
|
||||
expect { subject }.to raise_error(Puppet::Error, /Unsupported db_type sqlite/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user