diff --git a/manifests/db.pp b/manifests/db.pp index b2569850..1b592886 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -26,10 +26,10 @@ class ceilometer::db ( $backend_package = 'python-psycopg2' } /^mongodb:\/\//: { - $backend_package = 'python-pymongo' + $backend_package = $::ceilometer::params::pymongo_package_name } /^sqlite:\/\//: { - $backend_package = 'python-pysqlite2' + $backend_package = $::ceilometer::params::sqlite_package_name } default: { fail('Unsupported backend configured') diff --git a/manifests/params.pp b/manifests/params.pp index dbecc7bc..7963c0c2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -20,6 +20,17 @@ class ceilometer::params { $agent_compute_service_name = 'openstack-ceilometer-compute' $api_service_name = 'openstack-ceilometer-api' $collector_service_name = 'openstack-ceilometer-collector' + # db packages + if $::operatingsystem == 'Fedora' and $::operatingsystemrelease >= 18 { + # name change in f18 : https://bugzilla.redhat.com/show_bug.cgi?id=954155 + $pymongo_package_name = 'python-pymongo' + # fallback to stdlib version, not provided on fedora + $sqlite_package_name = undef + } else { + $pymongo_package_name = 'pymongo' + $sqlite_package_name = 'python-sqlite2' + } + } 'Debian': { # package names @@ -34,6 +45,10 @@ class ceilometer::params { $agent_compute_service_name = 'ceilometer-agent-compute' $api_service_name = 'ceilometer-api' $collector_service_name = 'ceilometer-collector' + # db packages + $pymongo_package_name = 'python-pymongo' + $sqlite_package_name = 'python-pysqlite2' + # Operating system specific case $::operatingsystem { 'Ubuntu': { diff --git a/spec/classes/ceilometer_db_spec.rb b/spec/classes/ceilometer_db_spec.rb new file mode 100644 index 00000000..c1f6312b --- /dev/null +++ b/spec/classes/ceilometer_db_spec.rb @@ -0,0 +1,110 @@ +require 'spec_helper' + +describe 'ceilometer::db' do + + # debian has "python-pymongo" + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + let :params do + { :database_connection => 'mongodb://localhost:1234/ceilometer' } + end + + it { should include_class('ceilometer::params') } + + it 'installs python-mongodb package' do + should contain_package('ceilometer-backend-package').with( + :ensure => 'present', + :name => 'python-pymongo') + end + end + + # Fedora > 18 has python-pymongo too + context 'on Redhat platforms' do + let :facts do + { :osfamily => 'Redhat', + :operatingsystem => 'Fedora', + :operatingsystemrelease => 18 + } + end + + let :params do + { :database_connection => 'mongodb://localhost:1234/ceilometer' } + end + + it { should include_class('ceilometer::params') } + + it 'installs pymongo package' do + should contain_package('ceilometer-backend-package').with( + :ensure => 'present', + :name => 'python-pymongo') + end + end + + # RHEL has pymongo + context 'on Redhat platforms' do + let :facts do + { :osfamily => 'Redhat', + :operatingsystem => 'CentOS', + :operatingsystemrelease => 6.4 + } + end + + let :params do + { :database_connection => 'mongodb://localhost:1234/ceilometer' } + end + + it { should include_class('ceilometer::params') } + + it 'installs pymongo package' do + should contain_package('ceilometer-backend-package').with( + :ensure => 'present', + :name => 'pymongo') + end + end + + # RHEL has python-sqlite2 + context 'on Redhat platforms' do + let :facts do + { :osfamily => 'Redhat', + :operatingsystem => 'CentOS', + :operatingsystemrelease => 6.4 + } + end + + let :params do + { :database_connection => 'sqlite:///var/lib/ceilometer.db' } + end + + it { should include_class('ceilometer::params') } + + it 'installs pymongo package' do + should contain_package('ceilometer-backend-package').with( + :ensure => 'present', + :name => 'python-sqlite2') + end + end + + # debian has "python-pysqlite2" + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + let :params do + { :database_connection => 'sqlite:///var/lib/ceilometer.db' } + end + + it { should include_class('ceilometer::params') } + + it 'installs python-mongodb package' do + should contain_package('ceilometer-backend-package').with( + :ensure => 'present', + :name => 'python-pysqlite2') + end + end + +end +