diff --git a/manifests/api.pp b/manifests/api.pp index 30d6510b..71413547 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -167,30 +167,18 @@ class trove::api( $key_file = false, $ca_file = false, $manage_service = true, - $ensure_packages = 'present', + $ensure_package = 'present', ) inherits trove { require keystone::python - ensure_packages($trove::params::api_package_name) + ensure_packages($::trove::params::api_package_name) - Package[$trove::params::api_package_name] -> File['/etc/trove/'] Package[$trove::params::api_package_name] -> Trove_config<||> + Trove_config<||> ~> Exec['post-trove_config'] + Trove_config<||> ~> Service['trove-api'] - Trove_config<||> ~> Exec<| title == 'trove-manage db_sync' |> - Exec<| title == 'trove-manage db_sync' |> ~> Service['trove-api'] - Trove_config<||> ~> Service['trove-api'] - - File { - ensure => present, - owner => 'trove', - group => 'trove', - mode => '0640', - notify => Service['trove-api'], - require => Class['trove'] - } - - if $database_connection { + if $::trove::database_connection { if($::trove::database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) { if ($::trove::mysql_module >= 2.2) { require 'mysql::bindings' @@ -219,8 +207,6 @@ class trove::api( 'DEFAULT/bind_port': value => $bind_port; 'DEFAULT/backlog': value => $backlog; 'DEFAULT/trove_api_workers': value => $workers; - 'DEFAULT/verbose': value => $verbose; - 'DEFAULT/debug': value => $debug; } if $auth_uri { @@ -375,7 +361,7 @@ class trove::api( } } - if $rpc_backend == 'trove.openstack.common.rpc.impl_qpid' { + if $::trove::rpc_backend == 'nova.openstack.common.rpc.impl_qpid' { trove_config { 'DEFAULT/qpid_hostname': value => $::trove::qpid_hostname; 'DEFAULT/qpid_port': value => $::trove::qpid_port; @@ -385,12 +371,12 @@ class trove::api( 'DEFAULT/qpid_protocol': value => $::trove::qpid_protocol; 'DEFAULT/qpid_tcp_nodelay': value => $::trove::qpid_tcp_nodelay; } - if is_array($qpid_sasl_mechanisms) { + if is_array($::trove::qpid_sasl_mechanisms) { trove_config { 'DEFAULT/qpid_sasl_mechanisms': value => join($::trove::qpid_sasl_mechanisms, ' '); } } - elsif $qpid_sasl_mechanisms { + elsif $::trove::qpid_sasl_mechanisms { trove_config { 'DEFAULT/qpid_sasl_mechanisms': value => $::trove::qpid_sasl_mechanisms; } diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index eee7a9c9..3844e6b9 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -66,9 +66,9 @@ class trove::db::mysql( $allowed_hosts = undef ) { - Class['trove::db::mysql'] -> Exec<| title == 'trove-manage db_sync' |> + Class['trove::db::mysql'] -> Exec<| title == 'trove-db-sync' |> Mysql::Db[$dbname] -> Anchor<| title == 'trove-start' |> - Mysql::Db[$dbname] ~> Exec<| title == 'trove-manage db_sync' |> + Mysql::Db[$dbname] ~> Exec<| title == 'trove-db-sync' |> if ($mysql_module >= 2.2) { mysql::db { $dbname: @@ -106,7 +106,7 @@ class trove::db::mysql( mysql_module => $mysql_module, } - Trove::Db::Mysql::Host_access[$real_allowed_hosts] -> Exec<| title == 'trove-manage db_sync' |> + Trove::Db::Mysql::Host_access[$real_allowed_hosts] -> Exec<| title == 'trove-db-sync' |> } diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 8be62eb4..74e77d2a 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -15,14 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. # -# Class to execute "trove-manage db_sync" +# Class to execute "trove-manage db_sync # class trove::db::sync { - exec { 'trove-manage db_sync': + exec { 'trove-db-sync': path => '/usr/bin', user => 'trove', refreshonly => true, - subscribe => [Package['trove'], Trove_config['database/connection']], + subscribe => [Package['trove'], Keystone_config['DEFAULT/sql_connection']], require => User['trove'], } } diff --git a/manifests/generic_service.pp b/manifests/generic_service.pp index 362ec0c2..050438e6 100644 --- a/manifests/generic_service.pp +++ b/manifests/generic_service.pp @@ -65,7 +65,6 @@ define trove::generic_service( name => $service_name, enable => $enabled, hasstatus => true, - require => [Package['trove-common'], Package[$package_name]], } } } diff --git a/manifests/init.pp b/manifests/init.pp index 03bf6d97..0cf9cd7d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -141,4 +141,9 @@ class trove( $rpc_backend = 'trove.openstack.common.rpc.impl_kombu', ){ include trove::params + + exec { 'post-trove_config': + command => '/bin/echo "Trove config has changed"', + refreshonly => true, + } } diff --git a/manifests/params.pp b/manifests/params.pp index d7dde40c..04120d20 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,6 @@ class trove::params { case $::osfamily { 'RedHat': { $client_package_name = 'openstack-trove' - $common_package_name = 'openstack-trove-common' $conductor_package_name = 'openstack-trove-conductor' $conductor_service_name = 'openstack-trove-conductor' $api_package_name = 'openstack-trove-api' @@ -17,7 +16,6 @@ class trove::params { } 'Debian': { $client_package_name = 'python-troveclient' - $common_package_name = 'trove-common' $conductor_package_name = 'trove-conductor' $conductor_service_name = 'trove-conductor' $api_package_name = 'trove-api' diff --git a/spec/classes/trove_api_spec.rb b/spec/classes/trove_api_spec.rb new file mode 100644 index 00000000..8c8cb1d0 --- /dev/null +++ b/spec/classes/trove_api_spec.rb @@ -0,0 +1,82 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Author: Emilien Macchi +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for trove::api +# +require 'spec_helper' + +describe 'trove::api' do + + let :pre_condition do + "class {'trove':}" + end + + let :params do + { :keystone_password => 'passw0rd' } + end + + let :facts do + { :processorcount => 5 } + end + + shared_examples 'trove-api' do + + context 'with default parameters' do + + it 'installs trove-api package and service' do + should contain_service('trove-api').with( + :name => platform_params[:api_service_name], + :ensure => 'running', + :hasstatus => true, + :enable => true + ) + should contain_package('trove-api').with( + :name => platform_params[:api_package_name], + :ensure => 'present', + :notify => 'Service[trove-api]' + ) + end + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + let :platform_params do + { :api_package_name => 'trove-api', + :api_service_name => 'trove-api' } + end + + it_configures 'trove-api' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + let :platform_params do + { :api_package_name => 'openstack-trove-api', + :api_service_name => 'openstack-trove-api' } + end + + it_configures 'trove-api' + end + +end