diff --git a/.gitignore b/.gitignore index a98de2e..8ffb147 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ spec/fixtures/modules/* spec/fixtures/manifests/* *swp +.vendor +Gemfile.lock diff --git a/manifests/cinder.pp b/manifests/cinder.pp deleted file mode 100644 index 59dfe5b..0000000 --- a/manifests/cinder.pp +++ /dev/null @@ -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, - } - } -} diff --git a/manifests/cinder/controller.pp b/manifests/cinder/controller.pp index 8d45418..90c6fe5 100644 --- a/manifests/cinder/controller.pp +++ b/manifests/cinder/controller.pp @@ -1,43 +1,54 @@ class openstack::cinder::controller( - $cinder_sql_connection, $rabbit_password, - $cinder_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', - $keystone_service_port = '5000', - $rabbit_userid = 'guest', - $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', - $scheduler_driver = 'cinder.scheduler.simple.SimpleScheduler', - $cinder_api_enabled = true, - $cinder_scheduler_enabled = true, - $cinder_verbose = 'False' + $keystone_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 = 'guest', + $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_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', + $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, } } diff --git a/manifests/cinder/storage.pp b/manifests/cinder/storage.pp index 036490b..b3d15e4 100644 --- a/manifests/cinder/storage.pp +++ b/manifests/cinder/storage.pp @@ -1,48 +1,50 @@ class openstack::cinder::storage( $sql_connection, $rabbit_password, - $rabbit_userid = 'guest', - $rabbit_host = '127.0.0.1', - $rabbit_hosts = undef, - $rabbit_port = '5672', - $rabbit_virtual_host = '/', - $cinder_package_ensure = 'present', - $api_paste_config = '/etc/cinder/api-paste.ini', - $cinder_package_ensure = 'latest', - $cinder_volume_package_ensure = 'latest', - $volume_group = 'cinder-volumes', - $cinder_volume_enabled = true, - $iscsi_enabled = true, - $iscsi_ip_address = '127.0.0.1', - $setup_test_volume = true, - $cinder_verbose = 'False', + $rabbit_userid = 'guest', + $rabbit_host = '127.0.0.1', + $rabbit_hosts = undef, + $rabbit_port = '5672', + $rabbit_virtual_host = '/', + $package_ensure = 'present', + $api_paste_config = '/etc/cinder/api-paste.ini', + $volume_package_ensure = 'present', + $volume_group = 'cinder-volumes', + $enabled = true, + $volume_driver = 'iscsi', + $iscsi_ip_address = '127.0.0.1', + $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") } - if $setup_test_volume { - class {'::cinder::setup_test_volume':} - } } diff --git a/spec/classes/openstack_cinder_controller_spec.rb b/spec/classes/openstack_cinder_controller_spec.rb new file mode 100644 index 0000000..5e678aa --- /dev/null +++ b/spec/classes/openstack_cinder_controller_spec.rb @@ -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 diff --git a/spec/classes/openstack_cinder_storage_spec.rb b/spec/classes/openstack_cinder_storage_spec.rb new file mode 100644 index 0000000..acd3584 --- /dev/null +++ b/spec/classes/openstack_cinder_storage_spec.rb @@ -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